Simple Interface for Toshiba's TB6612FNG H-Bridge Motor Driver

Committer:
humlet
Date:
Mon Mar 04 21:58:45 2013 +0000
Revision:
0:30d6828516f5
Child:
1:3dd9137a5cec
myfirst

Who changed what in which revision?

UserRevisionLine numberNew contents of line
humlet 0:30d6828516f5 1 /**
humlet 0:30d6828516f5 2 * H-Bridge / Motor Driver TB6612FNG Control Library
humlet 0:30d6828516f5 3 */
humlet 0:30d6828516f5 4
humlet 0:30d6828516f5 5 #ifndef TB6612FNG_H
humlet 0:30d6828516f5 6 #define TB6612FNG_H
humlet 0:30d6828516f5 7
humlet 0:30d6828516f5 8 #include "mbed.h"
humlet 0:30d6828516f5 9
humlet 0:30d6828516f5 10 class TB6612FNG
humlet 0:30d6828516f5 11 {
humlet 0:30d6828516f5 12 PwmOut m_pwm;
humlet 0:30d6828516f5 13 DigitalOut m_ctrl1;
humlet 0:30d6828516f5 14 DigitalOut m_ctrl2;
humlet 0:30d6828516f5 15 int m_dc;
humlet 0:30d6828516f5 16 bool m_on;
humlet 0:30d6828516f5 17
humlet 0:30d6828516f5 18 public:
humlet 0:30d6828516f5 19 /** Create TB6612FNG object connected to the specified mbed pins
humlet 0:30d6828516f5 20 * @param pwm PwmOut pin
humlet 0:30d6828516f5 21 * @param ctrl1/ctrl2 DigitalOut control pin
humlet 0:30d6828516f5 22 */
humlet 0:30d6828516f5 23 TB6612FNG(PinName pwm, PinName ctrl1, PinName ctrl2);
humlet 0:30d6828516f5 24 /// Set the duty cycle
humlet 0:30d6828516f5 25 /// @param dc in permille [-1000,1000]
humlet 0:30d6828516f5 26 void setDC(int dc);
humlet 0:30d6828516f5 27 /// activate the motor at given duty cycle
humlet 0:30d6828516f5 28 void on();
humlet 0:30d6828516f5 29 /// deactivate the motor
humlet 0:30d6828516f5 30 void off();
humlet 0:30d6828516f5 31 /// break the motor by shorting it
humlet 0:30d6828516f5 32 void brake();
humlet 0:30d6828516f5 33 /// duty cycle assignment
humlet 0:30d6828516f5 34 /// @param dc in permille [-1000,1000]
humlet 0:30d6828516f5 35 void operator=(int dc) {
humlet 0:30d6828516f5 36 setDC(dc);
humlet 0:30d6828516f5 37 }
humlet 0:30d6828516f5 38 };
humlet 0:30d6828516f5 39
humlet 0:30d6828516f5 40 #endif