D13 · Lesson 10 · Motor controller
Controlling a motor with two nested loops, a fast current loop whose PI gains cancel the winding's pole, a slower speed loop that commands current, limits on current and voltage, integrator windup and conditional integration, and a simulated drive that meets its specifications
Industrial drives almost all use the same structure: an inner loop that controls the motor's current, and therefore its torque, and an outer loop that controls speed by asking for current. The inner loop is fast and protects the hardware, since limiting the current demand limits the torque and the heat; the outer loop is slower and sees a simple plant, an inertia driven by a torque it can command. Limits make the loops nonlinear, and a PI controller that ignores its limits winds up its integral and overshoots badly. This lab builds the whole drive and makes it meet a specification.
- The speed loop's response to a step in demand, assuming the current loop is perfect and nothing saturates, for a speed-loop bandwidth and a PI zero placed at .
- Pushing the zero closer to the bandwidth (smaller r) gives stronger integral action, which rejects load torque faster, but at the cost of overshoot.
- The readout shows the current this linear design would ask for at the start of a 250 rad/s step. It's far above the motor's 8 A limit, so in practice the drive saturates, which the linear picture can't show and the lab can.
Predict
The drive's current is limited to 8 A, the motor's K is 0.05 N·m/A and its inertia 2 × 10⁻⁵ kg·m². At best, how long does it take to reach 250 rad/s from rest?
8 A gives 0.4 N·m of torque, which accelerates the rotor at 0.4/(2 × 10⁻⁵) = 20,000 rad/s². Reaching 250 rad/s takes 250/20,000 = 12.5 ms however high the loop gains are. For most of a large step the drive simply runs at its current limit, and the controller's job is to come out of the limit smoothly.
Name it
The current loop
Seen from the voltage, the winding is , with the back-EMF as a slowly changing disturbance. A PI controller with
has its zero at , exactly on the winding's pole, so the closed current loop is a first-order lag of bandwidth , here 2π × 1 kHz, a time constant of 0.16 ms.
The speed loop
With the current loop much faster, the speed plant is : a commanded current makes torque Ki. A PI with crosses over near , and puts its zero r times lower. The bandwidths are separated by a factor of 20 (50 Hz against 1 kHz), so each loop sees the other as nearly ideal.
Limits and windup
The speed controller's output is clamped to ±8 A and the current controller's to the 24 V supply. While a controller is clamped, its integral keeps growing if nothing stops it: windup. When the speed finally arrives, the oversized integral holds the current high and the speed overshoots. Conditional integration stops the integral whenever the output is clamped, so the controller leaves the limit with a sensible integral. The lab compares the two: about 3% overshoot with it, over 30% without.
Worked example
What PI gains does the lab use?
Show the solution
- Current loop, proportional gain. :
- Current loop, integral gain. :
- Speed loop, proportional gain. , with :
- Speed loop, integral gain.
Answer the current loop uses = 6.28 V/A and = 6283 V/(A·s); the speed loop uses = 0.126 A per rad/s and = 7.90 A/rad.
Worked example
A 0.1 N·m load lands while the motor holds 250 rad/s. What current must the drive add, and what did the lab's drive do?
Show the solution
- Extra current. more.
- What the lab's drive did. The speed dips to about 237.7 rad/s while the speed loop's integral builds up that 2 A, and it's back within 1% about 30 ms after the step.
- Without the integral. A proportional loop would settle with an error of
Answer 2 A more; the lab's drive dipped to about 237.7 rad/s and was back within 1% about 30 ms later.
Check
Build the drive: two PI loops with limits and anti-windup, meeting the specification.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
A current loop for a 1 mH winding should have a 500 Hz bandwidth. What proportional gain cancels the winding's pole?
Write units the way you normally would: 1.5 V/A, 1500 mV/A and 0.0015 kV/A are the same answer.
Check
A drive limited to 8 A spins a rotor of 10 × 10⁻⁵ kg·m² with K = 0.02 N·m/A. Ignoring friction and load, what's the shortest time to reach 250 rad/s from rest?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
A proportional-only speed loop with gain 0.5 A per rad/s carries a load of 0.1 N·m on a motor with K = 0.02. What steady speed error does it leave?
Write units the way you normally would: 1.5 rad/s and 1500 mrad/s are the same answer.
Check
A current loop around a motor winding ( = 1 mH, = 0.5 Ω) uses a PI controller whose zero cancels the winding's pole, for a 2000 Hz crossover.
(a)
What proportional gain (V/A) does it need?
Write units the way you normally would: 1.5 Ω, 1500 mΩ and 0.0015 kΩ are the same answer.
(b)
What integral gain (V/(A·s)) puts the zero on the pole?
Check
A cascaded drive's current loop crosses over at 1000 Hz. The speed loop is set 5 times slower so the loops don't interact. What is the speed loop's crossover?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Explain why
Why does a PI speed controller overshoot after a large step if its integral isn't stopped while the current is limited?
During a large speed step, the speed controller asks for far more current than the limit allows, so the motor accelerates at the limit for a while and the speed error stays large. If the integral keeps accumulating that large error the whole time, it grows far beyond what the final steady state needs. When the speed reaches its target and the error drops to zero, the output is still dominated by that oversized integral, so the controller keeps demanding full current and the speed overshoots until the error has been negative long enough to unwind it. Stopping the integral while the output is clamped keeps it near the value it should have, so the speed arrives without a large overshoot.
Practice
Keep practicing
7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.