Arduino

Below are the basic function calls used in the team’s Arduino codes along with their descriptions

celerate(m,p1,p2,t); – accelerates and deccelerates motors m from the starting speed p1(%) to the end speed p2(%) over the time period of t seconds

motorSpeed(m,p); – initializes motor m at speed p(%)

goFor(t); – runs initialized motors for time seconds

brake(m); – brakes motor m

reverse(m); – reverses polarity of motor m

goToRelativePosition(n); – continues the previous command for marks. This value can be positive (forwards) or negative (backwards)

goToAbsolutePosition(n); – continues the the previous command for n marks relative to the AEV’s starting position.

 

 


 

Scenario One

//Program between here

 

//Accelerate motor one from start to 15% power in 2.5 seconds.

celerate(1,0,15,2.5);

//Run motor one at a constant speed (15% power) for 1 second.

motorSpeed(1,15);

goFor(1);

//Brake motor one

brake(1);

// Accelerate motor two from start to 27% power in 4 seconds.

celerate(2,0,27,4);

// Run motor two at a constant speed (27% power) for 2.7 seconds.

motorSpeed(2,27);

goFor(2.7);

//  Decelerate motor two to 15% power in 1 second.

celerate(2,27,15,1);

//brake motor two

brake(2);

//reverse the direction of only motor 2

reverse(2);

//Accelerate all motors from start to 31% power in 2 seconds.

celerate(4,0,31,2);

// Run all motors at a constant speed of 35% power for 1 second.

motorSpeed(4,35);

goFor(1);

// Brake motor two but keep motor one running at a constant speed (35% power) for 3 seconds

brake(2);

motorSpeed(1,35);

goFor(3);

//brake all motors for 1 second

brake(4);

goFor(1);

//reverse the direction of motor one

reverse(1);

//Accelerate motor one from start to 19% power over 2 seconds.

celerate(1,0,19,2);

//Run motor two at 35% power while simultaneously running motor one at 19% power for 2 seconds.

motorSpeed(2,35);

motorSpeed(1,19);

goFor(2);

// Run both motors at a constant speed (19% power) for 2 seconds

motorSpeed(4,19);

goFor(2);

// Decelerate both motors to 0% power in 3 seconds

celerate(4,19,0,3);

//brake all motors

brake(4);

 

Scenario Two 

[From PreR&D lab 2]

void myCode()
{
  //—————————————————————————————-
  // myCode();
  //
  // This is the tab where the programming of your vehicle operation is done.
  // Tab _00_AEV_key_words contains a compiled list of functions/subroutines used for vehicle
  // operation. 
  //
  // Note:
  // (1) After running your AEV do not turn the AEV off, connect the AEV to a computer, or 
  //     push the reset button on the Arduino. There is a 13 second processing period. In 
  //     post processing, data is stored and battery recuperation takes place. 
  // (2) Time, current, voltage, total marks, position traveled are recorded approximately 
  //     every 60 milliseconds. This may vary depending on the vehicles operational tasks. 
  //     It takes approximately 35-40 milliseconds for each recording. Thus when programming,
  //     code complexity may not be beneficial. 
  // (3) Always comment your code. Debugging will be quicker and easier to do and will 
  //     especially aid the instructional team in helping you. 
  //—————————————————————————————- 
  // Program between here——————————————————————-
  
 // run all motors for 2 sec at 25%
 motorSpeed(4,25);
 goFor(2);
 // run all motors for 12ft at 20%
motorSpeed(4,20);
goToAbsolutePosition(123);
//reverse all motors
reverse(4); 
//run all motors for 1.5 sec at 30%
motorSpeed(4,30);
goFor(1.5);
// brake all motors
brake(4);
  // And here——————————————————————————–
} // DO NOT REMOVE. end of void myCode()