Bidirectional PWM motor driver design

Partlist

1 RHE1500 FUSE0
4 1k RESISTOR_QUARTER_WATT R1, R2, R13, R14
4 4N35 4N35 OK1, OK2, OK3, OK4
2 100 RESISTOR_QUARTER_WATT R3, R16
1 100uF 25V CAP_RADIAL_10MM C1
2 IRF540 N-ch power MOSFET T2, T4
2 IRF9540 P-ch power MOSFET T1, T3

Circuit explanation

There are two kinds of power:

  1. logic signals which should come directly from an AVR's output pins and should have the usual logic level, say 5V or so.
  2. "Grunt" power which means high current, possibly high voltage, possibly unregulated power for motor driving. A typical value for UB+ is 12V although this circuit would work with higher voltages up to about 25V. The limit is actually the capacitor C1 - the power transistors can go up to about 50 or 60V! Don't work with such high levels - stick with 12V for now!

When a signal is applied to the PWM and DIR logic inputs there are four possible combinations:

PWM LOW PWM HIGH
DIR LOW MOTOR OFF MOTOR DRIVE CCW
DIR HIGH MOTOR DRIVE CW MOTOR OFF

However "CW" and "CCW" depend of course on how you connect your motor. You can reverse the MOTOR0+ and MOTOR0- connections to the DC motor and of course it will run the other way.

I'll explain the circuit for a certain combination of PWM and DIR input signals. Imagine that PWM happens to be HIGH and DIR happens to be LOW. Current flows through the IR LEDs inside the optocouplers OK1 and OK2. This activates the phototransistors inside the optocouplers. OK1 pulls the gate of power transistor T2 very high - up to the UB+ or battery voltage. This strongly turns on the N-channel T2. At the same time OK2 pulls the gate of T3 low, all the way to the GNDA level (battery negative terminal). This strongly turns on T3. With T2 and T3 both switched on, current can flow through the motor in one direction.

If PWM happened to be LOW and DIR happened to be HIGH, similar reasoning will show that the motor will run in the other direction.

If the state of PWM matches the state of DIR, current cannot flow through any of the optocoupler LEDs so they cannot turn on and the power transistors will not be switched on - they will behave as open circuits.

back to main tutorial page


Dr Nathan Scott · nscott@mech.uwa.edu.au