Code Optimization


To further optimize the AEV, Team B was tasked to create two different codes that would show if the AEV used more or less energy when the percent of power was increased during the test. The percentages that were used during these tests were 20 percent and 30 percent. Shown below is the graph for the average energy used over the distance in performance test 2 for 20 percent motor power.

Graph 1: 20% Motor Power, Energy Consumed

In this graph, the average energy usage for 20 percent motor speed is 4.5747 joules per meter. This is over the distance in meters that the AEV traveled. The graph is very linear in the fact that the energy consumed and average energy consumed are almost exactly the same. Show below this is the graph for 30 percent motor power during performance test 2.

Graph 2: 30% Motor Power, Energy Consumed

In this graph, the average energy usage for 30 percent motor power is 4.1883 joules per meter. This is over the same distance in meters as the 20 percent motor power test. This graph is also relatively linear but less than 20 percent power.

In conclusion, as shown in these graphs above, 20 percent motor power had an average energy usage of 4.575 joules per meter where as 30 percent motor power had 4.188 joules per meter. Using this data, the conclusion is using a higher motor speed; for this test 30 percent, leads to a more energy efficient vehicle. This information will be used in how we set our motor speed in our final code for final performance testing.


Code Used:

Refer here for information on command functions.

20 Percent Power Code (First Code):

Code Explanation
 motorSpeed(4,20);

 goToAbsolutePosition(310);

 brake(4);

Sets all motors power to 20 percent. Then the motor runs until the vehicle counts 310 marks from its starting position. Then brakes.
 motorSpeed(4,0);

 goFor(8);

This sets all of the motors power to 0 percent and ran for 8 seconds. This makes sure that the vehicle stops for 8 seconds before continuing.
 motorSpeed(4,20);

 goToAbsolutePosition(625);

 motorSpeed(4,15);

 goToAbsolutePosition(650);

 brake(4);

Sets all motors power to 20 percent. Then the motor runs until the vehicle counts 625 marks from its starting position. After that the motors are set to 15 percent power. Then the motor runs until the vehicle counts 650 marks from its starting position. Then brakes.

30 Percent Power Code (Second Code):

Code Explanation
 motorSpeed(4,30);

 goToAbsolutePosition(295);

 brake(4);

Sets all motors power to 30 percent. Then the motor runs until the vehicle counts 295 marks from its starting position. Then brakes.
 motorSpeed(4,0);

 goFor(8);

This sets all of the motors power to 0 percent and ran for 8 seconds. This makes sure that the vehicle stops for 8 seconds before continuing.
 motorSpeed(4,30);

 goToAbsolutePosition(580);

 motorSpeed(4,25);

 goToAbsolutePosition(600);

 motorSpeed(4,15);

 goToAbsolutePosition(645);

 brake(4);

Sets all motors power to 30 percent. Then the motors runs until the vehicle counts 580 marks from its starting position. After that the motors are set to 25 percent power. Then the motors runs until the vehicle counts 600 marks from its starting position. After that all motors are set to 15 percent power. Then the motors runs until the vehicle counts 645 marks from the starting position. Then brakes.