Fighting with computers

Computers are not always friendly.

Tuesday, December 19, 2017

H-bridge and PWM for DC motor control

Several times when controlling a DC motor with PWM over an H-bridge I asked myself what could be better during the OFF part of the PWM cycle. I reckon three basic choices are possible:

  1. If all the switches are OFF, then the back EMF will flow through the flyback diodes of the bridge.
  2. The same action as above could be achieved if the switches opposite to the PWM-ON cycle where ON during the OFF period. A braking action is caused.
  3. The motor could be shorted by closing the top (S1+S3) or bottom switches (S2+S4) thus shorting motor current and again creating a braking action too.
Options 2 and 3 correspond to the fast and slow decay modes when the H-bridge is used for controlling one coil of a stepper motor. And even there, it is possible to mix and match so both can be used during a percentage of the PWM OFF time. 

But my doubt came from a user of my dcservo project, who alerted me that a motor was burned and he thought it was caused because my code was using option 3 during the PWM OFF time. That got me thinking whether he was right or not.

In different moments I have used interchangeably options 1 and 3, that is to allow the motor to coast or to brake it when the bridge was not energizing the motor. Mostly due to the availability of pins on the microcontroller or the features of the H-bridge used (some may not have a enable pin). 

A bit of searching led to these great articles on H-bridges, where basic operation and the details of Sign/Magnitude drive and Locked Anti-Phase drive were discussed. Each of them using option 2 or 3 but not 1 made me think that my approach was certainly not wrong.

However, it is possible to just let the motor coast during the PWM OFF time if the bridge has an enable pin. The net effect is that this type of drive will reduce power dissipation on the switches (as they will be on less often) and the motor could run freely when disabled. That may be a problem for a speed control of a robot if the speed command is zero and the robot is downhill, as it may roll all the way down. For a position control, this seems less of a problem, but having the drive both positive and negative torque seems like a better deal for a precise control. 

So my next step is to check whether Lock AntiPhase drive can give me better positioning accuracy over Sign/Magnitude or not.

0 Comments:

Post a Comment

<< Home