Current, speed and position loops: fastest on the inside
Motor control is a cascade with the current loop innermost and the speed and position loops outside. Bandwidth allocation and tuning order.
Cascade structure
position target → [position P] → speed target → [speed PI] → iq target → [current PI ×2] → voltage → motor
↑ encoder position ↑ calculated speed ↑ phase currents
Bandwidth allocation
| Loop | Period | Bandwidth (example) |
|---|---|---|
| Current | 10 to 20 kHz (PWM-synchronised, ISR) | ~1 kHz |
| Speed | 1 to 2 kHz | ~100 Hz |
| Position | 0.5 to 1 kHz | ~10 to 20 Hz |
An outer loop has to be 5 to 10 times slower than the loop inside it, so that it can be designed as if the inner loop has already reached its target.
Tuning order
- Current loop: calculate the PI gains from the motor's R and L (pole-zero cancellation: Kp = L·ωc, Ki = R·ωc) and check the iq step response
- Speed loop: initial values from the inertia J and Kt, then adjust under load
- Position loop: a single P (+ speed feedforward) is usually enough
Feedforward
If you know the target speed or acceleration, add the corresponding output in advance. Feedback then handles only the remaining error, which greatly reduces the tracking error.
Practical points
- Put a limit on each loop's output (maximum current, maximum speed). Handle them together so the inner limit does not wind up the outer loop's integrator
- Noise in the speed calculation limits the speed-loop gain. Encoder resolution and the speed filter decide the performance
- This is where control engineering, firmware and power electronics meet inside one piece of code