Sub topic 6
Brake, coast, and decay modes
This chapter covers what the motor does when you stop driving it, and how those states shape speed control. It assumes you know the H-bridge layout and how its switch pairs set direction, that you understand inductive kickback and flyback paths, and that you can write basic Arduino code with digitalWrite and analogWrite.
Why "off" has more than one meaning
An H-bridge has four switches, so it offers more than "forward", "reverse", and "off". When you stop pushing current in one direction, the motor is still a spinning mass with a coil of wire. What happens next depends on which switches are closed.
There are two stopped states:
- Coast (also called free-run or high-impedance): all four switches are open. Nothing is connected across the motor terminals except the body diodes.
- Brake: both low-side switches are closed (or both high-side switches). The motor terminals are shorted together.
The difference comes from back-EMF. A spinning motor acts as a generator. Its terminal voltage is roughly proportional to speed. If the terminals are open, no current flows from this generator and only friction and load slow the rotor. If the terminals are shorted, the generated voltage drives a current through the winding resistance. That current produces a torque that opposes rotation, so the motor stops much faster.
Coast
In coast, all four switches are off. The rotor keeps turning until friction, the load, and air drag stop it. A fan or a flywheel can take several seconds to stop.
Coast is the gentle option. The driver draws almost no current and the motor is not stressed. It is also the state to use when you want the shaft to turn freely, for example when a user pushes a robot by hand.
Even in coast, the current already flowing in the winding cannot stop instantly. It finds a path through the body diodes of the bridge back to the supply. This is the flyback path from the previous chapter, and it matters again in the decay modes below.
Brake
In brake, you close both low-side switches. Two input patterns on a typical two-input driver achieve this. On many modules, setting both direction inputs to the same level (both HIGH or both LOW, depending on the chip) while the enable is on produces a brake. Check your driver's truth table, because some chips treat both-HIGH as brake and both-LOW as coast, and others do the reverse.
The braking current is limited only by the back-EMF divided by the winding resistance, plus the small resistance of the switches. For a motor at full speed, this can approach the stall current. The brake is strong when the motor is fast and weakens as it slows, since back-EMF falls with speed.
Brake does not hold a load. Once the rotor stops, back-EMF is zero, so there is no braking torque. A motor on a slope will creep downhill, slowly at first. Holding a position needs a gearbox that resists back-driving, a mechanical brake, or active control with feedback.
| State | Switches | Motor terminals | Stopping behavior |
|---|---|---|---|
| Forward | Q1 and Q4 closed | Driven | Runs |
| Reverse | Q2 and Q3 closed | Driven | Runs |
| Coast | All open | Floating | Slow, free-running |
| Brake (low side) | Q3 and Q4 closed | Shorted | Fast, weakens at low speed |
| Brake (high side) | Q1 and Q2 closed | Shorted | Same, using the high-side switches |
Here Q1 is the high-side switch on the left, Q2 the high-side on the right, Q3 the low-side on the left, and Q4 the low-side on the right. Forward closes Q1 and Q4, and reverse closes Q2 and Q3, which are the diagonal pairs.
What happens during PWM
When you control speed with PWM, the bridge alternates between an "on" phase and an "off" phase thousands of times per second. During the on phase the motor is driven. During the off phase you must choose what the bridge does. That choice is the decay mode, named after how the winding current decays while the supply is disconnected.
Fast decay
In fast decay, the off phase opens all switches (coast). The winding current has nowhere to go but through the body diodes back into the supply. The motor voltage is reversed relative to the current, so the current falls quickly.
Effects of fast decay:
- Current drops fast, so average current is lower and the motor responds with a steep, nonlinear speed curve.
- Current flows back into the supply on every cycle. If the supply cannot absorb it (a battery that is nearly full, a supply with a series diode), the voltage can rise. Decoupling capacitors help.
- Duty cycle maps poorly to speed at low duty, and the motor can stall at low settings.
Slow decay
In slow decay, the off phase shorts the motor terminals (brake). The current recirculates through the low-side switches and the winding, and falls slowly because only the winding resistance and the back-EMF drive it down.
Effects of slow decay:
- Current stays smooth, so ripple is lower and the motor runs more evenly.
- Speed is closer to proportional to duty cycle, which makes control easier.
- The motor is braked during every off phase, so it works against its own motion. At low duty this wastes energy as heat in the winding but gives good low-speed torque.
- The off-phase current flows in the switches rather than the diodes. MOSFET switches usually have lower voltage drop than diodes, so less heat is generated in the driver.
Comparing the modes
| Property | Fast decay (coast on off phase) | Slow decay (brake on off phase) |
|---|---|---|
| Off-phase switches | All open | Both low-side (or both high-side) closed |
| Current path | Body diodes back to supply | Switch and winding loop |
| Current ripple | Higher | Lower |
| Speed versus duty | Less linear | More linear |
| Low-speed behavior | Can stutter or stall | Smoother |
| Supply stress | Pumps current back to supply | Little current returns |
How common drivers implement this
Many cheap modules do not give you a choice. The behavior depends on which pins you modulate.
With an L298N or L293D style driver that has two direction inputs and an enable input, applying PWM to the enable pin while holding direction pins steady gives fast decay. When enable goes low, all outputs turn off and the bridge coasts, so current returns through the diodes. This is what the analogWrite(EN, ...) pattern in the earlier Arduino example does.
If you instead hold enable high and apply PWM to one direction input, with the other input held LOW, the off phase becomes both inputs LOW, which on many of these chips shorts the motor and gives slow decay. The exact result depends on the chip, so read the truth table. Some bipolar drivers like the L298 have high voltage drops in the switches, so the difference is also affected by diode and transistor drops.
Here is a version of the earlier signed-speed function that modulates a direction pin for slow decay. It assumes a driver where both-LOW inputs with enable HIGH short the motor terminals. Verify this against your datasheet before relying on it.
const uint8_t IN1 = 5; // PWM-capable pin
const uint8_t IN2 = 6; // PWM-capable pin
const uint8_t EN = 9; // held HIGH
void setup() {
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(EN, OUTPUT);
digitalWrite(EN, HIGH);
}
// speed: -255 (full reverse) to 255 (full forward), 0 = brake
void setMotorSlowDecay(int speed) {
speed = constrain(speed, -255, 255);
if (speed > 0) {
analogWrite(IN1, speed);
digitalWrite(IN2, LOW);
} else if (speed < 0) {
digitalWrite(IN1, LOW);
analogWrite(IN2, -speed);
} else {
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
}
}
void loop() {
setMotorSlowDecay(150);
delay(2000);
setMotorSlowDecay(0);
delay(1000);
setMotorSlowDecay(-150);
delay(2000);
setMotorSlowDecay(0);
delay(1000);
}Many dedicated MOSFET drivers expose the mode directly. Some have a pin or a register bit that selects fast, slow, or mixed decay. Others have a PH/EN interface: one pin for phase (direction) and one for enable (PWM), with the chip choosing slow decay internally. Check the datasheet for the mode your PWM input produces.
Choosing a mode
Use these rules as a starting point.
- Smooth speed control at low speed: prefer slow decay. The motor current is smoother and speed tracks duty cycle more closely.
- Rapid slowing while PWM is running: fast decay makes the current fall quickly, which suits a controller that must reverse or reduce speed rapidly.
- Simple modules with the PWM-on-enable wiring: accept fast decay and test the low-speed range. Raise the minimum duty cycle so the motor does not stall.
- Stopping on command: use brake when you need a quick stop, and coast when you need a gentle one or a freely turning shaft.
- Battery supply: be careful with fast decay and regenerative braking. Current pushed back into a battery pack through a protection circuit or a series diode can raise the rail voltage above the driver's limit.
Some drivers offer mixed decay, which uses fast decay for part of the off phase and slow decay for the rest. It is common in stepper drivers. For brushed motors it is less common, and you will not usually need it.
Common mistakes
- Assuming both-LOW means coast. On some chips it brakes. Test by spinning the shaft by hand with the inputs in that state. A braked shaft resists turning noticeably.
- Using brake to hold a load. Brake only works while the shaft moves.
- Braking from full speed on a weak supply. Peak braking current can approach stall current. Make sure the driver's current rating and the supply can handle it, or ramp down first.
- Ignoring supply rise with fast decay. Add bulk capacitance near the driver and use a supply that can sink current or a clamp.
- Expecting a brake to work at very low speed. Braking torque falls with back-EMF, so the last bit of motion decays slowly.
Exercise
A motor driven with PWM on the enable pin of an L298N module runs smoothly at 60 percent duty but stalls below 25 percent. You move the PWM to one direction input, hold enable high, and keep the other input LOW. The motor now starts at 15 percent duty. Which decay mode did each wiring use, and why did the change help?
Show answer
PWM on the enable pin used fast decay: during each off phase all outputs turn off, the bridge coasts, and winding current falls quickly through the body diodes, so average current and torque are low at small duty. PWM on a direction input with the other input LOW used slow decay: during each off phase both inputs are LOW with enable high, which shorts the motor and lets current recirculate through the switches and winding. Current falls more slowly, so average current is higher and smoother at a given duty, and the motor develops enough torque to start at a lower setting. Confirm the both-LOW behavior in your driver's truth table.
Exercise
A small cart on a slope must stop quickly and then stay in place. Which stopped state do you use for each requirement, and what extra measure does holding position need?
Show answer
Use brake for the quick stop, because shorting the terminals makes the back-EMF drive a current that opposes rotation. Brake cannot hold position, because braking torque is zero when the shaft is not moving. To hold on a slope, use a gearbox that resists back-driving, a mechanical brake, or a feedback loop that applies drive torque to stay in place.