Sub topic 6
Brake, Coast, and Decay Modes
Assume you know basic Arduino functions such as digitalWrite() and analogWrite(), and that you understand the four-switch H-bridge from the previous chapters. This chapter uses a driver with two direction inputs and one enable or PWM input. Exact control states vary by driver, so check its truth table before wiring a motor.
Coast and brake states
The motor is an inductive load. Its winding current cannot stop instantly when a switch opens. The H-bridge must provide a safe path for that current. The path determines whether the motor coasts, brakes, or continues driving.
| Mode | Motor terminals | Motor behavior | Typical control state |
|---|---|---|---|
| Coast | Floating or disconnected | Motor slows from friction and load | Driver disabled |
| Dynamic brake | Shorted together | Motor stops quickly by generating counter-torque | Both outputs driven to the same rail |
| Drive | Opposite voltage applied | Motor produces forward or reverse torque | One high-side and opposite low-side switch on |
In coast mode, the driver disconnects both motor terminals, or lets them become electrically inactive. The spinning motor acts briefly as a generator, but little current can circulate through the winding. The motor therefore slows gradually.
In dynamic braking, both motor terminals are connected to the same voltage, often ground. The voltage across the winding is close to zero, but the winding current still circulates through the switches or their diodes. That current produces torque opposing the rotation. Braking is stronger at higher speed and becomes weaker as the motor stops.
PWM decay modes
Pulse-width modulation, or PWM, controls average motor voltage by switching rapidly between states. During the off portion of each pulse, the motor current needs a recirculation path. This interval is called the decay period.
With slow decay, the bridge connects both motor terminals to the same rail. The winding current circulates with a relatively small voltage across it, so current changes slowly. Torque is smoother, but the motor may respond less sharply to a reduction in speed command.
With fast decay, the bridge allows the winding current to fall more quickly, often by applying a voltage opposite to the current or by opening the outputs and using diode paths. Fast decay gives more responsive current control, but can increase electrical noise and ripple.
The names slow decay and fast decay are used differently across driver families. Some drivers choose decay automatically. Others provide a mode pin, or require specific input and PWM timing. Do not assume that setting the enable pin low selects the same decay mode on every module.
Arduino control states
For a common driver with IN1, IN2, and an enable input, the following example shows drive, coast, and dynamic brake states. This truth table is common, but verify it for your specific driver.
const uint8_t IN1 = 7;
const uint8_t IN2 = 8;
const uint8_t EN = 9; // PWM-capable pin
void setup() {
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(EN, OUTPUT);
}
void driveForward(uint8_t duty) {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
analogWrite(EN, duty);
}
void coast() {
analogWrite(EN, 0); // Outputs are disabled on many drivers.
}
void brake() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
analogWrite(EN, 255); // Hold both outputs in the brake state.
}
void loop() {
driveForward(180);
delay(2000);
coast();
delay(1000);
driveForward(180);
delay(2000);
brake();
delay(1000);
}Some drivers brake when both direction inputs are HIGH instead of LOW. Some require PWM on an input rather than on EN. Use the driver’s datasheet truth table and test with a current-limited supply.
Exercise
Why does dynamic braking stop a motor faster than coasting?
Show answer
Braking connects the motor terminals together, allowing winding current to circulate. That current creates torque opposite to the rotation, while coasting largely disconnects the winding.