Logic

What Sets Us Apart

 

The Brake Loop

This Loop was designed to account for changes in friction between the wheel and the track to create repeatably in any situation.

How it works

The AEV will travel to a selected position and then cut power to the motor, the code will then start reading the brake loop.

Here is how the code reads:

  1. A flag variable is initialized and the loop begins.
  2. The position is checked
  3. The if loop checks if the position is less then a specified mark.
    1. If it is power is applied in the opposite direction to ensure the AEV comes to a stop.
    2. If not, the loop continues
  4. The code then reads the next if loop
  5. The position is checked again, with a second variable
  6. Each position check is compared and if they are the same, a counter variable has one added to it.
    1. If the counter reaches six, the AEV has came to a stop and code will exit the while loop. This is to keep the code moving forward and removing the possibility of a stack error.
    2. If not the counter variable resets to zero
  7. The while loop repeats if the while loop flag is not changed.

The second position check is designed to ensure the code will continue if the AEV stops before the brake position. The flag variable for this set to six because of how fast the arduino reads the code. This ensures that the AEV is in the same position long enough that is at a full stop.