Simple Interface for Toshiba's TB6612FNG H-Bridge Motor Driver
Diff: TB6612FNG.h
- Revision:
- 0:30d6828516f5
- Child:
- 1:3dd9137a5cec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TB6612FNG.h Mon Mar 04 21:58:45 2013 +0000 @@ -0,0 +1,40 @@ +/** + * H-Bridge / Motor Driver TB6612FNG Control Library + */ + +#ifndef TB6612FNG_H +#define TB6612FNG_H + +#include "mbed.h" + +class TB6612FNG +{ + PwmOut m_pwm; + DigitalOut m_ctrl1; + DigitalOut m_ctrl2; + int m_dc; + bool m_on; + +public: + /** Create TB6612FNG object connected to the specified mbed pins + * @param pwm PwmOut pin + * @param ctrl1/ctrl2 DigitalOut control pin + */ + TB6612FNG(PinName pwm, PinName ctrl1, PinName ctrl2); + /// Set the duty cycle + /// @param dc in permille [-1000,1000] + void setDC(int dc); + /// activate the motor at given duty cycle + void on(); + /// deactivate the motor + void off(); + /// break the motor by shorting it + void brake(); + /// duty cycle assignment + /// @param dc in permille [-1000,1000] + void operator=(int dc) { + setDC(dc); + } +}; + +#endif