Below is the code used for testing and data that was collecting.
The code below was used to control a AEV model and used to test the coding and functions of the AEVs.
celerate(1,0,15,2,5); //Accelerate motor one from start to 15% power in 2.5 seconds.
goFor(1); //Run motor one at a constant speed (15% power) for 1 second.
brake(1); //Brake motor one.
celerate(2,0,27,4); //Accelerate motor two from start to 27% power in 4 seconds.
goFor(2.7); //Run motor two at a constant speed (27% power) for 2.7 seconds.
celerate(2,27,15,1); //Decelerate motor two to 15% power in 1 second.
brake(2); //Brake motor two.
reverse(2); //Reverse the direction of only motor 2.
celerate(4,0,31,2); //Accelerate all motors from start to 31% power in 2 seconds.
motorSpeed(4,35); //Initializes all motors to 35% power.
goFor(1); //Run all motors at a constant speed of 35% power for 1 second.
celerate(2,35,0,3); //Brake motor two but keep motor one running at a constant speed (35% power) for 3 seconds.
brake(4); //Brake all motors for 1 second.
reverse(1); //Reverse the direction of motor one.
celerate(1,0,19,2); //Accelerate motor one from start to 19% power over 2 seconds.
celerate(2,0,35,2);
celerate(1,0,19,2); //Run motor two at 35% power while simultaneously running motor one at 19% power for 2 seconds.
motorSpeed(2,19);
goFor(4,2); //Run both motors at a constant speed (19% power) for 2 seconds.
celerate(4,19,0,3); //Decelerate both motors to 0% power in 3 seconds.
brake(4); //Brake all motors.
SaveAs: PrgmBasics //Save Program as PrgmBasics.
The code below was used to test the reflectance sensors and determine if the sensors were installed correctly and are able to be used to track distance. This was monitored using the Serial Monitor in Arduino. The test was successful but the sensors were tracking backward so they were reversed.
reflectanceSensorTest(); //Used to test the reflectance sensors
motorSpeed(4, x); //Runs all motors at 35% speed
goToAbsolutePosition(265); //Continues to run the motors for 265 marks
brake(4); //Stops all motors
reverse(4); //Reverses all motors
motorSpeed(4, x); //Runs motors at 35% speed
goFor(1.5); //Goes for 1.5 seconds for power braking
brake(4); //Stops power braking
reverse(4); //Reverses all motors
goFor(7); //Waits for 7 seconds
motorSpeed(4,x); //Starts all motors at 35% speed
goToAbsolutePosition(530); //Continues to run the motors for 530 marks
brake(4); //Stops all motors
reverse(4); //Reverses all motors
motorSpeed(4,x); //Runs motors at 35% speed
goFor(2); //Goes for 2 seconds for power braking
brake(4); //Stops power braking
goFor(5); //Waits for caboose to attach
motorSpeed(4,45); //Runs all motors at 45% speed
goToRelativePosition(-221); //Goes a total distance of 221 marks
brake(4); //Stops all motors
reverse(4); //Reverses all motors
motorSpeed(4, 49); //Runs motors at 49% speed
goFor(2.5); //Goes for 2.5 seconds for power braking
brake(4); //Stops power braking
goFor(8); //Waits for 8 seconds
reverse(4); //Reverses all motors
motorSpeed(4, 45); //Runs all motors at 45% speed
goToRelativePosition(-145); //Continues for a total distance of 145 marks
brake(4); //Stops all motors
goToRelativePosition(-36); //Waits until travel 36 marks
reverse(4); //Reverses all motors
motorSpeed(4, 49); //Runs motors at 49% speed
goFor(3.5); //Runs for 3.5 seconds for power braking
brake(4); //Stops power braking
reverse(4); //Reverses all motors