Eurobot2012_Primary
Dependencies: mbed Eurobot_2012_Primary
motors.h
00001 #ifndef MOTORS_H 00002 #define MOTORS_H 00003 00004 #include "mbed.h" 00005 #include "QEI.h" 00006 #include "PID.h" 00007 #include "TSH.h" 00008 00009 class Motors { 00010 00011 public: 00012 Motors(); 00013 Motors(TSI2C &i2cin); 00014 00015 //Functions declaration 00016 void resetEncoders(); 00017 int getEncoder1(); 00018 int getEncoder2(); 00019 void move(int distance, int speed); 00020 void turn(int angle, int speed); 00021 int getSignOfInt(int direction); 00022 void setSpeed(int speed); 00023 void setSpeed(int speed1, int speed2); 00024 void stop(); 00025 void setMode(int mode); 00026 int encoderToDistance(int encoder); 00027 int distanceToEncoder(int distance); 00028 void sendCommand(char command); 00029 void sendCommand(char command1, char command2 ); 00030 void speedRegulatorTask(); 00031 float _debug1; 00032 float _debug2; 00033 int accelerationRegister; //turns on acceleration control 00034 void coastStop(); 00035 00036 private: 00037 00038 void _setSpeed(int speed1, int speed2); 00039 void _stop(); 00040 void _stop(int motor1, int motor2); 00041 QEI Encoder1; 00042 QEI Encoder2; 00043 DigitalOut Motor1A; 00044 DigitalOut Motor1B; 00045 DigitalOut Motor2A; 00046 DigitalOut Motor2B; 00047 PwmOut Motor1Enable; 00048 PwmOut Motor2Enable; 00049 int _motorSpeed1; 00050 int _motorSpeed2; 00051 PID PIDControllerMotor1; 00052 PID PIDControllerMotor2; 00053 int _lastEncoder1; 00054 int _lastEncoder2; 00055 int _pidDataBufferIndex; 00056 int _accelerationSpeed1; 00057 int _accelerationSpeed2; 00058 int _enableSpeed; 00059 Ticker _ticker; 00060 00061 }; 00062 00063 #endif
Generated on Tue Jul 12 2022 21:49:58 by 1.7.2