Arduino Code Used

This sections highlights all code tested to ensure that the team knows how to use Arduino and that all equipment functions properly.

EXERCISE 1

celerate(1,0,15,2.5);  //accelerate motor 1 to 15% power in 2.5 seconds

motorSpeed(1,15);    //run motor 1 at 15% power for 1 second

goFor(1);

brake(1);                     //stop motor 1

celerate(2,0,27,4);    //accelerate motor 2 to 27% power in 4 seconds

motorSpeed(2,27):   //run motor 2 at 27% power for 2.7 seconds

goFor(2.7);

celerate(2,27,15,1);   //decelerate motor 2 from 27% to 15% power in 1 second

brake(2);                     //stop motor 2

The code above accelerates only motor one from rest to 15% power in 2.5 seconds and runs the motor at that power for 1 second before braking. Then the second motor is accelerated from rest to 27% power in 4 seconds. The motor is run at that power for 2.7 seconds before being decelerated to 15% power in one second. After the motor reaches 15% power, it is braked.

 

EXERCISE 2

motorSpeed(4,25);                   //run both motors at 25% power for 2 seconds

goFor(2);

motorSpeed(4,20);                  //decrease motor speeds to 20%

goToAbsolutePosition(295);  //continue until AEV reaches 295 marks

reverse(4);                                  //reverse both motors

motorSpeed(4,30);                   //run both motors at 30% power for 1.5 seconds

goFor(1.5);

brake(4);                                    //stop both motors

The code above runs both motors at 25% power for 2 seconds. Then both motors run at 20% power for the time it takes to move 12 feet. Both motors then reverse, run at 30%power for 1.5 seconds, and then brake.

 

EXERCISE 4

celerate(4,0,25,3);      //accelerate both motors to 25% power over 3 seconds
motorSpeed(4,25);     //run both motors at 25% power for 1 second
goFor(1);
motorSpeed(4,20);    //run both motors at 20% power for 2 seconds
goFor(2);
reverse(4);                   //reverse both motors
motorSpeed(4,25);    //run both motors at 25% power for 2 seconds
goFor(2);
brake(4);                      //stop both motors

The code above accelerates both motors from rest to 25% power in three seconds. Once that power is reached, the motors run for one second before being set to 20% for two seconds. After two seconds is up both motors are reversed and set to 25% power for two seconds. All motors are braked after the two seconds. While testing the data analysis tool, this was the code used. This was also the run where the AEV was first tested on the track.

 

Motor Configuration Code
celerate(4,0,40,3);   //accelerate both motors to 40% power over 3 seconds
celerate(4,40,0,3);   //decelerate both motors from 40% to 0% power over 3 seconds
reverse(4);                 //reverse both motors
celerate(4,0,40,3);   //accelerate both motors to 40% power over 3 seconds
celerate(4,40,0,3);   //decelerate both motors from 40% to 0% power over 3 seconds
brake(4);                    //stop both motors

The code above accelerates both motors from 0% to 40% power in 3 seconds, then decelerates from 40% to 0% power in 3 seconds. The motors then reverse direction, accelerate to 40% power in 3 seconds, and decelerate from 40% power to 0% power in 3 seconds again. This was the only code used to test the motor configurations, as it was important to maintain consistent testing conditions across all three configurations. The AEV completes the same maneuvers in the forward and reverse portions of the run in order to facilitate the comparison of each configurations effectiveness in the forward direction to that in the reverse direction.

 

Battery Voltage Testing Code 1
motorSpeed(4,17);   //run both motors at 17% power for 15 seconds
goFor(15);
reverse(4);                 //reverse both motors
motorSpeed(4,10);   //run both motors at 10% power for 10 seconds
goFor(10);
brake(4);                    //stop both motors

The code above runs both motors at 17% power for 15 seconds. The motors then reverse, run at 10% power for 10 seconds, and then brake. This was the first iteration used for testing the battery voltage. The speeds and times were low in order to get a general idea of the speed an duration for which the AEV could be safely run on the overhead track. The forward speed and duration was greater than the reverse speed and duration because the track was found to have a slight downward slope in the reverse direction.

 

Battery Voltage Testing Code 2
motorSpeed(4,20);   //run both motors at 20% power for 40 seconds
goFor(40);
reverse(4);                  //reverse both motors
motorSpeed(4,20);   //run both motors at 20% power for 10 seconds
goFor(10);
brake(4);                     //stop both motors

The code above runs both motors at 20% power for 40 seconds. The motors then reverse, run at 20% power for 10 seconds, and then brake. This was the second and final iteration of the code used for the battery voltage testing. It was favorable over the earlier iteration because the AEV covered more distance each time the code was run because both the motor speed and the duration of the testing interval were greater than those used in the first iteration of the code, allowing more data to be collected on the changes in the battery voltage over time.

 

Performance Test 1:

Prototype 1 Code

motorSpeed(4,37);                    //run both motors at 37% power

goToAbsolutePosition(188);     //continue until AEV has travelled 188 marks

brake(4);                                    //stop both motors

goToAbsolutePosition(208);     //coast until AEV reaches 208 marks

reverse(4);                                 //reverse both motors

motorSpeed(4,32);                     //run motors at 32% power for 2 seconds (air braking)

goFor(2);

brake(4);                                    //stop both motors

goFor(8);                                    //remain stopped for 8 seconds

reverse(4);                                  //reverse both motors

motorSpeed(4,30);                     //run both motors at 30% power for 2 seconds (exit gate)

goFor(2);

brake(4);                                    //stop both motors

 

Prototype 2 Code

motorSpeed(4,37);                    //run both motors at 37% power

goToAbsolutePosition(187);   //continue until AEV reaches 187 marks

brake(4);                                     //stop both motors

goToAbsolutePosition(207);  //coast until a AEV reached 207 marks

reverse(4);                                   //reverse both motors

motorSpeed(4,37);                    //run motors at 37% power for 2 seconds (air braking)

goFor(2);

brake(4);                                      //stop both motors

goFor(8);                                     //remain stopped for 8 seconds

reverse(4);                                   //reverse both motors

motorSpeed(4,30);                    //run both motors at 30% power for 2 seconds (exit gate)

goFor(2);

brake(4);                                      //stop both motors

Each of these pieces of code was written for the AEV to move from rest at one end of the track to the first gate, pause there for seven seconds,  then proceed to the opposite end of the track, where it coupled with the caboose and remained at rest for five seconds. The slight difference in prescribed distances between codes (goToAbsolutePosition) are due to the fact that the two prototypes required slightly different amounts of power and time to move the same distance.

 

Performance Test 2:

Code with Higher Power

motorSpeed(4,37);                  //run both motors at 37% power

goToAbsolutePosition(191);  //continue until AEV reaches 191 marks

brake(4);                                   //stop both motors

goToAbsolutePosition(211);  //coast until AEV reaches 211 marks

reverse(4);                                //reverse both motors

motorSpeed(4,35);                 //run both motors at 35% power for 2 seconds (air braking)

goFor(2);

brake(4);                                  //stop both motors

goFor(8);                                 //remain stopped for 8 seconds

reverse(4);                               //reverse both motors

motorSpeed(4,34);                //run both motors at 34% power for 2 seconds (exit gate)

goFor(2);

brake(4);                                 //stop both motors

goFor(13);                              //coast ~7 seconds, remain stopped ~6 seconds

reverse(4);                              //reverse both motors

motorSpeed(4,55);                //run both motors at 55% power for 2 seconds (start return trip)

goFor(2);

 

Code with Lower Power

motorSpeed(4,27);                  //run both motors at 27% power

goToAbsolutePosition(242); //continue until AEV reaches 242 marks

brake(4);                                    //stop both motors

goToAbsolutePosition(257);  //coast until AEV reaches 257 marks

reverse(4);                                 //reverse both motors

motorSpeed(4,23);                  //run both motors at 23% power for 2 seconds (air braking)

goFor(2);

brake(4);                                //stop both motors

goFor(8);                                //remain stopped for 8 seconds

reverse(4);                             //reverse both motors

motorSpeed(4,34);              //run both motors at 34% power for 2 seconds (exit gate)

goFor(2);

brake(4);                               //stop both motors

goFor(13);                             //coast ~7 seconds, remain stopped ~6 seconds

reverse(4)                              //reverse both motors

motorSpeed(4,55);              //run both motors at 55% power for 2 seconds (start return trip)

goFor(2);

Both of these pieces of code are designed for the AEV to move from the the starting position at the close end of the track to the gate, where it stopped in front of the first sensor for seven seconds, thereby triggering the opening mechanism of the gate. The AEV would then use a two second burst of motor power to accelerate out of the gate and coast down the downward sloped section of track toward the far end where the caboose was located. It remained stopped there after coupling with the caboose, and would then run its motors in the reverse direction for two seconds to initiate motion back toward the beginning of the track. Due to the lower motor speeds used in the first half of the code in the second version, the length of the initial powered phase had to be increased in order to reach to top of the incline, and the braking power had to be decreased as not to overpower the AEV’s reduced forward velocity as it approached the gate.

 

Final Performance Test

motorSpeed(4,27);                  //run both motors at 27% power
goToAbsolutePosition(238); //continue until AEV reaches 238 marks
brake(4);                                    //stop both motors
goToAbsolutePosition(253);  //coast until AEV reaches 253 marks
reverse(4);                                 //reverse both motors
motorSpeed(4,25);                  //run both motors at 25% power for 2 seconds (air braking)
goFor(2);
brake(4);                                //stop both motors
goFor(7);                                //remain stopped for 7 seconds
reverse(4);                             //reverse both motors
motorSpeed(4,34);              //run both motors at 34% power for 2 seconds (exit gate)
goFor(2);
brake(4);                                    //stop both motors
goToAbsolutePosition(565); //coast until AEV reaches 565 marks
reverse(4);                                //reverse both motors
motorSpeed(4,25);                 //run both motors at 25% power for 1 second
goFor(1);
brake(4);                                  //stop both motors
goFor(10);                               //coast for ~4 seconds, remain stopped for ~6 seconds
motorSpeed(4,55);                   //run both motors at 55% power
goToAbsolutePosition(450);  //continue until AEV reaches 450 marks
brake(4);                                     //stop both motors
goToAbsolutePosition(428);  //coast until AEV reaches 428 marks
reverse(4);                                  //reverse both motors
motorSpeed(4,41);                   //run both both motors at 41% power for 2 seconds
goFor(2);
brake(4);                                    //stop both motors
goFor(8);                                   //coast for 8 seconds
reverse(4);                                //reverse both motors
motorSpeed(4,55);                 //run both motors at 55% power for 3 seconds
goFor(3);
brake(4);                                  //stop both motors
goToAbsolutePosition(64); //coast until AEV reaches 64 marks
reverse(4);                              //reverse both motors
motorSpeed(4,39);               //run both motors at 39% power for 2 seconds
goFor(2);
brake(4);                                //stop both motors

The above code was designed for the AEV to move from the the starting position at the close end of the track to the gate, where it stopped in front of the first sensor for seven seconds, thereby triggering the opening mechanism of the gate. The AEV would then use a two second burst of motor power to accelerate out of the gate and coast down the downward sloped section of track toward the far end where the caboose was located. It remained stopped there for five seconds after coupling with the caboose, and would then run its motors in the reverse direction until reaching a point just short of the gate’s first sensor, whereupon it’s motors would reverse and run in the reverse direction, stopping it just behind the gate. The AEV remained stopped there for seven seconds, reverse its motors, and run them for three seconds to clear the gate. It would then coast toward the close end of the track, and then reverse and run its motors to bring it to a stop between the two track supports nearest the end.