Dual DC Motor Drive using PWM for RenBuggy; there are two inputs to feed a hall sensor for distance / speed feedback.
Diff: DCMotorDrive.h
- Revision:
- 3:50495c3c3c37
- Parent:
- 1:0c8cb3439288
- Child:
- 4:b9aafce708b5
--- a/DCMotorDrive.h Wed Jan 15 11:48:01 2014 +0000 +++ b/DCMotorDrive.h Tue Jan 21 13:25:59 2014 +0000 @@ -31,36 +31,35 @@ #include "mbed.h" #define PWM_PERIOD 20 -#define BUFFER_SIZE 16 #define MOTOR_STALL_TIME 2 class DCMotorDrive { public: - DCMotorDrive(PinName MotorOut, PinName SensorIn); + DCMotorDrive(PinName MotorOut, PinName BrakeOut, PinName SensorIn); + void SetMotorPwm(int PwmValue); void SetMotorPwmAndRevolutions(int PwmValue, int MaxRevolutions); int GetAveragePulseTime(void); int GetLastPulseTime(void); + int GetRevolutionsLeft(void); void ResetOdometer(void); int ReadOdometer(void); int ReadCaptureTime(void); - void ClearBuffer(void); private: Ticker timeout; Timer PulseClock; - volatile int ClockBuffer[BUFFER_SIZE]; volatile int ClockPointer; - volatile int CaptureTime; volatile int LastPulseTime; volatile int RotationCounter; volatile int RevolutionLimit; PwmOut _MotorPin; + DigitalOut _BrakePin; InterruptIn _SensorIn; void Counter(void); void Stall(void); }; -#endif // _DCMOTORDRIVE_H +#endif // _DCMOTORDRIVE_H \ No newline at end of file