Arduino Functions
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.
motorSpeed(m,p); – Initializes motor(s) m at percent power p.
goFor(t); – Runs the motor(s) at their initialized state for t seconds.
brake(m); – Brakes motor(s) m. This does not stop the AEV from moving, just stops the motors from spinning.
reverse(m); – Reverses the polarity of motor(s) m.
goToRelativePosition(n); – Continues the previous command for n marks( one mark is a full rotation of the wheels) from the vehicles current position. N can be both positive and negative. Positive meaning forward, and negative meaning backwards.
goToAbsolutePosition(n); – Continues the previous command for n marks relative to the overall starting position of the AEV.
Lab 1 Code:
// Run motor one at a constant speed (23% power) for 2.5 second.
motorSpeed(1,23);
goFor(2.5);
// Brake motor one.
brake(1);
Lab 3 Code:
celerate(4,0,25,3); //accelerate all motors to 25% power in 3 seconds
motorSpeed(4,25); // Hold motor speed (for all motors) at 25% power
goFor(1); // for 1 second
motorSpeed(4,20); // change motor speed for all motors to 20% power
goFor(2); // for 3 seconds
reverse(4); // reverse orientation of propeller spinning
motorSpeed(4,25); // change motor speed to 25% power
goFor(2); // for 2 seconds
brake(4); // stop all motors
This code was made for testing all the motors attached to the AEV for functionality.
AR&D:
Reflectance Sensors
reflectanceSensorTest();
Motor Configuration
//pull test
reverse();
motorSpeed(4, 25);
goFor(5);
//push test
motorSpeed(4, 25);
goFor(5);
Wheel Power Efficiency
//run 1
motorSpeed(4, 20);
goToRelativePosition(240);
brake(4);
goFor(10);
//progress from gate scanner to the end
motorSpeed(4, 20);
goToRelativePosition(240);
brake(4);
goFor(5);
//picked up caboose and reverse
reverse(4);
motorSpeed(4, 20);
goToRelativePosition(-30);
brake(4);
goFor(10);
//run 2
reverse(4);
motorSpeed(4, 20);
goToRelativePosition(240);
brake(4);
goFor(10);
//progress from gate scanner to the end
motorSpeed(4, 20);
goToRelativePosition(240);
brake(4);
goFor(5);
//picked up caboose and reverse
reverse(4);
motorSpeed(4, 20);
goToRelativePosition(-30);
brake(4);
goFor(10);
Performance Test 1
//Room 224
//Start to gate and wait for seven seconds
reverse(4);
motorSpeed(4, 32);
goToRelativePosition(-298);
brake(4);
goFor(.5);
reverse(4);
motorSpeed(4, 30);
goFor(.5);
brake(4);
goFor(9);
//progress from gate scanner to the end
reverse(4);
motorSpeed(4, 30);
goFor(3);
brake(4);
Performance Test 2
//Room 224
//Start to gate and wait for seven seconds
motorSpeed(4, 20);
goToRelativePosition(240);
brake(4);
goFor(10);
//progress from gate scanner to the end
motorSpeed(4, 20);
goToRelativePosition(240);
brake(4);
goFor(5);
//picked up caboose and reverse
reverse(4);
motorSpeed(4, 20);
goToRelativePosition(-30);
brake(4);
goFor(10);
Final Test:
//Room 224
//Burst
//motorSpeed(4, 40);
//goFor(0.5);
reverse(4);
motorSpeed(4, 30);
goToRelativePosition(280);
reverse(4);
motorSpeed(4, 30);
goFor(1);
reverse(4);
brake(4);
goFor(10);
//progress from gate scanner to the end
// motorSpeed(4, 40);
//goFor(0.5);
motorSpeed(4, 30);
goToRelativePosition(190);
reverse(4);
motorSpeed(4, 30);
goFor(2);
reverse(4);
brake(4);
goFor(7);
//picked up caboose and reverse
reverse(4);
motorSpeed(4, 50);
goToRelativePosition(-170);
reverse(4);
motorSpeed(4, 30);
goFor(1);
reverse(4);
brake(4);
goFor(10);
//motorSpeed(4, 40);
//goFor(0.5);
motorSpeed(4,40);
goToRelativePosition(-110);
reverse(4);
motorSpeed(4, 30);
goFor(2);
reverse(4);
brake(4);