1. Programming Code

Code Glossary:

celerate(m,p1,p2,t);

  • Accelerates motor(s) from speed 1 to speed 2 in t seconds.

motorSpeed(m,p);

  • Runs motor(s) at specified power

goFor(t);

  • Runs motor(s) at predetermined state for t seconds.

brake(m);

  • Brakes (cuts power to) specified motor(s)

reverse(m);

  • Reverses direction of specified motor(s)

goToRelativePosition(n);

  • Goes n marks, either forwards or backwards (positive or negative n values) from current position

goToAbsolutePosition(n);

  • Goes n marks relative to starting position of vehicle.

 

Exercise 1: Programming Basic Code

celerate(1,0,15,2.5);

-Accelerates motor one to 15% power in 2.5 seconds

motorSpeed(1,15);

-motor one runs at 15% power

goFor(1);

-runs for 1 second

brake(1);

-brakes motor 1

celerate(2,0,27,4);

-accelerates motor two to 27% power in 4 seconds

motorSpeed(2,27);

-runs motor two at 27% power

goFor(2.7);

-runs for 2.7 seconds

celerate(2,27,15,1);

-decelerates motor 2 from 27% power to 15% power in 1 second

brake(2);

-brake motor 2

reverse(2);

-reverse motor 2

celerate(4,0,31,2);

-accelerates all motors to 31% power in 2 seconds

motorSpeed(4,35);

-runs both motors at 35% power

goFor(1);

-runs for 1 second

brake(2);

-brakes motor 2

motorSpeed(1,35);

-runs motor 2 at 35% power

goFor(3);

-runs for 3 seconds

brake(4);

-brakes both motors

goFor(1);

-brakes for 1 second

reverse(1);

-reverses motor 1

celerate(1,0,19,2);

-accelerates motor one to 19% power in 2 seconds

motorSpeed(2,35);

-sets speed of motor one to 35% power

motorSpeed(1,19);

-sets speed of motor 2 to 19% power

goFor(2);

-runs both motors for 2 seconds

motorSpeed(4,19);

-runs both motors at 19% power

goFor(2);

-runs for 2 seconds

celerate(4,19,0,3);

-decelerates to 0% power in 3 seconds

brake(4);

-brakes all motors

 

Exercise 2 Reflectance Sensor Code

motorSpeed(4,25);

-sets both motors to 35% power

goFor(2);

-runs both motors for 2 seconds

motorSpeed(4,20);

-runs both motors at 20% power

goToAbsolutePosition(295);

-goes to position of 295 marks

reverse(4);

-reverses both motors

motorSpeed(4,30);

-runs both motors at 30% power

goFor(1.5);

-runs motors for 1.5 seconds

brake(4);

-brakes both motors

 

Exercise 4: Design Analysis Tool Code

celerate(4,0,25,3);

-accelerates both motors to 25% power in 3 seconds

motorSpeed(4,25);

-runs both motors at 25% power

goFor(1);

-runs for 1 second

reverse(4);

-reverses both motors

motorSpeed(4,25);

-runs both motors at 25% power

goFor(2);

-runs for 3 seconds

brake(4);

-brakes both motors

 

Advanced Research and Development Code:

code for propeller config pull-push system:

celerate(4,0,50,3);

-accelerates both motors to 50% power in 3 seconds

motorSpeed(4,50);

-runs both motors at 50% power

goFor(2);

-runs for 2 seconds

brake(4);

-brakes both motors

goFor(2);

-brakes for 2 seconds

reverse(4);

-reverses both motors

motorSpeed(4,50);

-runs both motors at 50% power

goFor(3);

-runs for 3 seconds

code for propeller config push-pull system and motor config:

reverse(4);

-reverses both motors (start from push configuration)

celerate(4,0,50,3);

-accelerates both motors to 50% power in 3 seconds

motorSpeed(4,50);

-runs both motors at 50% power

goFor(2);

-runs for 2 seconds

brake(4);

-brakes both motors

goFor(2);

-brakes for 2 seconds

reverse(4);

-reverses both motors (pull configuration)

motorSpeed(4,50);

-runs both motors at 50% power

goFor(3);

-runs for 3 seconds

 

Performance Test 1 Design 1 

celerate(4,0,30,30; 

-accelerates both motors from 0 to 30% power in 3 seconds 

motorSpeed(4,30); 

-runs both motors at 30% power 

goToRelativePosition(230); 

-AEV goes 230 marks relative to where it was 

brake(4); 

-brakes both motors 

goFor(10); 

-brakes for 10 seconds 

motorSpeed(4,30); 

-runs both motors at 30% power 

goFor(2); 

-runs for 2 seconds 

 

Performance Test 1 Design 2 

celerate(4,0,30,3); 

-accelerates both motors from 0 to 30% power in 3 seconds 

motorSpeed(4,30); 

-runs both motors at 30% power 

goToRelativePosition(200); 

-AEV goes 200 marks relative to where it was 

brake(4); 

-brakes both motors 

goFor(10); 

-brakes for 10 seconds 

motorSpeed(4,30); 

-runs both motors at 30% power 

goFor(2); 

-runs for 2 seconds 

 

Performance Test 2 Code 1 

reverse(4); 

-reverse all motors 

celebrate(4,0,30,3); 

-accelerates all motors from 0 to 30% power in 3 seconds 

motorSpeed(4,30); 

-runs all motors at 30% power 

goToRelativePosition(223.5); 

-AEV goes 223.5 marks relative to current position 

brake(4); 

-brakes all motors 

goFor(11); 

-brakes for 11 seconds 

celerate(4,0,30,2); 

-accelerates all motors from 0 to 30% power in 2 seconds 

motorSpeed(4,30); 

-runs all motors at 30% power 

goToRelativePosition(105); 

-AEV goes 105 marks relative to current position 

brake(4); 

-brakes all motors 

goFor(10); 

-brakes for 10 seconds 

reverse(4); 

-reverses all motors 

celerate(4,0,40,2); 

-accelerates all motors from 0 to 40% power in 2 seconds 

motorSpeed(4,40); 

-runs all motors at 40% power 

goToRelativePosition(-120); 

-AEV goes -120 marks relative to current position 

brake(4); 

-brakes all motors 

 

Performance Test 2 Code 2 

reverse(4); 

– reverse all motors 

celerate(4,0,65,2); 

-accelerates all motors from 0 to 65% power in 2 seconds 

motorSpeed(4,65); 

-runs all motors at 65% power  

goToRelativePosition(67.2); 

-AEV goes 67.2 marks relative to current position 

brake(4); 

-brakes all motors 

goFor(11); 

-brakes for 11 seconds 

celerate(4,0,65,2); 

-accelerates all motors from 0 to 65% in 2 seconds 

motorSpeed(4,65); 

-runs all motors at 65% power 

goToRelativePosition(30); 

– AEV goes 30 marks relative to current position 

brake(4); 

-brakes all motors 

goFor(11); 

-brakes for 11 seconds 

reverse(4); 

-reverses all motors 

celerate(4,0,70,2); 

– accelerates all motors from 0 to 70% in 2 seconds 

motorSpeed(4,70); 

– runs all motors at 65% power 

goToRelativePosition(-50); 

– AEV goes -50 marks relative to current position 

brake(4); 

-brakes all motors 

 

Performance Test 3 / Final Test Code

reverse(4); 

– reverse all motors

celebrate(4,0,30,3); 

-accelerates all motors from 0 to 30% power in 3 seconds 

motorSpeed(4,30); 

-runs all motors at 30% power 

goToRelativePosition(218); 

-AEV goes 218 marks relative to current position 

brake(4); 

-brakes all motors 

goFor(10.5); 

-brakes for 10.5 seconds 

celerate(4,0,65,2); 

-accelerates all motors from 0 to 65% in 2 seconds 

motorSpeed(4,65); 

-runs all motors at 65% power 

goToRelativePosition(25); 

– AEV goes 25 marks relative to current position 

brake(4); 

-brakes all motors 

goFor(11); 

-brakes for 11 seconds 

reverse(4); 

-reverses all motors 

celerate(4,0,60,2); 

-accelerates all motors from 0 to 60% in 2 seconds 

motorSpeed(4,60); 

-runs all motors at 60% power 

goToRelativePosition(-193); 

– AEV goes -193 marks relative to current position 

brake(4); 

-brakes all motors 

reverse(4); 

-reverses all motors 

motorSpeed(4,60); 

-runs all motors at 60% power 

goFor(2); 

-runs for 2 seconds

brake(4); 

-brakes all motors 

goFor(8); 

-brakes for 8 seconds 

reverse(4); 

-reverses all motors 

celerate(4,0,65,2); 

-accelerates all motors from 0 to 65% in 2 seconds 

motorSpeed(4,65); 

-runs all motors at 65% power

goToRelativePosition(-42); 

– AEV goes -42 marks relative to current position 

brake(4); 

-brakes all motors 

goToRelativePosition(-262); 

– AEV goes -262 marks relative to current position 

reverse(4); 

-reverses all motors 

motorSpeed(4,60); 

-runs all motors at 60% power

goFor(.75); 

-runs for 2 seconds

brake(4); 

-brakes all motors