Eimantas Bernotavicius / Mbed 2 deprecated Buggy_Project

Dependencies:   QEI mbed

Committer:
Weranest
Date:
Thu Feb 15 13:19:37 2018 +0000
Revision:
0:62e51b80d738
Child:
1:12f18cede014
Test commit please ignore

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Weranest 0:62e51b80d738 1 //this defines motor setup and movement
Weranest 0:62e51b80d738 2 #include "mbed.h"
Weranest 0:62e51b80d738 3 #include "C12832.h"
Weranest 0:62e51b80d738 4 #include "pins.cpp"
Weranest 0:62e51b80d738 5 //will have to determine real pulsewidths by testing with encoder
Weranest 0:62e51b80d738 6 //constants to be utilized in the buggy, can be changed as required
Weranest 0:62e51b80d738 7 #define NORMAL_PWM 0.5f
Weranest 0:62e51b80d738 8 #define FAST_PWM 0.7f
Weranest 0:62e51b80d738 9 #define SLOW_PWM 0.3f
Weranest 0:62e51b80d738 10 #define RIGHT_MOTOR_CONST 1
Weranest 0:62e51b80d738 11 #define LEFT_MOTOR_CONST 1
Weranest 0:62e51b80d738 12 #define MOTOR_PERIOD 1.0f
Weranest 0:62e51b80d738 13
Weranest 0:62e51b80d738 14 //currently the setup uses unipolar mode, hence the need for direction
Weranest 0:62e51b80d738 15
Weranest 0:62e51b80d738 16
Weranest 0:62e51b80d738 17 void motorSetup(){
Weranest 0:62e51b80d738 18 motorRight.period_ms(MOTOR_PERIOD);
Weranest 0:62e51b80d738 19 motorLeft.period_ms(MOTOR_PERIOD);
Weranest 0:62e51b80d738 20 motorDirLeft.write(1);
Weranest 0:62e51b80d738 21 motorDirRight.write(1);
Weranest 0:62e51b80d738 22 motorModeLeft.write(1);
Weranest 0:62e51b80d738 23 motorModeRight.write(1);
Weranest 0:62e51b80d738 24 driveBoard.write(1);
Weranest 0:62e51b80d738 25 }
Weranest 0:62e51b80d738 26 void buggyGoF(){ //drives forward
Weranest 0:62e51b80d738 27 motorRight.write(NORMAL_PWM);
Weranest 0:62e51b80d738 28 motorLeft.write(NORMAL_PWM);
Weranest 0:62e51b80d738 29 }
Weranest 0:62e51b80d738 30
Weranest 0:62e51b80d738 31 void buggyGoLeft(){// drives left
Weranest 0:62e51b80d738 32 motorRight.write(FAST_PWM);
Weranest 0:62e51b80d738 33 motorLeft.write(SLOW_PWM);
Weranest 0:62e51b80d738 34 }
Weranest 0:62e51b80d738 35 void buggyGoRight(){ //drives fast
Weranest 0:62e51b80d738 36 motorRight.write(SLOW_PWM);
Weranest 0:62e51b80d738 37 motorLeft.write(FAST_PWM);
Weranest 0:62e51b80d738 38 }
Weranest 0:62e51b80d738 39 void buggyStop(){// no power
Weranest 0:62e51b80d738 40 motorRight.write(0.0f);
Weranest 0:62e51b80d738 41 motorLeft.write(0.0f);
Weranest 0:62e51b80d738 42 }