Ground Embedded KO Subscribe

Notes / Motor Control

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.

GROUND EMBEDDED · NOTEMotor Control 10Current, speed and position loopsNSABC

Cascade structure

Position loopslowSpeed loopCurrent loopfastestInverterMotor
Three nested loops. The output of an outer loop is the target of the inner one. The further in, the faster.
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

  1. 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
  2. Speed loop: initial values from the inertia J and Kt, then adjust under load
  3. Position loop: a single P (+ speed feedforward) is usually enough
3D labRun what you have read so far→

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
3D LABPID ControlRun what this note explains and watch it respond.Open the lab →FREE PDFGet the 3 free ebooksIf you want to keep reading this topic as one book: BLDC motor control, serial communication and sensors at book length. PDFs are in Korean.Get them free →