Arduino Programs for All Experiments and Tests

The codes listed have been used in our experiments, and a description of each code shall be provided.

 

 Basic Motor Arduino Program (PR&D: Activity 1)
celerate(1,0,15,2.5); // Accelerates motor 1 to speed of 15% motor capacity
motorSpeed(1,15); // maintains motor speed after acceleration
goFor(1); // maintain speed for 1 second
brake(1); // stop motor 1
celerate(2,0,27,4); // accelerate motor 2 to speed of 27% motor capacity
motorSpeed(2,27); // maintain motor speed after acceleration
goFor(2.7); // maintain motor speed for 2.7 seconds
celerate(2,27,15,1); // reduce speed from 27% to 15%
brake(2); // stop motor two
reverse(2); // reverse blade rotation of motor 2
celerate(4,0,31,2); // accelerate all motors to a speed of 31% motor capacity
motorSpeed(4,35); // increase motor speed to 35% after acceleration
goFor(1); // maintain motor speed for 1 second
brake(2); // stop motor 2
motorSpeed(1,35); // maintain speed on motor one
goFor(3); // maintain speed for 3 seconds
brake(4); stop all motors
goFor(1); // maintain stop for one second
reverse(1); // reverse blade rotation of motor 1
celerate(1,0,19,2); // accelerate motor 1 to a speed of 19% motor capacity
motorSpeed(2,35); // start motor 2 at a speed of 35%
motorSpeed(1,19); // maintain speed of motor 1
goFor(2); // maintain speed for 2 seconds
motorSpeed(4,19); // run all motors at 19% motor capacity
goFor(2); // maintain speed for 2 seconds
celerate(4,19,0,3); // reduce speed of motors to a stop.
brake(4); // stop all motors

________

 Sensor Test Program (PR&D: Activity 2)
motorSpeed(4,25); // start all motors at speed of 25% motor capacity
goFor(2); // maintain speed for 2 seconds
motorSpeed(4,20); // reduce all motor speed to 20% motor capacity
goToAbosolutPosition(295.38); // run motors till AEV reaches absolute position
reverse(4); // reverse blade rotation of all motors
motorSpeed(4,30); // start all motors at speed of 30% motor capacity
goFor(1.5); // maintain speed for 1.5 seconds
brake(4); // stop all motors

_______

Data Analysis Program (PR&D: Activity 4)
celerate(4,0,25,3); // accelerate all motors to 25% motor capacity
motorSpeed(4, 25); // maintain motor speed
goFor(1); // maintain motor speed for 1 second
motorSpeed(4,20); // reduce speed to 20% motor capacity
goFor(2); // maintain motor speed for 1 second
reverse(4); // reverse blade rotation of all motors
motorSpeed(4,25); // start motors at 25% motor capacity
goFor(2); // maintain speed for 2 seconds
brake(4); // stop all motors

______

Power Braking Test Program (AR&D):
celerate(4,0,30,1); // used to accelerate AEV to 30% motor capacity
motorSpeed(4,30); // used to maintain speed
goFor(5); // maintains speed for 5 seconds
brake(4); // shuts off all motors
reverse(4); // reverses the rotation of motor blades
celerate(4,0,50,.2); // used to accelerate AEV to 50% motor capacity
motorSpeed(4,50); // used to maintain speed
goFor(.2); // maintains speed for .2 seconds
brake(4); //shuts down all motors

_____

 Coasting Test Code (AR&D):
celerate(4,0,30,1); // used to get AEV up to speed of 30% motor capacity
motorSpeed(4,30); // used to maintain speed
goFor(5); // maintains speed for 5 seconds
brake(4); // shuts down all motors
_____
Battery Test Program (AR&D):
Battery Testing:
motorSpeed(4,25); // used to set the motors to 25 percent power
goFor(2); // sets the AEV to the previously assigned speed for 2 seconds
motorSpeed(4,20); // used to set the motors to 20 percent speed
goFor(8); // sets the AEV to the previously assigned speed for 8 seconds
reverse(4); // reverses all the motors’ directions
motorSpeed(4,30); // used to set the motors to 30 percent power, now in the opposite direction
goFor(1.5); // sets the AEV to the previously assigned speed for 8 seconds
brake(4); // shuts off all the motors.
 ________
Performance Test 1 Program
reverse(4); // reverse all motors
motorSpeed(4,40); //start motors at 40% motor capacity
goToAbsolutePosition(220); //run motors for 220 marks from initial position
motorSpeed(4,30); //slow motors down to 30% motor capacity
goToAbsolutePosition(233); //run motors for another 13 marks
brake(4); //stop all motors
reverse(4); //reverse all motors
motorSpeed(4,60); //start all motors at 60% motor capacity *
goFor(1); //run motors for one second
brake(4); //brake all motors
reverse(4); //reverse all motors
goFor(7); //wait seven seconds
motorSpeed(4,30); //start all motors at 30% capacity
goFor(1); //run motors for one second
Brake(4); //brake all motors
Comment of change: *The motor speed after the reversal was set too high at a 80% capacity in the beginning of trial runs, causing the vehicle to move backwards slightly when power breaking. This was remedied by slightly lowering the power to a 60% capacity, the sufficient amount required to quickly stop the AEV.
 _____
Performance Test 2 Program
reverse(4); //reverse all motors
motorSpeed(4,40); //start all motors at 40% motor capacity
goToAbsolutePosition(230); //run motors for 230 marks from initial position
motorSpeed(4,30); //slow motors to 30% motor capacity
goToAbsolutePosition(255); //run motors for another 25 marks
brake(4); //brake all motors
reverse(4); //reverse all motors
motorSpeed(4,40); //start all motors at 40% capacity
goFor(1); //run motors for one second
brake(4); //brake all motors
reverse(4); //reverse all motors
goFor(7); //wait for seven second
motorSpeed(4,40); //start all motors at 40% capacity
goFor(4); //run motors for four second
motorSpeed(4,30); //slow motors to 30% capacity
brake(4); //brake all motors
reverse(4); //reverse all motors
motorSpeed(4,43); //start all motors at 43% capacity
goFor(1); //go for one second
brake(4); //brake all motors
goFor(5.5); //wait for five and one half seconds
motorSpeed(4,40); //start motors at 40% capacity
brake(4); //break all motors
____
Final Performance Test Program
reverse(4); //reverse all motors
motorSpeed(4,40); // start all motors at 40% capacity
goToAbsolutePosition(230); // move the AEV 230 marks
motorSpeed(4,30); // slow motors to 30% capacity
goToAbsolutePosition(248); // move the AEV another 18 makrs
brake(4); // stop all motors
reverse(4); // reverse all motors
motorSpeed(4,40); // start all motors at 40% motor capacity
goFor(1); // run motors for one second
brake(4); // stop all motors
reverse(4); // reverse all motors
goFor(7); // wait for seven seconds *to the gate
motorSpeed(4,50); //
goToRelativePosition(180); // move the AEV 180 marks
brake(4); // stop all motors
reverse(4); // reverse all motors
motorSpeed(4,46); // start all motors at 46% motor capacity
goFor(1); // run motors for one second
brake(4); // stop all motors
goFor(5.5); // wait five and a half seconds * at the caboose
motorSpeed(4,40); // start all motors at 40% motor capacity
goToRelativePosition(-256); // move the AEV 256 marks
brake(4); // stop all motors
reverse(4); // reverse all motors
motorSpeed(4,75); // start all motors at 75% motor capacity
goFor(1); // run motors for one second
brake(4); // stop all motors
goFor(8); // wait for eight seconds *gate the second time
reverse(4); // reverse all motors
motorSpeed(4,50); // start all motors at 50% motor capacity
goToRelativePosition(-210); // move the AEV 210 marks*
reverse(4); // reverse all motors
motorSpeed(4,95); // start all motors at 95% motor capacity
goFor(1); // run motors for one second
brake(4); // stop all motors
goFor(1.5); // wait for one and a half seconds
motorSpeed(4,33); // start all motors at 33% motor capacity
goFor(.75); // run motors for three quarters of a second
brake(4); // stop all motors *return to starting position
Comment of Change: *In the last performance test, the team was having trouble stopping the AEV at the correct location towards the second half of the run. In order to remedy this, a goFor function that was originally being used to reach the desired location based on timing and speed, was replaced by a goToRelativePostition function. this function provided more consistency to the stopping location because the distance was now being built off of that which was tracked by the reflectance sensors throughout the test run.