CSS1 – Basic code used for lab: Propeller Configuration
// Accelerate all motors from start to 25% in 3 seconds.
celerate(4,0,25,3);
// Run all motors at a constant speed (25% power) for 1 second.
goFor(1);
// Run all motors at 20% power for 2 seconds.
motorSpeed(4,20); goFor(2);
// Reverse all motors.
reverse(4);
// Run all motors at a constant speed (25% power) for 2 second.
motorSpeed(4,25);
goFor(2);
// Brake all motors.
brake(4);
CSS1_3s_1motor – Code used for the 1 motor test in lab: Motor Quantity
// Accelerate one motor from start to 25% in 3 seconds.
celerate(1,0,25,3);
// Run motor 1 at a constant speed (25% power) for 1 second.
goFor(3);
// Run motor 1 at 20% power for 2 seconds.
motorSpeed(1,20);
goFor(2);
// Reverse motor 1.
reverse(1);
// Run motor 1 at a constant speed (25% power) for 2 second.
motorSpeed(1,25);
goFor(3);
// Brake motor 1.
brake(1);
CSS1_3s_2motors – Code used for the 2 motors test in lab: Motor Quantity
// Accelerate both motors from start to 25% in 3 seconds.
celerate(4,0,25,3);
// Run both motors at a constant speed (25% power) for 1 second.
goFor(3);
// Run both motors at 20% power for 2 seconds.
motorSpeed(4,20);
goFor(2);
// Reverse both motors.
reverse(4);
// Run both motors at a constant speed (25% power) for 2 second. motorSpeed(4,25);
goFor(3);
// Brake both motors.
brake(4);
Performance_test_1 – Code used to complete Performance test 1
#include <PWMServo.h>
PWMServo myservo;
void myCode()
{
myservo.attach(SERVO_PIN_A); // attaches the servo on pin 9 to the servo object
int neutral = 0;
int halt = 30;
myservo.write(neutral);
//Reverse the Motors so the AEV goes forward
reverse(4);
//Set both motors to 25% power;
motorSpeed(4,25);
//Slow down
goToAbsolutePosition(190);
motorSpeed(4,10);
//Go to gate (~310 marks)
goToAbsolutePosition(280); //~310
//Brake AEV
brake(4);
myservo.write(halt);
//Wait for 7 seconds
delay(3500);
myservo.write(neutral);
goFor(4);
//Move past the gate
motorSpeed(4,25);
goFor(2);
brake(4);
}
Performance_test_2- Code used to complete Performance Test 2
#include <PWMServo.h>
PWMServo myservo;
void myCode()
{
myservo.attach(SERVO_PIN_A); // attaches the servo on pin 9 to the servo object
int neutral = 0;
int halt = 30;
myservo.write(neutral);
//Reverse the motors to go forward
reverse(4);
//Set both motors to 25% power;
motorSpeed(4,25);
//Slow down
goToAbsolutePosition(180);
motorSpeed(4,10);
//Go to gate (310 marks)
goToAbsolutePosition(290); //~310
//Brake AEV
brake(4);
myservo.write(halt);
//Wait for 7 seconds
delay(3500);
myservo.write(neutral);
goFor(4);
//Move past the gate
motorSpeed(4,25);
goFor(2);
brake(4);
//BEGIN PHASE 2
//go to load
goToAbsolutePosition(615);
//wait at loading
goFor(5.5);
//Go again
reverse(4);
motorSpeed(4,45);
//BEGIN PHASE 3
//Back to the gate
goToAbsolutePosition(435);
brake(4);
//coast to the gate
goToAbsolutePosition(375);
myservo.write(halt);
delay(3500);
goFor(4);
}
Performance_test_final- Code used to complete the Final Performance Test
#include <PWMServo.h>
PWMServo myservo;
void myCode()
{
myservo.attach(SERVO_PIN_A); // attaches the servo on pin 9 to the servo object
int neutral = 1;
int halt = 30;
myservo.write(neutral);
//Reverse Motors to go forward ———————————————–
reverse(4);
//Set both motors to 25% power;
motorSpeed(4,25);
//Slow down
goToAbsolutePosition(185);
motorSpeed(4,10);
//Go to gate (310 marks)
goToAbsolutePosition(285); //~310
//Brake AEV
brake(4);
myservo.write(halt);
//Wait for 7 seconds
delay(3500);
myservo.write(neutral);
goFor(4);
//Move past the gate
motorSpeed(4,25);
goFor(2);
brake(4);
//BEGIN PHASE 2 ———————————————————————-
//go to load
goToAbsolutePosition(615);
myservo.write(halt);
delay(15);
myservo.write(neutral);
//wait at loading
goFor(7);
//Go again
reverse(4);
motorSpeed(4,44);
//BEGIN PHASE 3 ———————————————————————–
//Back to the gate
goToAbsolutePosition(432);
brake(4);
//coast to the gate
goToAbsolutePosition(375);
myservo.write(halt);
delay(3500);
myservo.write(neutral);
goFor(4);
//Go through gate
motorSpeed(4,60);
goToAbsolutePosition(295);
brake(4);
//Stop at end
goToAbsolutePosition(190);
reverse(4);
motorSpeed(4,30);
goFor(2);
brake(4);
}