How can I implement regenerative braking of a DC motor?
Probably you already have it, and just didn't know it. If you are driving a motor with a half-bridge or H-bridge and PWM or similar, you have regenerative braking. Let's consider a half-bridge, since for this analysis we will run the motor in only one direction:



First, let's consider non-regenerative braking. If the bridge output is high (S1 closed, S2 open), the motor will accelerate to full speed. If the bridge is now switched low, the motor won't just gently coast to a stop. It will slam to a stop, as if someone but a brake on it. Why?

A motor can be modelled as a series inductor and voltage source. The motor torque is proportional to current. The voltage source is called back-EMF, and it's proportional to the speed of the motor. This is why a motor draws more current when it is loaded (or worst, stalled): with the speed decreased, the back-EMF is decreased, and it opposes the supply voltage less, resulting in higher current. Let's redraw our schematic with that model, with values as if our motor is spinning at high speed:



This motor is running at full speed. We have a small current to overcome the friction in the motor, and the back-EMF is the supply voltage, less the voltage drop over R1. Not much current flows because the back-EMF cancels most of the supply voltage, so L1 and R1 see only 100mV. Now what happens when we switch the bridge to the low side?



At first, nothing. L1 prevents an immediate change in current. However, this doesn't last long, and very soon (defined by the time constant of \$L_1 / R_1\$, not more than a couple \$ms\$ typically) the back-emf (V1) has reversed the current, and now it's going in the other direction. It's also pretty huge, since now L1 and R1 don't see the small difference of \$V_{B1}-V_1\$ (it was \$100mV\$), but now they see the full 9.9V from V1 alone:



We now have a large current flowing in the opposite direction. Torque is proportional to current, so now instead of applying a gentle clockwise force, just enough to overcome friction, we are applying a hard counterclockwise force, and the mechanical load is rapidly decelerated. As the speed of the motor decreases, so does V1, and consequently so does the current, and the torque with it, until the load is no longer spinning.

Where did the energy go? The kinetic energy of the mechanical load is energy. It can't just disappear, right?

Right. If you look at the circuit again, we have 9.9A flowing through R1. \$P_{R1} = (9.9A)^2 1\Omega = 98.01W\$. The kinetic energy of the load was converted into heat in the motor's winding resistance (and in a practical circuit, also the H-bridge transistors). Some motors will be destroyed by this high power. Others may not. The current generated by the back-EMF is about as strong as the stall current of the motor, so if your motor can run stalled without overheating, it can brake like this all day.

So how do I store the energy, instead of converting it to heat?

Let's look at what's happening a bit after we have started braking, but before we have stopped:



The motor has slowed significantly (back-emf is 1V), and the current has decreased with it. Now what if we switch the bridge to the high side?



Ah ha! We are charging the battery! Of course, if we stay like this very long (again, defined by time constant \$L_1 / R_1\$) then the current direction will reverse, and we will be uncharging our battery, and accelerating our motor, not braking it.

So don't do that. As long as we remain in this state, the current is decreasing. So, we switch back to the other state, with the bridge low, so the back-emf can build the current back up. Then we switch again, and shoot some of it into the battery. Repeat, fast.

If this sounds like what one ordinarily does for PWM motor control, it's because it is. This is why probably you already have it, and just didn't know it.

Once you understand the principle of operation, you can make some simplifications. When a motor is being driven by PWM, the inductance of the motor (L1) works like a flywheel, averaging the voltage you apply to the motor. It's as if you had a real flywheel, and spun it by striking it with a hammer repeatedly. So in this example our supply voltage is 10V. If our PWM duty cycle is 80%, we are effectively driving the motor with 8V (\$80\% \cdot 10V = 8V\$).



Whenever the back-EMF is greater than this voltage, you get regenerative braking. This will happen whenever the PWM duty cycle decreases faster than external forces (friction, for example) will slow the motor. Any resistance in the circuit reduces the energy you can recover from the mechanical load. In the most extreme case where the PWM duty cycle is decreased to 0% and the motor terminals are shorted together, the current is so high that losses reach 100%. (\$P = I^2 R\$)

You can also open all the transistors on the bridge, and the inductor current will die out through the diodes in the bridge. Then neither the back-EMF nor the battery will have a path to drive a current, and the motor will freewheel. Unless of course, some external force accelerates the motor enough to push the back-EMF higher than the supply voltage. A vehicle rolling down a hill is a good example.

In all other cases, you get regenerative braking.

practical consequence

You must consider what you will do with the mechanical energy from the motor. Batteries can absorb energy, but there's a limit to how much, and how fast, that varies on the type of battery. Some power supplies (linear voltage regulators, for example) can't absorb energy at all.

If you don't provide a place for the energy to go, either a battery, or some other load in the circuit, it will go into the power supply decoupling capacitors. If you have enough energy returned from the motor and not enough capacitance, the power supply rail voltage will increase until something breaks.

You must design your circuit so it can't happen. In an electric car, there are complex battery controllers that will apply the conventional brakes if the batteries can't absorb any more of the car's kinetic energy. You can also switch on a power resistor across the supply rails, or design your motor controller to back off on the braking if it gets to be too much.

related questions


Why should I worry about a motor causing my supply voltage to shoot up when the back-EMF can&#39;t exceed the supply voltage?
How can I measure back-EMF to infer the speed of a DC motor?
supercat's answer to a largely unrelated question


mind blowing related rhetorical question

What happens if we have a motor with no winding resistance, and we have a way to drive it without adding any additional resistance (ideal transistors and wires)? It's more efficient, obviously. But how does the speed of the motor vary with applied voltage and mechanical load? Hint: if you try to change the speed of the motor by increasing or decreasing the mechanical load, what does the back-emf do to the current?