TABLE OF CONTENTS:
Common Arduino Function Calls
Exercise 1
Exercise 2
Exercise 4
aR&D #1
aR&D #2
Performance Test #1
Performance Test #2
Final Performance Test
Common Arduino Function Calls:
celerate(m,p1,p2,t);
Accelerates or decelerates motor(s) m from start speed (%) p1 to end speed (%) p2 over a duration of t seconds
E.g. celerate(1,20,45,2); Accelerates motor 1 from 20% to 45% power in 2 seconds
motorSpeed(m,p);
Initializes motor(s) m at percent power p
E.g. motorSpeed(2,16); Sets motor 2 speed to 16% power
goFor(t);
Runs the motor(s) at their initialized state for t seconds
E.g. goFor(5); Runs the motor(s) at their initialized state for 5 seconds
brake(m);
Brakes motor(s) m. Note: This does NOT brake the AEV, just stops the motors from spinning
E.g. brake(4); Cuts the power to all motors
reverse(m);
Reverses the polarity of motor(s) m
E.g. reverse(1); Reverses polarity of motor 1
goToRelativePosition(n);
Continues the previous command for n marks from the vehicle’s current position. n can be positive or negative, with positive meaning the vehicle is moving forward, negative meaning the vehicle is moving backward
E.g. motorSpeed(4,20); goToRelativePosition(30); All motors are set to 20% power, and they will continue to run at 20% power until the AEV reaches 30 marks from its current position
goToAbsolutePosition(n);
Continues the previous command for n marks relative to the overall starting position of the AEV
E.g. motorSpeed(4,20); goToAbsolutePosition(300); All motors are set to 20% power, and they will continue to run at 20% power until the AEV reaches 300 marks from its starting position
Exercise 1:
//Reverse to Align the motors to the correct direction
reverse(4);
//Accelerate motor one from start to 15% power in 2.5 seconds
celerate(1,0,15,2.5);
//Run motor one at a constant speed (15% power) for 1 second
motorSpeed(1,15);
goFor(1);
//Brake motor one
brake(1);
//Accelerate motor two from start to 27% power in 4 seconds.
celerate(2,0,27,4);
//Run motor two at a constant speed (27% power) for 2.7 seconds
motorSpeed(2,27);
goFor(2.7);
//Decelerate motor two to 15% power in 1 second
celerate(2,27,15,1);
//Brake motor two
brake(2);
//Reverse the direction of only motor 2
reverse(2);
//Accelerate all motors from start to 31% power in 2 seconds
celerate(4,0,31,2);
//Run all motors at a constant speed of 35% power for 1 second
motorSpeed(4,35);
goFor(1);
//Brake motor two but keep motor one running at a constant speed (35% power) for 3 seconds
brake(2);
motorSpeed(1,35);
goFor(3);
//Brake all motors for 1 second
brake(4);
goFor(1);
//Reverse the direction of motor one
reverse(1);
//Accelerate motor one from start to 19% power over 2 seconds
celerate(1,0,19,2);
//Run motor two at 35% power while running motor one at 19% power for 2 seconds at the same time
motorSpeed(2,35);
motorSpeed(1,19);
goFor(2);
//Run both motors at a constant speed of 19% power for 2 seconds
motorSpeed(4,19);
goFor(2);
//Decelerate both motors to 0% power in 3 seconds
celerate(4,19,0,3);
//Brake all motors
brake(4);
Exercise 2:
//Reverse to Align the motors to the correct direction
reverse(4);
//Run all motors at a constant speed of 25% power for 2 seconds.
motorSpeed(4,25);
goFor(2);
//Run all motors at a constant speed of 20% to travel a total distance of 12 feet
motorSpeed(4,20);
goToAbsolutePosition(296);
//Reverse motors.
reverse(4);
//Run all motors at a constant 30% power for 1.5 second.
motorSpeed(4,30);
goFor(1.5);
//Brake all motors
brake(4);
Exercise 4:
//Reverse to Align the motors to the correct direction
reverse(4);
//begin the program
celerate(4,0,25,3);
//Runs all motors at a constant speed of 25% power
motorSpeed(4,25);
//Runs motors at that constant speed for 1 second
goFor(1);
//Runs all motors at a constant 25% speed
motorSpeed(4,20);
//Runs motors for 2 seconds at the constant speed
goFor(2);
//Reverses all motors
reverse(4);
//Runs all motors at a constant speed of 25% power
motorSpeed(4,25);
//Runs motors for 2 seconds at the constant 25% power
goFor(2);
//Brake all motors
brake(4);
aR&D #1:
reverse(4);
motorSpeed(4,35);
goFor(5);
brake(4);
aR&D #2:
Trial 1:
reverse(4);
motorSpeed(4,35);
goFor(5);
reverse(4);
motorSpeed(4, 50);
goFor(1);
Trial 2:
reverse(4);
motorSpeed(4,35);
goFor(5);
brake(4);
reverse(4);
motorSpeed(4, 50);
goFor(1);
Trial 3:
reverse(4);
motorSpeed(4,35);
goFor(5);
brake(4);
reverse(4);
motorSpeed(4, 50);
goFor(.15);
Trial 4:
reverse(4);
motorSpeed(4,35);
goFor(5);
brake(4);
reverse(4);
motorSpeed(4, 50);
goFor(.03);
Trial 5:
reverse(4);
motorSpeed(4,35);
goFor(5);
brake(4);
reverse(4);
motorSpeed(4, 50);
goFor(.005);
Trial 6:
reverse(4);
motorSpeed(4,35);
goFor(5);
brake(4);
reverse(4);
motorSpeed(4, 45);
goFor(.25);
Trial 7:
reverse(4);
motorSpeed(4,35);
goFor(5);
reverse(4);
motorSpeed(4, 35);
goFor(1);
brake(4);
Trial 8:
reverse(4);
motorSpeed(4,35);
goFor(5);
reverse(4);
motorSpeed(4, 40);
goFor(1);
brake(4);
Trial 9:
reverse(4);
motorSpeed(4,35);
goFor(5);
reverse(4);
motorSpeed(4, 45);
goFor(1);
brake(4);
Performance Test #1
//Reverse the polarity to align the motor orientation
reverse(4);
//run all motors at 45 percent power for 234 marks
motorSpeed(4,45);
goToAbsolutePosition(234);
//brake all motors and reverse polarity of motors to power brake at gate
brake(4);
reverse(4);
//Run all motors at 45 percent power for 1.2 seconds in opposite direction to power brake
motorSpeed(4,45);
goFor(1.2);
brake;
//Cut power and wait at gate at a speed of 0 percent power for 7 seconds
motorSpeed(4,0);
goFor(7);
//Run all motors at a speed 35 percent power for 2 seconds and brake to allow coasting past the gate
motorSpeed(4,35);
goFor(2);
//Brake to end code
brake(4);
Performance Test #2
//Reverse the polarity to align the motor orientation
reverse(4);
//run all motors at 45 percent power for 234 marks
motorSpeed(4,45);
goToAbsolutePosition(234);
//brake all motors and reverse polarity of motors to power brake at gate
brake(4);
reverse(4);
//Run all motors at 45 percent power for 1.2 seconds in opposite direction to power brake
motorSpeed(4,45);
goFor(1.2);
brake;
//Cut power and wait at gate at a speed of 0 percent power for 7 seconds
motorSpeed(4,0);
goFor(7);
//Run all motors at a speed 45 percent power for 65 marks brake to allow coasting past the gate
reverse(4);
motorSpeed(4,45);
goToRelativePosition(65);
//Brake to allow coasting to the caboose
brake(4);
//Run motors at 0 percent power for 12 seconds to connect to the caboose and wait 5 seconds
motorSpeed(4,0);
goFor(12);
//Reverse polarity of motors to align the orientation
reverse(4);
//Run all motors at 50 percent power for relatively 100 marks in opposite directions towards gate
motorSpeed(4,50);
goToRelativePosition(-100);
//Brake to end code
brake(4);
Final Performance Test
reverse(4);
motorSpeed(4,45);
goToAbsolutePosition(230);
brake(4);
// Reverse polarity of motors
reverse(4);
//Run all motors at 45 percent for 1.2 seconds to Power Brake at gate
motorSpeed(4,45);
goFor(1.2);
brake;
//Wait for gate to open
motorSpeed(4,0);
goFor(7);
reverse(4);
//Run motors at 45 percent power to absolute position 370 marks
motorSpeed(4,45);
goToAbsolutePosition(370);
//brake all motors and wait the 5 seconds connected to the caboose
brake(4);
motorSpeed(4,0);
goFor(11);
//Reverse polarity of motors to get back to the gate
reverse(4);
//Run all motors at 42 percent power to absolute position 438 marks then brake
motorSpeed(4,42);
goToAbsolutePosition(438);
brake(4);
//Reverse polarity of motors
reverse(4);
//Run all motors at 40 percent power for 1.6 seconds to power brake at gate
motorSpeed(4,40);
goFor(1.6);
brake(4);
//wait for gate to open
motorSpeed(4,0);
goFor(9);
//Reverse polarity of motors to transport caboose to the loading zone
reverse(4);
//Run motors at 45 percent power for 3 seconds to loading zone
motorSpeed(4,45);
goFor(3);
//Brake to coast to the end of the loading zone
brake(4);
//Reverse polarity of motors to power break
reverse(4);
//Let AEV coast for 3 seconds before power braking
motorSpeed(4,0);
goFor(3);
//Run motors at 45 percent power for 1.8 seconds to power break to a gradual stop
motorSpeed(4,45);
goFor(1.8);