Glossary of Arduino Functions (“PR&D”):
Function Call | Function |
celerate(m,p1,p2,t);
|
motors (m) are accelerated/decelerated from an initial percent power (p1) to a final percent power (p2) in a time (t) seconds |
motorSpeed(m,p);
|
motors (m) are initialized at percent power (p)
|
goFor(t);
|
motors run for a time (t) seconds at initialized state |
brake(m);
|
brakes motors (m) |
reverse(m);
|
reverses the motors (m) |
goToRelativePosition(n);
|
runs the motors at previous command for n marks (can be positive or negative) |
goToAbsolutePosition(n);
|
runs the motors at previous command for n marks relative to AEV starting position |
Scenario 1:
This code was used to learn how to operate the AEV at the beginning of the semester.
//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.
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.
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);
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 simultaneously running motor one at 19% power for 2 seconds.
motorSpeed(2,35);
goFor(2);
//Run both motors at a constant speed (19% power) for 2 seconds.
motorSpeed(2,19);
goFor(2);
//Decelerate both motors to 0% power in 3 seconds.
celerate(4,19,0,3);
//Brake all motors.
brake(4);
Scenario 2:
This code was also used to learn how to operate the AEV at the beginning of the semester. It was coded for a specific scenario given in lab 2.
motorSpeed(4,25); //sets motor speed of AEV motors from to 25% power
goFor(2); //keeps all motors going at 25% power for 2 seconds
motorSpeed(4,20); //changes all motor speed to 20% power
goToAbsolutePosition(295); //keeps the motors at 20% power until they rotate 295 marks
reverse(4); //reverse the polarity of all motors
motorSpeed(4,30); //changes all motor speed to 30% power
goFor(1.5); //keeps all motors going at 30% power for 1.5 seconds
brake(4); //brakes all motors
Scenario 3:
This code was used to learn how to operate the AEV at the beginning of the semester. It was coded for a specific scenario given in lab 3.
reverse(4); // Now ‘forward’ actually moves the AEV in the direction I want it to
celerate(4,0,40,3); // Found that 25% power didn’t get the AEV to work so I used 40% instead
goFor(1);
motorSpeed(4,35); // Found that 30% power didn’t get the AEV to work so I used 35% instead
goFor(2);
reverse(4);
motorSpeed(4,40); // Found that 25% power didn’t get the AEV to work so I used 40% instead
goFor(2);
brake(4);
Performance Test 1:
This code is for the first performance test of getting the AEV to the stop sign, stopping for 7 seconds, and continuing on. It had some problems such as not stopping the correct spot to trigger the stop sign lift. The reflective sensors ran in the opposite direction in this scenario, which caused our positions to be negative. The vehicle design included our 3-D printed part, which may have contributed to inconsistent results. This code was only tested in one room.
// Room 224
reverse(4);
celerate(4,0,45,2);
goToAbsolutePosition(-360);
brake(4);
reverse(4);
motorSpeed(4,30);
goFor(2);
brake(4);
reverse(4);
motorSpeed(4,0);
goFor(7);
celerate(4,0,45,2);
motorSpeed(4,30);
goFor(2);
brake(4);
Performance Test 2
The reflective sensors were adjusted, so a positive position was used and the vehicle design was changed to a third altered design. This code worked for both rooms.
//Going up hill
celerate(4,0,40,2);
goToAbsolutePosition(350);
brake(4);
//Braking before gate
reverse(4);
motorSpeed(4,20);
goFor(2);
brake(4);
//stopping at gate
reverse(4);
motorSpeed(4,0);
goFor(7);
//going through gate
celerate(4,0,35,2);
motorSpeed(4,35);
goFor(3.1);
brake(4);
//braking before caboose
reverse(4);
motorSpeed(4,20);
goFor(2);
//stopping at caboose for 5 seconds
motorSpeed(4,0);
goFor(7);
//going back up hill with caboose
celerate(4,0,40,3);
goFor(3);
Final Performance Test Code
Code at start of performance testing.
The AEV design used was the same design used in Performance Test 2. The position function was replaced with travelling for a specific time in order to eliminate potential reflectance sensor errors.
/* //224
// going up hill
motorSpeed(4,37.5);
goFor(3.5);
brake(4);
//Braking before gate
reverse(4);
motorSpeed(4,20);
goFor(2);
brake(4);
//stopping at gate
reverse(4);
motorSpeed(4,0);
goFor(7);
//going through gate
motorSpeed(4,30);
goFor(3.5);
brake(4);
//braking before caboose
reverse(4);
motorSpeed(4,15);
goFor(2);
//stopping at caboose for 5 seconds
motorSpeed(4,0);
goFor(5);
//going back up hill with caboose
motorSpeed(4,43.5);
goFor(7);
//braking at top of hill?
reverse(4);
motorSpeed(4,27.5);
goFor(2);
brake(4);
//stopping at gate
reverse(4);
motorSpeed(4,0);
goFor(7);
//going through gate
motorSpeed(4,45);
goFor(5);
brake(4);
//gliding down hill using the power of gravity
motorSpeed(4,0);
goFor(3);
//hard brake
reverse(4);
motorSpeed(4,35);
goFor(2.5);
*/
//308
motorSpeed(4,40);
goToAbsolutePosition(375);
brake(4);
//Braking before gate
reverse(4);
motorSpeed(4,25);
goFor(2);
brake(4);
//stopping at gate
reverse(4);
motorSpeed(4,0);
goFor(7);
//going through gate
motorSpeed(4,35);
goFor(3.4);
brake(4);
//braking before caboose
reverse(4);
motorSpeed(4,17);
goFor(2);
//stopping at caboose for 5 seconds
motorSpeed(4,0);
goFor(5);
//going back up hill with caboose
motorSpeed(4,40);
goFor(7);
//braking at top of hill?
reverse(4);
motorSpeed(4,25);
goFor(2);
brake(4);
//stopping at gate
reverse(4);
motorSpeed(4,0);
goFor(7);
//going through gate
motorSpeed(4,45);
goFor(5);
brake(4);
//gliding down hill using the power of grAVITY
motorSpeed(4,0);
goFor(3);
//hard brake
reverse(4);
motorSpeed(4,40);
goFor(2.5);
Code used on 4/4/19
This code was changed from the previous code and continuously modified to get a code for the final performance test.
/* //224
// going up hill
motorSpeed(4,40);
goFor(3.5);
brake(4);
//Braking before gate
reverse(4);
motorSpeed(4,20);
goFor(2);
brake(4);
//stopping at gate
reverse(4);
motorSpeed(4,0);
goFor(7);
//going through gate
motorSpeed(4,35);
goFor(3.5);
brake(4);
//braking before caboose
reverse(4);
motorSpeed(4,15);
goFor(2);
//stopping at caboose for 5 seconds
motorSpeed(4,0);
goFor(5);
//going back up hill with caboose
motorSpeed(3.75,43);
goFor(7);
//braking at top of hill?
reverse(4);
motorSpeed(4,27.5);
goFor(2);
brake(4);
//stopping at gate
reverse(4);
motorSpeed(4,0);
goFor(7);
//going through gate
motorSpeed(4,45);
goFor(5);
brake(4);
//gliding down hill using the power of gravity
motorSpeed(4,0);
goFor(3);
//hard brake
reverse(4);
motorSpeed(4,35);
goFor(2.5);
*/
//308
motorSpeed(4,40);
goFor(3.27);
brake(4);
//Braking before gate
reverse(4);
motorSpeed(4,41);
goFor(1.65);
brake(4);
//stopping at gate
reverse(4);
motorSpeed(4,0);
goFor(7);
//going through gate
motorSpeed(4,40);
goFor(2.5);
brake(4);
//gliding down hill
motorSpeed(4,0);
goFor(1.5);
//braking before caboose
reverse(4);
motorSpeed(4,23);
goFor(2);
//stopping at caboose for 5 seconds
motorSpeed(4,0);
goFor(5);
//going back up hill with caboose
motorSpeed(4,45);
goFor(5.5);
//braking at top of hill?
reverse(4);
motorSpeed(4,45);
goFor(1);
brake(4);
//stopping at gate
reverse(4);
motorSpeed(4,0);
goFor(7);
//going through gate
motorSpeed(4,45);
goFor(5);
brake(4);
//gliding down hill using the power of grAVITY
motorSpeed(4,0);
goFor(2);
//hard brake
reverse(4);
motorSpeed(4,40);
goFor(2.25);
Finished Final Performance Test Code
This code was used for all three trials of the Final Performance Test, with minor tweaks from previous codes.
/* //224
// going up hill
motorSpeed(4,40);
goFor(3.5);
brake(4);
//Braking before gate
reverse(4);
motorSpeed(4,20);
goFor(2);
brake(4);
//stopping at gate
reverse(4);
motorSpeed(4,0);
goFor(7);
//going through gate
motorSpeed(4,35);
goFor(3.5);
brake(4);
//braking before caboose
reverse(4);
motorSpeed(4,15);
goFor(2);
//stopping at caboose for 5 seconds
motorSpeed(4,0);
goFor(5);
//going back up hill with caboose
motorSpeed(3.75,43);
goFor(7);
//braking at top of hill?
reverse(4);
motorSpeed(4,27.5);
goFor(2);
brake(4);
//stopping at gate
reverse(4);
motorSpeed(4,0);
goFor(7);
//going through gate
motorSpeed(4,45);
goFor(5);
brake(4);
//gliding down hill using the power of gravity
motorSpeed(4,0);
goFor(3);
//hard brake
reverse(4);
motorSpeed(4,35);
goFor(2.5);
*/
//308
motorSpeed(4,42);
goFor(3.28);
brake(4);
//Braking before gate
reverse(4);
motorSpeed(4,40);
goFor(1.55);
brake(4);
//stopping at gate
reverse(4);
motorSpeed(4,0);
goFor(7);
//going through gate
motorSpeed(4,40);
goFor(2.5);
brake(4);
//gliding down hill
motorSpeed(4,0);
goFor(1.62);
//braking before caboose
reverse(4);
motorSpeed(4,20);
goFor(1.6);
//stopping at caboose for 5 seconds
motorSpeed(4,0);
goFor(5);
//going back up hill with caboose
motorSpeed(4,45);
goFor(5.6);
//braking at top of hill?
reverse(4);
motorSpeed(4,45);
goFor(1);
brake(4);
//stopping at gate
reverse(4);
motorSpeed(4,0);
goFor(7);
//going through gate
motorSpeed(4,45);
goFor(5.4);
brake(4);
//gliding down hill using the power of GRAVITY
motorSpeed(4,0);
goFor(2.55);
//hard brake
reverse(4);
motorSpeed(4,42);
goFor(1.85);