Lab 06: Belt-Driven Linear Stage with a Resonance
Overview
A servo motor moves a carriage through a timing belt. At low frequency the stage behaves like a rigid mass, but the elastic belt adds a lightly damped resonance in the tens of hertz, and that resonance, together with the drive delay, is what limits the bandwidth of the position loop. We measure the frequency response, fit a model, design a lead compensator on the low-order model, and judge the design by its gain margin and sensitivity peak on the measured response, including what goes wrong when the crossover is pushed toward the resonance.

The belt-driven stage of lab 06 and its position loop.
The system
| quantity | demo stage S1 | homework stage S2 | basis |
|---|---|---|---|
| motor and pulley inertia $J_m$ | $2.0 \times 10^{-5}$ kg m² | identify (through $J$) | representative values |
| pulley radius $r$ | 12 mm | 15 mm (given) | |
| carriage mass $m_L$ | 1.2 kg | 2.5 kg (given) | |
| belt axial stiffness $k$ | 17.7 kN/m | identify (through $f_r$) | GT-type belt, 1-2 m span |
| belt mode $f_r$, $\zeta$ | 60.0 Hz, 0.040 | identify from the logs | |
| guide friction $b_L$ | 8 N s/m | identify (through $a$) | |
| torque constant $K_t$ | 0.12 N m/A | 0.20 N m/A (given) | |
| drive | 4 kHz sampling, 2 samples (0.5 ms) of delay plus the zero-order hold, ±3 A current limit, 1 kHz current loop | same | |
| sensing and noise | 1 µm linear encoder (0.3 µm noise), 0.01 A rms force ripple and friction noise | same |
The current command $i$ passes through the current loop, the motor torque $K_t i$ accelerates the motor inertia, the belt acts as a torsional spring $k r^2$ with light damping, and the linear encoder measures the carriage position $x$ on the far side of the belt (non-collocated sensing). At low frequency the stage is a rigid body,
$$ \begin{aligned}\frac{X(s)}{I(s)} &= \frac{K}{s\,(s + a)},\\K &= \frac{K_t r}{J},\quad J = J_m + m_L r^2,\quad a = \frac{b_L r^2}{J},\end{aligned} $$which gives $K = 7469$ mm/(A s²) and $a = 5.98$ rad/s for stage S1. The two-mass mode of the belt sits at
$$ \omega_r = \sqrt{k r^2 \left(\frac{1}{J_m} + \frac{1}{m_L r^2}\right)} , $$
and above it the magnitude falls at -80 dB/dec while the phase drops by another 180°. The drive adds the delay $T_d = 2.5\,T_s = 0.625$ ms (two samples of computation and bus delay plus half a sample for the zero-order hold). sim.simulate_loop applies each command one sample after it is computed, so the scripts pass it delay=(N_DELAY - 1) * TS for the two samples, and the measured response already contains the whole delay. The logs are simulated with ctrlprac.sim.simulate_loop from this two-mass model and are not measurements from a real machine; each data file is marked as simulated.
| step | course tool | lecture |
|---|---|---|
| closed-loop excitation test, ETFE via the excitation, coherence (demo 1) | sinusoidal response, ident.etfe |
L20 |
| stepped-sine check (demo 1) | ident.sine_response over integer periods |
L20 |
| rigid-body -40 dB/dec line, resonance peak, $\zeta = 1/(2Q)$ (demo 1) | Bode plot reading, resonance | L21 |
| transfer-function fit with the known integrator built in (demo 2) | ident.fit_tf |
L21, L22 |
| low-frequency design model $K/(s(s+a))$ (demo 2) | dominant poles, model approximation | L22 |
| lead for a crossover and phase margin, delay included (demo 3) | lead design on the Bode plot | L18, L21, L26 |
| margins on the measured response, Nyquist plot with the resonance loop, $M_s$ (demo 3) | Nyquist criterion, gain and phase margins, sensitivity | L24, L26 |
| crossover pushed toward the resonance, step responses (demo 3) | sim.simulate_loop, sim.LTIController |
L26 |
Demo 1: measuring a frequency response and reading the Bode plot
Before designing anything we measure the frequency response from current to carriage position. A double integrator drifts away under open-loop excitation, so the drive holds the carriage with a slow parking PD loop (crossover near 3.7 Hz) and adds the excitation current $i_{exc}$, a ±0.4 A PRBS with 1 ms bits, to the controller output. The 8 s log contains the excitation, the total current command and the encoder position, sampled at 4 kHz.

The PRBS identification test inside the parking loop (simulated log).
ident.etfe(t, u, y) returns the Welch estimate $\hat H(j\omega) = S_{uy}/S_{uu}$ and the coherence $\gamma^2 = |S_{uy}|^2/(S_{uu}S_{yy})$. In a closed loop the current command also contains the controller’s reaction to sensor noise, so the plant is estimated through the excitation, which is independent of that noise:
A coherence near 1 means the output is explained linearly by the input, and the estimate is trusted only there; with 2 s windows (0.49 Hz resolution) the coherence is above 0.9 at every bin from 2.0 to 142.6 Hz, and above 143 Hz at only 24 of the 57 bins up to 170.4 Hz (lowest 0.66 near 165 Hz), so the trusted points thin out there. A stepped-sine test checks the result one frequency at a time: the amplitude is faded in, the transient is allowed to die out (longer near the resonance, whose ringing lasts about $1/(\zeta\omega_r)$), and ident.sine_response projects an integer number of periods onto sine and cosine.

Measured frequency response from current to carriage position: ETFE via the excitation, the direct estimate, the stepped-sine points and the coherence.
Below the resonance the magnitude follows $|G| \approx K/\omega^2$. Fitting $K$ on 4-12 Hz, above the friction corner near 1 Hz and below the quasi-static rise of the resonance (already +4 % at 12 Hz), gives $K = 7569$ mm/(A s²), 1.3 % above the true value, and the total inertia $J = K_t r/K = 1.9 \times 10^{-4}$ kg m². A second-order mode multiplies the rigid-body line by $\omega_r^2/(s^2 + 2\zeta\omega_r s + \omega_r^2)$, whose peak at $\omega_r$ has the height $Q = 1/(2\zeta)$. The measured peak lies 21.9 dB above the rigid-body line at 60.1 Hz, so $Q = 12.4$ and $\zeta = 0.040$, both matching the true values. The stepped sines, on a 2 Hz grid near the peak, miss the top slightly and give $Q = 12.1$.
Demo 2: fitting a transfer function and a low-order design model
A transfer function is a compact summary of the measured response that we can design with. The first attempt with ident.fit_tf uses four poles and no zeros ($n_a = 4$, $n_b = 0$) for the rigid body and one resonance; it fits the band closely, but the pole near $s = 0$ is pinned only by data well above it, and the fit places it at $s = +2.4$, which is not physical for this stage. Position is the integral of velocity, so the integrator is known physics. Fitting the velocity response $j\omega\,G(j\omega)$ with $n_a = 3$ after removing the known delay gives
with $a = 6.22$ rad/s, $f_r = 60.07$ Hz, $\zeta = 0.0408$ and $K = b_0/\omega_r^2 = 7459$ mm/(A s²), within 0.1 % of the true gain. The fit errors are small and random below 90 Hz (0.26 dB and 0.9° rms on 2-30 Hz). Above 90 Hz a slow phase drift appears because the 1 kHz current loop is not in the model; both effects lie far above any feasible crossover.
Well below $\omega_r$ the resonance factor is close to 1, so the dominant dynamics are the rigid body $G_{lf}(s) = K/(s(s + a))$. The approximation error is $|1/(1 - (\omega/\omega_r)^2)|$, which stays below 1 dB up to 20.0 Hz, or $0.33 f_r$.
The interactive version recomputes the ETFE from the log for a chosen Welch segment length and coherence threshold, repeats the Bode reading of demo 1, and fits the model on the trusted band, with or without the integrator built in. Shorter segments give more averages but a coarser frequency grid that misses the top of the resonance; with two long segments the coherence is close to 1 everywhere and no longer tells which points to trust.
Interactive: ETFE settings, Bode reading and the model fit
The button loads Python (Pyodide with numpy, scipy, matplotlib and python-control, about 40 MB on the first visit, cached afterwards) into this page; after that, changing a parameter re-runs the computation and redraws the figures. Until then the figures and numbers below are the output of the original demo script with the default parameters.
coherence > 0.9 at every bin from 2.0 to 142.6 Hz, and at 24 of the 57 bins up to 170.4 Hz
5 Hz: ETFE 7.8109 mm/A, -172 deg, coherence 0.996
20 Hz: ETFE 0.5316 mm/A, 177 deg, coherence 1.000
60 Hz: ETFE 0.6614 mm/A, 80 deg, coherence 0.968
100 Hz: ETFE 0.0110 mm/A, -15 deg, coherence 0.996
rigid-body slope -38.7 dB/dec (ideal -40); K = 7569 mm/(A s^2) (true 7469, +1.3 %)
total inertia J = Kt r/K = 0.00019 kg m^2 (true 0.000193)
resonance f_r = 60.1 Hz (true 60.0), peak 21.9 dB above the rigid-body line: Q = 12.4, zeta = 0.040 (true 0.040)
fitting 296 ETFE points, 2-148 Hz, known delay 0.625 ms removed
fit (nb=0, na=4) poles: [-15.7+374.1j -15.7-374.1j -8.9 +0.j 2.4 +0.j ]
structured fit: a = 6.22 rad/s (true 5.98), f_r = 60.07 Hz (true 60.01), zeta = 0.0408 (true 0.040),
K = 7459 mm/(A s^2) (true 7469, -0.1 %)
2- 30 Hz: rms error 0.26 dB, 0.9 deg
30- 90 Hz: rms error 0.12 dB, 1.4 deg
90-150 Hz: rms error 0.37 dB, 3.5 deg
G_lf(s) = 7459 / (s (s + 6.22)) [x in mm, i in A]

Python output
(appears after the first live run)
Show code
Loading the source...The dominant-pole approximation is shown as computed by the lab script.

The full fitted model and the rigid-body design model $K/(s(s+a))$, 1 dB apart at 20 Hz.
Demo 3: lead design on the Bode plot, checked on the measured response
The lead compensator is designed on the rigid-body model for a target crossover $f_c$ and phase margin. At $\omega_c$ the rigid body with the delay has the phase $-90^\circ - \arctan(\omega_c/a) - \omega_c T_d$, and the lead supplies the rest:
$$ \begin{aligned}\phi_{max} &= PM - 180^\circ - \angle G_{lf}(j\omega_c)e^{-j\omega_c T_d},\\\alpha &= \frac{1 - \sin\phi_{max}}{1 + \sin\phi_{max}},\\z &= \omega_c\sqrt{\alpha},\quad p = \frac{\omega_c}{\sqrt{\alpha}},\end{aligned} $$with $C(s) = K\,(s/z + 1)/(s/p + 1)$ and $K$ chosen so that $|C(j\omega_c)G_{lf}(j\omega_c)| = 1$. For $f_c = 10$ Hz, one sixth of the resonance frequency, and PM = 50°, the lead needs $\phi_{max} = 46.6^\circ$, which puts the zero at 4.0 Hz and the pole at 25.1 Hz, with $K = 0.2117$ A/mm.
The design model ignores the resonance, so the decisive check uses the measured response directly: $L_{meas}(j\omega) = C(j\omega)\hat G(j\omega)$, which already contains the drive delay. On the measured loop the crossover is 10.4 Hz with PM = 47.9°, but the resonance lifts $|L|$ back toward 0 dB and the phase crosses -180° at 50.4 Hz, where the gain margin is only 10.6 dB. The open loop has no right-half-plane poles, so the Nyquist plot must not encircle $-1$; the resonance draws an extra loop whose size is the resonance peak times the loop gain there, and the closest approach to $-1$ is $1/M_s$ with the sensitivity peak
$$ M_s = \max_\omega \left|\frac{1}{1 + L(j\omega)}\right| = 1.75 \quad (4.9\ \text{dB at } 56.2\ \text{Hz}). $$On the simulated stage the 1 mm step of this design peaks at 1.31 A, the first output of the lead, and stays well inside the ±3 A current limit. Repeating the design for 15 Hz and 20 Hz shows the limit. At 15 Hz the measured loop still has PM = 47° at its first crossover (16.1 Hz), but the measured gain margin drops to 1.7 dB and $M_s$ rises to 11, so the loop rings at the belt mode. At 20 Hz the resonance loop encircles $-1$ (GM = -3.9 dB) and the simulated stage oscillates at the resonance until the current limit holds the amplitude. The phase margin at the first crossover would have approved all three designs; the measured gain margin at the resonance and $M_s$ do not. A faster loop needs a notch filter at the resonance, a stiffer belt, or collocated motor-side feedback for the high-frequency part.
In the interactive version you choose the target crossover and phase margin. The module designs the lead on the rigid-body model, evaluates the loop on the measured ETFE (2-150 Hz, coherence above 0.9) and on the fitted model, reports the margins and $M_s$, checks closed-loop stability on the true two-mass plant with a Padé(3) delay, and simulates a 1 mm step of the sampled loop with the current limit, encoder quantization and noise, and drive delay. Like demo 3, the step leaves out the 0.01 A force ripple of the logs; _make_data.py shows how to add it as the input disturbance d. $M_s$ is only meaningful while the closed loop is stable.
Interactive: lead design judged on the measured response
The button loads Python (Pyodide with numpy, scipy, matplotlib and python-control, about 40 MB on the first visit, cached afterwards) into this page; after that, changing a parameter re-runs the computation and redraws the figures. Until then the figures and numbers below are the output of the original demo script with the default parameters.
design model G_lf = 7459/(s(s + 6.22)); resonance at 60.1 Hz, zeta 0.041; drive delay 0.625 ms
lead: phi_max = 46.6 deg, zero 4.0 Hz, pole 25.1 Hz, K = 0.2117 A/mm
C(s) = 0.2117 (s/25.0 + 1)/(s/157.9 + 1)
rigid-body model crossover [10.] Hz, PM [50.] deg | GM 27.1 dB at 73.5 Hz, 80.2 dB at 1603.5 Hz | Ms = 1.41 (3.0 dB) at 15.9 Hz
full fitted model crossover [10.2] Hz, PM [49.] deg | GM 10.9 dB at 49.8 Hz, 113.4 dB at 808.5 Hz | Ms = 1.74 (4.8 dB) at 56.4 Hz
MEASURED response crossover [10.4] Hz, PM [47.9] deg | GM 10.6 dB at 50.4 Hz | Ms = 1.75 (4.9 dB) at 56.2 Hz
fc = 10 Hz (measured) crossover [10.4] Hz, PM [47.9] deg | GM 10.6 dB at 50.4 Hz | Ms = 1.75 (4.9 dB) at 56.2 Hz
closed-loop (true plant, Pade delay): max Re(pole) = -14.4 rad/s
fc = 15 Hz (measured) crossover [16.1 55.8 62.9] Hz, PM [ 47.2 -10.5 -121.4] deg | GM 1.7 dB at 53.9 Hz | Ms = 11.19 (21.0 dB) at 55.2 Hz
closed-loop (true plant, Pade delay): max Re(pole) = -4.3 rad/s
fc = 20 Hz (measured) crossover [22.4 50.4 65.5] Hz, PM [ 47.1 18.8 -132.4] deg | GM -3.9 dB at 55.5 Hz | Ms = 3.42 (10.7 dB) at 51.8 Hz
closed-loop (true plant, Pade delay): max Re(pole) = +17.3 rad/s


Python output
(appears after the first live run)
Show code
Loading the source...Homework: how fast can stage S2 be? (100 points)
Stage S2 is a longer belt axis with a heavier carriage (2.5 kg) than the demo stage. The homework starts from two simulated logs recorded at 4 kHz inside a slow parking loop, a logarithmic chirp from 1 to 400 Hz and a stepped-sine test, and asks for the highest crossover that keeps a 6 dB gain margin and $M_s \le 2$ on the measured response. The full problem statements are in homework.md, and the starter script hw_starter.py is in the lab folder of the lab materials on GitHub; the logs are in its data/ folder. Clone the repository, or download it as a zip file.
- Frequency response from the chirp (10 points; L20)
- Stepped sine (10 points; L20)
- Read the Bode plot (15 points; L21)
- Fit a transfer function (15 points; L21, L22)
- Dominant-pole model (10 points; L22)
- Lead design, checked on the measured response (20 points; L21, L24, L26)
- Push the crossover (10 points; L26)
- Engineering judgement (10 points)