A class for driving a DC motor using a full-bridge (H-bridge) driver.

Dependencies:   RateLimiter

Dependents:   L298N-Breakout-Test Zavrsni_rad_NXP_cup

Committer:
tbjazic
Date:
Wed Jan 14 08:51:14 2015 +0000
Revision:
0:d3f1d0d52615
Child:
1:fb5553d9ff4c
Initial commit.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tbjazic 0:d3f1d0d52615 1 #include "mbed.h"
tbjazic 0:d3f1d0d52615 2 #include "RateLimiter.h"
tbjazic 0:d3f1d0d52615 3
tbjazic 0:d3f1d0d52615 4 /** A class for driving a DC motor using full-bridge MOSFET/IGBT H-driver.
tbjazic 0:d3f1d0d52615 5 * All four transistors' gates are driven separately by four PwmOuts.
tbjazic 0:d3f1d0d52615 6 *
tbjazic 0:d3f1d0d52615 7 * Author(s): TVZ Mechatronics Team
tbjazic 0:d3f1d0d52615 8 *
tbjazic 0:d3f1d0d52615 9 */
tbjazic 0:d3f1d0d52615 10 class HBridgeDCMotor {
tbjazic 0:d3f1d0d52615 11 public:
tbjazic 0:d3f1d0d52615 12 /** Constructor receives the pin names at which the gates are connected.
tbjazic 0:d3f1d0d52615 13 * H stands for high side gate and L for low side.
tbjazic 0:d3f1d0d52615 14 * A and B designate the individual half-bridges.
tbjazic 0:d3f1d0d52615 15 */
tbjazic 0:d3f1d0d52615 16 HBridgeDCMotor(PinName GH_A, PinName GL_A, PinName GH_B, PinName GL_B);
tbjazic 0:d3f1d0d52615 17 /** Set the duty cycle value in range (-1, 1). Negative value means opposite direction. */
tbjazic 0:d3f1d0d52615 18 void setDutyCycle(float dutyCycle);
tbjazic 0:d3f1d0d52615 19 /** Put the drive in a coast mode. */
tbjazic 0:d3f1d0d52615 20 void coast();
tbjazic 0:d3f1d0d52615 21 /** Get the current duty cycle. */
tbjazic 0:d3f1d0d52615 22 float getDutyCycle();
tbjazic 0:d3f1d0d52615 23 private:
tbjazic 0:d3f1d0d52615 24 PwmOut GH_A, GL_A, GH_B, GL_B;
tbjazic 0:d3f1d0d52615 25 RateLimiter rl;
tbjazic 0:d3f1d0d52615 26 float switchingPeriod, dutyCycle, tempDutyCycle, sampleTime;
tbjazic 0:d3f1d0d52615 27 Ticker ticker;
tbjazic 0:d3f1d0d52615 28 void adjustDutyCycle();
tbjazic 0:d3f1d0d52615 29 };