Fundamentals / Mechanical engineering / Control engineering / System dynamics, feedback and estimation

Designing current, speed and position loops for a drive

An encoder measures shaft motion, while the power stage acts on voltage. Decide which disturbances each measurement can reject and how fast each loop can move before the unseen inner dynamics erode the position margin.

Place a fast loop where the disturbance enters

Use the small-signal motor equations \(L\dot i+Ri=v-k_e\omega\), \(J\dot\omega+B\omega=k_t i-\tau_L\), and \(\dot\theta=\omega\). Measure current at the converter and motion at the shaft. A speed loop alone leaves rapid electrical disturbances to propagate before they appear in shaft motion. Close a fast local current loop and send it a current reference from the mechanical loop. Treat back EMF as a disturbance or add measured-speed feedforward.

Choose \(C_i(s)=k_{pi}+k_{ii}/s\) with \(k_{ii}/k_{pi}=R/L\). For the nominal \(1/(Ls+R)\) current plant the open loop reduces to \(k_{pi}/(Ls)\) and the closed transfer is \(\omega_i/(s+\omega_i)\), with \(k_{pi}=L\omega_i\) and \(k_{ii}=R\omega_i\). At \(L=0.010\) H, \(R=1\) ohm and \(\omega_i=1000\) rad/s the gains are 10 V/A and 1000 V/(A s). The approximation presupposes adequate measurement, switching and computation bandwidth.

Choose the middle loop against an inner-loop error budget

If current follows its command over the speed-loop band, the torque-to-speed plant is \(k_t/(Js+B)\). A speed PI controller with \(k_{p\omega}=J\omega_v/k_t\) and \(k_{i\omega}=B\omega_v/k_t\) gives an approximate closed speed response \(\omega_v/(s+\omega_v)\). With \(J=0.020\), \(B=0.020\), \(k_t=0.40\) in SI and \(\omega_v=100\) rad/s, the gains are 5 in the corresponding current-per-speed and integral units. The neglected current lag contributes \(\arctan(100/1000)=5.71°\) at that speed-loop crossover. Reserve this phase when validating the full model. A torque disturbance enters the mechanical balance directly and is primarily rejected by this middle loop.

Convert a position requirement into a realizable crossover

Use position proportional feedback \(\omega_{ref}=K(\theta_{ref}-\theta)\), the achieved speed model \(\omega_v/(s+\omega_v)\) and total outer-path delay \(\tau\). In this reduced model the exact position-loop frequency response is \(L(s)=K e^{-s\tau}/[s(1+s/\omega_v)]\). Choosing \(K\) for a desired amplitude crossover separates magnitude tuning from the residual phase budget:

\[K=\omega_c\sqrt{1+(\omega_c/\omega_v)^2},\]
\[\phi_m=\pi/2-\arctan(\omega_c/\omega_v)-\omega_c\tau.\]

At \(\tau=6\) ms, \(\omega_v=100\) rad/s and required margin 45°, solving the monotone equation gives \(\omega_c\leq51.56\) rad/s. The 50 rad/s design has only 46.25° before any additional sensor or drive lag. At 20 rad/s the nominal margin is 71.81°. The notebook separately evaluates the delay-free closed-loop poles with OneSimulation. Their decay rate and the delayed loop’s phase margin measure different properties.

Interactive experiment · Spend the phase budget with bandwidth and delay sliders

Choose the achieved inner-loop bandwidth, the outer-path delay and the intended outer crossover. The browser adjusts the proportional gain to place the amplitude crossover exactly at that frequency, then evaluates the remaining phase margin. The 45° line is a design target; it is not the boundary of stability itself.

Begin at an inner bandwidth of 100 rad/s, delay 6 ms and crossover 50 rad/s. Double the delay and observe the lost 17.19°. Then lower the requested crossover until the target is recovered. The zero-delay pole margin in the readout is computed from the quadratic closed-loop characteristic polynomial. Compare it with the OneSimulation stability diagnostic in the notebook; it does not certify the delayed system.

Continue in the OneSimulation notebook · Download its Python model

OneSimulation experiment · An achieved inner speed bandwidth and transport delay bound the outer-loop crossover

Run the notebook with OneSimulation 0.2.0, NumPy, SciPy and Matplotlib. Change the input data and compare your run with the recorded result.

"""Evaluate inner-lag and transport-delay limits on an outer position loop."""
import numpy as np
import matplotlib.pyplot as plt
from onesim.physics.systems.control import stability_margin

inner_pole = 100.0  # rad/s, achieved bandwidth of the closed speed loop
def outer_gain(crossover):
    return crossover*np.sqrt(1+(crossover/inner_pole)**2)
def phase_margin(crossover, delay):
    return 90-np.rad2deg(np.arctan(crossover/inner_pole)+crossover*delay)

frequencies = np.linspace(1,90,250)
fig, ax = plt.subplots(figsize=(6.4,3.7), layout="constrained")
for delay in [0.0,0.006,0.012]:
    ax.plot(frequencies, phase_margin(frequencies,delay),label=f"{1000*delay:.0f} ms delay")
for crossover in [20.0, 50.0]:
    gain = outer_gain(crossover)
    poles = np.roots([1.0,inner_pole,inner_pole*gain])
    print(f"crossover {crossover:.0f} rad/s: delay-free pole margin = "
          f"{stability_margin(poles,discrete=False):.3f} /s, "
          f"6 ms phase margin = {phase_margin(crossover,0.006):.2f} deg")
ax.axhline(45,color="0.4",ls=":",label="45° requirement")
ax.set(xlabel="Outer gain crossover (rad/s)",ylabel="Phase margin (degrees)")
ax.legend()
plt.show()

Reference run

crossover 20 rad/s: delay-free pole margin = 28.543 /s, 6 ms phase margin = 71.81 deg
crossover 50 rad/s: delay-free pole margin = 50.000 /s, 6 ms phase margin = 46.25 deg
An achieved inner speed bandwidth and transport delay bound the outer-loop crossover
An achieved inner speed bandwidth and transport delay bound the outer-loop crossover

Download editable notebook · Download Python script

Inspect failure signatures from the inside out

Measure the current-reference response with the mechanical loop open in the model. Then close speed feedback and compare measured torque-step recovery with the linear prediction. Finally apply a position command and log reference and achieved current, shaft speed and position together. Under voltage clipping the actual current cannot track its command at speed. A speed integrator that keeps charging can dominate the later position excursion. Use actuator feedback for anti-windup and check the actual limits at the operating speed.

Which loop receives the position sample delay?

A rotor-position timestamp used to derive speed can delay both mechanical loops. A transport delay introduced only between the supervisory controller and the drive delays the outer loop. Draw the measurement paths before inserting a single lumped delay or counting it twice.

Exercises on a changed architecture

Keep crossover at 50 rad/s while total delay rises from 6 to 12 ms. What does this do to the reduced-model margin?

Worked solution

The gain is unchanged by pure delay. The added lag is \(50(0.006)=0.30\) rad, or 17.19°. Margin falls from 46.25° to 29.06°, below the target.

At high speed the current sensor follows its local model but digital speed estimates have 4 ms of additional filtering delay. Where should the new uncertainty enter?

Worked solution

Place it in the speed measurement path. Recompute the middle-loop closed dynamics before using them as the position plant. Adding it only to the outer-loop delay would miss loss of speed-loop robustness.

Further reading · Åström and Murray, Feedback Systems, 2nd ed., Chapters 10–11 and 15.