Mbed library to control a motor via DRV8833 H-bridge motor controller. Uses two Pwmouts.
DRV8833.h
- Committer:
- xeta05
- Date:
- 2013-10-15
- Revision:
- 0:80e26be59f41
- Child:
- 1:048f85990e31
File content as of revision 0:80e26be59f41:
/* mbed simple DRV8833 H-bridge motor controller * * * PWM a un puente en H(DRV8833) conectado a los motores. * El comportamiento del driver es el siguiente * * x_PWM1 x_PWM2 Mode * 0 0 Coast/Fast decay * 0 1 Reverse * 1 0 Forward * 1 1 Brake/slow decay *15/10/2013 */ #ifndef MBED_DRV8833 #define MBED_DRV8833 #include "mbed.h" #define BRAKE_FAST 1 #define BRAKE_SLOW 0 /** Interface to control a standard DC motor * with an DRV8833 H-bridge motor controller * using 2 PwmOuts */ class DRV8833 { public: /** Create a DRV8833 control interface * * @param pwm1 A PwmOut pin, Logic input controls state of AOUT1 * @param pwm2 A PwmOut pin, Logic input controls state of AOUT2 * */ DRV8833(PinName pwm1, PinName pwm2); /** Set the speed of the motor * * @param speed The speed of the motor as a normalised value between -1.0 and 1.0 */ void speed(float speed); /** Set the period of the pwm duty cycle. * * Wrapper for PwmOut::period() * * @param seconds - Pwm duty cycle in seconds. */ void period(float period); /** Brake the H-bridge to fast or slow. * * Defaults to breaking fast. * * Brake fast(coast) => pwm1 = pwm2 = 0 * Brake slow => pwm1 = pwm2 = 1 */ void brake(int highLow = BRAKE_FAST); protected: PwmOut _pwm1; PwmOut _pwm2; }; #endif