A DC motor is a coil, and a coil resists changes in current. When the switch feeding the motor opens, the current has nowhere to go, and the coil’s voltage can jump well above the supply. That spike can destroy a transistor or MOSFET. A flyback diode, sometimes called a freewheel diode, placed across the motor gives the current a path to circulate and die away safely.
What happens when a motor switches off
- The coil stores energy in its magnetic field.
- The voltage across an inductor is L × di/dt. When the current changes quickly, the voltage can become large.
- Without a diode, that voltage appears across the switch. It can exceed the switch’s rating and cause damage. At a mechanical switch, it causes sparking.
Where to place the diode
Put the diode directly across the motor’s two terminals, as close to the motor as you can.
+V
│
┌─────┴─────┐
│ │
motor flyback diode
│ (cathode to +V)
│ │
└─────┬─────┘
│
MOSFET drain
│
MOSFET
│
GND
For a low-side MOSFET, as in the diagram:
- The diode’s cathode (the banded end) goes to the positive supply, on the motor’s + side.
- The diode’s anode goes to the MOSFET drain, on the motor’s − side.
In normal operation, the diode is reverse-biased and carries no current. When the MOSFET turns off, the motor’s voltage reverses. The diode then conducts, and the current circulates through the motor and the diode. The current dies away through the winding resistance.
Choosing the diode
- Current: rated for at least the motor’s stall current, because it carries the motor current during each switch-off.
- Reverse voltage: rated above the supply voltage, with some margin.
- Speed: a general-purpose rectifier such as the 1N4001 to 1N4007 family is common in small, low-frequency circuits. For PWM at higher frequencies, a fast-recovery or Schottky diode is a better fit. Schottky diodes have lower reverse-voltage ratings, so check the datasheet.
Mistakes to avoid
- Diode the wrong way round: a backwards diode conducts as soon as the supply is on. It then shorts the supply through itself, and it can overheat or fail. Check the band before you solder.
- Diode far from the motor: long leads add inductance and weaken the protection. Keep the leads short.
- Assuming the MOSFET protects itself: some MOSFETs have an internal body diode, but it is not always suitable as a freewheel diode. Check the datasheet, and add an external diode if in doubt.
Parts that may already have one
- Many motor driver chips include built-in clamp diodes. The L293D is one example. Check your chip’s datasheet, and whether your module adds its own diodes.
- Relays, solenoids and other coils are inductive loads too, and they need the same kind of protection.
For a PWM circuit that uses this protection, see DC motor speed control using PWM. For an H-bridge, see how to reverse a DC motor with an H-bridge.