Code Progress

Arduino Code from R&D Lab 1:

celerate(1,0,15,1); //accelerates motor 1 from 0 to 15 in 1 sec

motorSpeed(1,15); //set motor 1 speed at 15%

goFor(1); //run last command for 1 sec
brake(1); //brake motor 1

celerate(2,0,27,4); //accelerates motor 2 from 0 to 27 in 2 sec

motorSpeed(2,27); //set motor 2 speed at 27%

goFor(2.7); //run last command for 2.7 sec

celerate(2,27,15,1); //decelerates motor 2 from 27 to 15 in 1 sec
brake(2); //brake motor 2

reverse(2); //reverse motor 2

celerate(4,0,31,2); //accelerates all motors from 0 to 31 in 2 sec

motorSpeed(4,35); //set all motors speed at 35%

goFor(1); //run last command for 1 sec
brake(2); //brake motor 2

motorSpeed(1,35); //set motor 1 speed at 35%

goFor(3); //run last command for 3 sec

brake(4); //brake all motors

reverse(1); //reverse motor 1

celerate(1,0,19,2); //accelerates motor 1 from 0 to 19 in 2 sec

motorSpeed(2,35); //set motor 2 speed at 35%

motorSpeed(1,19); //set motor 1 speed at 19%

goFor(2); //run last command for 2 sec

motorSpeed(4,19) //set all motors speed at 19%

goFor(2); //run last command for 2 sec

celerate(4,19,0,3); //decelerates all motors from 19 to 0 in 3 sec

brake(4); //brake all motors

Arduino Code from R&D Lab 2:

motorSpeed(4,25); //set all motor speed at 25%

goFor(2); //run last command for 2 sec

motorSpeed(4,20); //set all motor speed at 20%

goToAbsolutePosition(295.4); //run the last command until AEV travels 295.4 total wheel counts

reverse(4); //reverse all motors

motorSpeed(4,30); //set all motor speed at 30%

goFor(1.5); //run last command for 1.5 sec

brake(4); //brake all motors

Arduino Code from R&D Lab 4:

celerate(4,0,25,3); //accelerates all motora from 0 to 25 in 3 sec

motorSpeed(4,25); //set all motor speed at 25%

goFor(1); //run last command for 1 sec

motorSpeed(4,20); //set all motor speed at 20%

goFor(2); //run last command for 2 sec

reverse(4); //reverse all motors

motorSpeed(4,25); //set all motor speed at 25%

goFor(2); //run last command for 2 sec

brake(4); //brake all motors

Arduino Code from Battery Testing:

celerate(4,0,30,3); //accelerate both motors to 30% in 2 seconds

motorSpeed(4,30); //set both motor speeds at 30%

goFor(2.5); // continue last command for 2 sec

motorSpeed(4,0): //reduce all motor speed to 0%

Arduino Code from Coasting Test:

celerate(4,0,30,2.5); //accelerate both motors to 30% in 2 seconds

motorSpeed(4,30); // set both motor speeds at 30%

goFor(2.5); //continue last command for 2.5 sec

celerate(4,30,0,2); //reduce all motor speed from 30% to 0% in 2 sec

Arduino Code from Power Braking Test:

celerate(4,0,30,3); //accelerate both motors to 30% in 2 seconds

motorSpeed(4,30); // set both motor speeds at 30%

goFor(2); //continue last command for 2 sec

reverse(4); //reverse all motors

motorSpeed(4,30); //  set both motor speeds at 30%

goFor(2); // continue previous command for 2 sec

From this testing the group decided to move forward with using a mix of braking and coasting during the final performance.

Arduino Code from Performance Test One:

reverse(1); //reverses motor one
motorSpeed(1,50); //sets motor one to 50% power
goToAbsolutePosition(298); //moves AEV to absolute position 298
brake(1); //brakes motor 1
reverse(1); //reverses motor one
reverse(2); /reverses motor two
motorSpeed(1,75); //sets motor one to 75% power
motorSpeed(2,75); //sets motor two to 75% power
goFor(.5); //continues last command for .5 seconds
motorSpeed(4,0); //sets both motors to 0% power
goFor(7); //continues last command for 7 seconds
reverse(1); //reverses motor one
motorSpeed(1,40); //sets motor one to 40% power
goToAbsolutePosition(450);//moves AEV to absolute position 450

 

The group used the previous code for the next section but added the use of relative position on the way back to make coasting a little easier to get consistent.

Arduino Code from Performance Test Two:

reverse(1); //reverses motor one
motorSpeed(1,50); //sets motor one to 50% power
goToAbsolutePosition(289); //moves AEV to absolute position 289
brake(1); //brakes motor 1
reverse(1); //reverses motor one
reverse(2); /reverses motor two
motorSpeed(1,75); //sets motor one to 75% power
motorSpeed(2,75); //sets motor two to 75% power
goFor(.5); //continues last command for .5 seconds
motorSpeed(4,0); //sets both motors to 0% power
goFor(7); //continues last command for 7 seconds
reverse(1); //reverses motor one
motorSpeed(1,40); //sets motor one to 40% power
goToAbsolutePosition(454);//moves AEV to absolute position 454
motorSpeed(1,0); //sets motor one at 0% power
goFor(10); //continues last command for 10 seconds
motorSpeed(2,60); //sets motor two to 60% power
goToRelativePosition(-162);//, moves AEV to relative position 162
motorSpeed(4,0); //sets both motors to 0% power
goFor(11); //continues last command for 11 seconds
motorSpeed(2,60); //sets motor 2 to 60% power
goToRelativePosition(-35); //moves AEV to relative position 35

The final code used a mix of everything we were taught over the semester, with small changed based on how the AEV was performing that day.

Arduino Code from Final Performance:

reverse(1); //reverses motor one
motorSpeed(1,52); //sets motor one to 52% power
goToAbsolutePosition(277); //moves AEV to absolute position 277
brake(1); //brakes motor 1
reverse(1); //reverses motor one
reverse(2); /reverses motor two
motorSpeed(1,71); //sets motor one to 71% power
motorSpeed(2,71); //sets motor two to 71% power
goFor(.5); //continues last command for .5 seconds
motorSpeed(4,0); //sets both motors to 0% power
goFor(7); //continues last command for 7 seconds
reverse(1); //reverses motor one
motorSpeed(1,40); //sets motor one to 40% power
goToAbsolutePosition(430);//moves AEV to absolute position 430
motorSpeed(1,0); //sets motor one at 0% power
goFor(12); //continues last command for 12 seconds
motorSpeed(2,53); //sets motor two to 53% power
goToRelativePosition(-205);//, moves AEV to relative position 205
brake(1); //brake motor 1
reverse(2); //reverse motor 2
motorSpeed(1,80); //Set motor one to 80% power
motorSpeed(2,80); //Set motor two to 80% power
goFor(.5); //Continue last command for .5seconds
motorSpeed(4,0); //Set both motors to 0% power
goFor(12); //Continue last command for 12 seconds
reverse(2); //reverse motor 2
motorSpeed(2,60); //set motor 2 to 60% power
goToRelativePosition(-120); //move AEV to relative position 120
motorSpeed(4,0); //set both motors to 0% power
goFor(2); //continues last command for 2 seconds
reverse(2); //Reverses motor two
motorSpeed(1,70); //Set motor 1 to 70% power
motorSpeed(2,70); //Set motor 2 to 70% power
goFor(1);//Continues last command for 1 second