Programming Basics

Basic Audrino Function Calls

celerate(m,p1,p2,t);

Accelerates or decelerated motor(s) m from start speed (in %) p1 to end speed (in %) p2 over 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

NOTE: This does NOT brake the AEV. This just stops the motors from spinning

reverse(m);

Reverses the polarity of motor(s) m

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

goToAbsolutePosition(n);

Continues the previous command for n marks relative to the overall starting position of the AEV

(cite from Preliminary R&D Labs, carmen.osu.edu, page 5)

 

Example

celerate(1,0,20,3);//  Accelerate motor one from start to 20% power in 3 seconds.

goFor(2);// Run motor one at a constant speed (20% power) for 2 second.

brake(1);//Brake motor one.

celerate(2,0,30,5);//Accelerate motor two from start to 30% power in 5 seconds.

goFor(2.8);//Run motor two at a constant speed (30% power) for 2.8 seconds.

celerate(2,27,15,2);//Decelerate motor two to 15% power in 2 second.

brake(2);//Brake motor two.

reverse(2);//Reverse the direction of only motor 2.

celerate(4,0,35,4);//Accelerate all motors from start to 35% power in 4 seconds.

motorSpeed(4,35);//Run all motors at a constant speed of 35% power.

goFor(5);//for 5 second.

brake(2);//Brake motor two.

goFor(4);//but keep motor one running at a constant speed (35% power) for 4 seconds.

brake(4);//Brake all motors.

goFor(2);//for 2 second.

reverse(1);// Reverse the direction of motor one.

celerate(1,0,11,6);// Accelerate motor one from start to 11% power over 6 seconds.

motorSpeed(2,35);//Run motor two at 12% power.

goFor(2);//while simultaneously running motor one at 11% power for 2 seconds.

motorSpeed(4,19);// Run both motors at a constant speed (19% power).

goFor(2);//for 2 seconds.

celerate(4,19,0,4);//Decelerate both motors to 0% power in 4 seconds.

brake(4);// Brake all motors.

motorSpeed(1,23);  // Run motor one at a constant speed (23% power).

goFor(2.8);//for 2.8 second.

Brake(1); // Brake motor one.