Eurobot2012_Primary
Dependencies: mbed Eurobot_2012_Primary
Diff: motors/motors.h
- Revision:
- 2:cffa347bb943
- Child:
- 23:1901cb6d0d95
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/motors/motors.h Thu Apr 26 21:02:12 2012 +0000 @@ -0,0 +1,62 @@ +#ifndef MOTORS_H +#define MOTORS_H + +#include "mbed.h" +#include "QEI.h" +#include "PID.h" +#include "TSH.h" + +class Motors { + +public: + Motors(); + Motors(TSI2C &i2cin); + + //Functions declaration + void resetEncoders(); + int getEncoder1(); + int getEncoder2(); + void move(int distance, int speed); + void turn(int angle, int speed); + int getSignOfInt(int direction); + void setSpeed(int speed); + void setSpeed(int speed1, int speed2); + void stop(); + void setMode(int mode); + int encoderToDistance(int encoder); + int distanceToEncoder(int distance); + void sendCommand(char command); + void sendCommand(char command1, char command2 ); + void speedRegulatorTask(); + float _debug1; + float _debug2; + int accelerationRegister; //turns on acceleration control + +private: + + + void _setSpeed(int speed1, int speed2); + void _stop(); + void _stop(int motor1, int motor2); + QEI Encoder1; + QEI Encoder2; + DigitalOut Motor1A; + DigitalOut Motor1B; + DigitalOut Motor2A; + DigitalOut Motor2B; + PwmOut Motor1Enable; + PwmOut Motor2Enable; + int _motorSpeed1; + int _motorSpeed2; + PID PIDControllerMotor1; + PID PIDControllerMotor2; + int _lastEncoder1; + int _lastEncoder2; + int _pidDataBufferIndex; + int _accelerationSpeed1; + int _accelerationSpeed2; + Ticker _ticker; + +}; + +#endif