Arduino Code

Arduino Code:

Scenario 1:

//accelerate motor 1 from 0 to 15% in 2.5 secs
celerate(1,0,15,2.5);
//run motor 1 at 15% for 1 sec
motorSpeed(1,15);
goFor(1);
//brake 1
brake(1);
//accelerate motor 2 from 0 to 27% in 4 secs
celerate(2,0,27,4);
//run motor 2 at 27% for 2.7 seconds
motorSpeed(2,27);
goFor(2.7);
//decelerate motor 2 to 15 in 1 second
celerate(2,27,15,1);
//brake 2
brake(2);
//reverse motor 2
reverse(2);
//accelerate all motors from 0 to 31 in 2 secs
celerate(4,0,31,2);
//run all motors at 35 for 1 sec
motorSpeed(4,35);
goFor(1);
//brake motor 2 but keep motor 1 at 35% for 3 secs
brake(2);
motorSpeed(1,35);
goFor(3);
//brake all
brake(4);
goFor(1);
//reverse the direction of motor one
reverse(1)
//accelerate motor 1 from 0 to 19 in 2 secs
celerate(1,0,19,2);
//run motor 2 at 35 while motor 1 is at 19 for 2 secs
motorSpeed(2,35);
motorSpeed(1,19);
goFor(2);
//run both motors at 19 for 2 secs
motorSpeed(19);
//decelerate all motors to 0 in 3 secs
celerate(4,19,0,2);
//brake all
brake(4);

Scenario 2:

//run all motors at 25 for 2
motorSpeed(4,25);
goFor(2);
//run all motors at 20 and go 12 ft (296 marks)
motorSpeed(4,20);
goToAbsolutePosition(296);
//reverse motors
reverse(4);
//run all motors at 30 for 1.5 secs
motorSpeed(4,30);
goFor(1.5);
//brake all
brake(4);

Scenario 4:

Code for Scenario 4:

//accelerate all engines from 0 to 25 for 3 seconds
celerate(4,0,25,3);
//set all motors to 25% for 1 second.
motorSpeed(4,25);
goFor(1);
//set all motors to 20% for 2 seconds.
motorSpeed(4,20);
goFor(2);
//reverse all motors
reverse(4);
//set all motors to 25% for 2 seconds.
motorSpeed(4,25);
goFor(2);
//brake all motors.
brake(4);

 

AR&D Testing Code (Motor Configuration and Prop Configuration):

//push at 25%
motorSpeed(4, 25);
goToRelativePosition(24);
brake(4);
//pull at 25%
reverse(4);
motorSpeed(4, 25);
goToRelativePosition(-24);
brake(4);
//push at 35%
reverse(4);
motorSpeed(4, 35);
goToRelativePosition(24);
brake(4);
//pull at 35%
motorSpeed(4, 25);
goToRelativePosition(24);
brake(4);
reverse(4);

 

Performance Test 1:

//initial track duration
motorSpeed(4,38);
//0.4875 inches/mark – travel
goToRelativePosition(-274);
//power-braking
reverse(4);
motorSpeed(4,41);
goFor(0.9);
//wait at the gate for 7.2 seconds
brake(4);
goFor(7.3);
//reverse engines, and move 20 marks at 35
reverse(4);
motorSpeed(4,35);
goToRelativePosition(-20);
//=====================GATE 1=================================
//cruise to caboose

 
Performance Test 2:

//initial track duration
motorSpeed(4,38);
//0.4875 inches/mark – travel
goToRelativePosition(-274);
//power-braking
reverse(4);
motorSpeed(4,41);
goFor(0.9);
//wait at the gate for 7.2 seconds
brake(4);
goFor(7.3);
//reverse engines, and move 20 marks at 35
reverse(4);
motorSpeed(4,35);
goToRelativePosition(-20);
//=====================GATE 1=================================
//cruise to caboose
motorSpeed(4,33);
goToRelativePosition(-169);
brake(4);
goToRelativePosition(-102);
//brake for a few seconds to pick up caboose
reverse(4);
motorSpeed(4,26);
goFor(0.3);
//brake 5 seconds
brake(4);
goFor(5.3);
//move AEV with caboose 255 marks at 50%
motorSpeed(4,37);
goToRelativePosition(243);
//power brake
reverse(4);
motorSpeed(4,63);
goFor(1);
brake(4);

 
Final Performance Test:

//initial track duration
motorSpeed(4,38);
//0.4875 inches/mark – travel
goToRelativePosition(-274);
//power-braking
reverse(4);
motorSpeed(4,41);
goFor(0.9);
//wait at the gate for 7.2 seconds
brake(4);
goFor(7.3);
//reverse engines, and move 20 marks at 35
reverse(4);
motorSpeed(4,35);
goToRelativePosition(-20);
//=====================GATE 1=================================
//cruise to caboose
motorSpeed(4,33);
goToRelativePosition(-169);
brake(4);
goToRelativePosition(-102);
//brake for a few seconds to pick up caboose
reverse(4);
motorSpeed(4,26);
goFor(0.3);
//brake 5 seconds
brake(4);
goFor(5.3);
//move AEV with caboose 255 marks at 50%
motorSpeed(4,37);
goToRelativePosition(243);
//power brake
reverse(4);
motorSpeed(4,63);
goFor(1);
brake(4);
//=====================GATE 2=================================
//wait at the gate for 7.2 seconds
brake(4);
goFor(7.5);
//reverse engines, and move 20 marks at 35
reverse(4);
motorSpeed(4,54);
goToRelativePosition(60);
brake(4);
goToRelativePosition(197);
//power brake
reverse(4);
motorSpeed(4,43);
goFor(1);
brake(4);