Lab 04: A Phone Pendulum, Measured by You
Overview
A phone hangs on a string, is pulled aside, held still and released, and the free phyphox app records its gyroscope. The free decay of the swing is a lightly damped second-order system. From it we estimate $\zeta$ and $\omega_n$ in two ways, the logarithmic decrement and a second-order fit, compare $\omega_n$ with the value the length predicts, place the poles in the s-plane, check the settling-time formula, and see where the linear model breaks down at large angles and under air drag.

The phone pendulum of lab 04 and the estimation problem.
The system
This is the one lab in the group that runs on a measurement each student makes. The sample file used by the demos and by the default settings below is simulated: it reproduces the format of a phyphox export and the effects of a real recording (gyro bias, noise, quantization, a few degrees of axis misalignment, a twisting string, time-stamp jitter), but it is not a measurement. Your own recording replaces it.
| quantity | simulated sample (demos) | your recording | basis |
|---|---|---|---|
| pendulum length $d$, from the pivot to the phone centre | 0.75 m | measure with a tape, to about 0.5 cm | |
| phone height $h$ and width $w$ | 0.150 m and 0.072 m | measure | |
| release angle | 35° after 3 s held still | 20° to 30°, held still for 3 s | |
| linear damping $\zeta_l$ (pivot and string) | 0.006 | to be estimated | representative |
| quadratic air drag $c_q$ | 0.08 1/rad | to be estimated | representative |
| gyroscope sampling | 100 Hz, 3 min | phone default, at least 50 Hz | phyphox Gyroscope (rotation rate) |
| gyro bias, noise, resolution | about 5 mrad/s, 1.5 mrad/s rms, 1.06 mrad/s | depends on the phone |
The phone swings in the plane of its screen, so the gyroscope axis normal to the screen measures $\dot\theta$ directly. The sample was simulated from
$$ \begin{gathered}\ddot\theta + \frac{g}{L_{eq}}\sin\theta + 2\zeta_l\omega_n\dot\theta + c_q\,|\dot\theta|\,\dot\theta = 0,\\L_{eq} = d + \frac{h^2 + w^2}{12\,d},\end{gathered} $$where $L_{eq}$ is the equivalent length of the phone treated as an $h \times w$ plate (a physical pendulum). Near the bottom, with $\sin\theta \approx \theta$ and the damping lumped into one $\zeta$, this becomes the second-order model of the course,
$$ \begin{gathered}\ddot\theta + 2\zeta\omega_n\dot\theta + \omega_n^2\theta = 0,\\\omega_n = \sqrt{g/L_{eq}} .\end{gathered} $$| step | course tool | lecture |
|---|---|---|
| linearize $\ddot\theta + (g/L)\sin\theta = 0$ at the bottom | modeling, first- and second-order systems | L3, L6 |
| $\zeta$ and $\omega_n$ from the peaks (demo 1) | free and step response against the parameters | L7 |
| $\zeta$ and $\omega_n$ from a fit of the whole decay (demo 1) | second-order response, dominant poles | L6, L8 |
| $\omega_n$ against $\sqrt{g/d}$ and $\sqrt{g/L_{eq}}$ (demo 1) | modeling of a physical pendulum | L3 |
| poles $-\zeta\omega_n \pm j\omega_d$ and $T_s = 4/(\zeta\omega_n)$ (demo 1) | pole locations and the response | L16 |
| period and damping against the amplitude (demo 2) | limits of linearization | L3, L6 |
Recording your own swing
Install phyphox (free, from RWTH Aachen, for iOS and Android) and open the experiment Gyroscope (rotation rate). Put the phone in a case or a zip bag and hang it from a door frame, a rod or a hook with 0.5 to 1.5 m between the pivot and the phone centre; two strings in a V keep it from twisting. Let it swing left and right in the plane of its screen, over a bed or a sofa. Measure $d$, $h$ and $w$. Pull the phone aside by 20° to 30°, start the recording, hold it still for 3 s, let go without pushing, and stop after 3 minutes. Then use Export Data and choose CSV (Comma, decimal point), and from the zip keep only Gyroscope.csv.
The upload fields below accept the Gyroscope.csv file from a phyphox CSV export separated by commas, tabs or semicolons, with a decimal point or a decimal comma; the Excel export and the zip archive itself are not read, and the widget says so. The file is read by Python inside your browser and is not sent to any server. The meta/ folder of the export holds your phone model and the start time, so do not share it.
Demo 1: damping and natural frequency from the free decay
The gyroscope gives the swing rate $\dot\theta$. The phone is held still before the release, so the mean of the gyro over that segment is its bias. Removing the bias and integrating gives the angle; a small residual bias would make the angle drift, and since the equilibrium of a pendulum cannot move, a straight-line drift fitted after the release is removed as well.
The logarithmic decrement uses successive peaks $x_i$ of the swing rate:
$$ \begin{aligned}\delta &= \ln\frac{x_i}{x_{i+1}} = \frac{2\pi\zeta}{\sqrt{1-\zeta^2}},\\\omega_d &= \frac{2\pi}{T_d}, \qquad \omega_n = \frac{\omega_d}{\sqrt{1-\zeta^2}} ,\end{aligned} $$with $\delta$ taken as the slope of $\ln x_i$ against the peak number. The second-order fit treats the release as a step: released from rest at $\theta_0$, the angle is $\theta_0$ minus $\theta_0$ times the unit step response of $\omega_n^2/(s^2 + 2\zeta\omega_n s + \omega_n^2)$, so a step-response fit of the angle returns $\zeta$, $\omega_n$ and $K = -\theta_0$. On the sample, 30 peaks give $\zeta = 0.0114$ and $\omega_n = 3.596$ rad/s, and a 40 s fit gives $\zeta = 0.0178$ and $\omega_n = 3.581$ rad/s, both within 1 % of $\sqrt{g/L_{eq}} = 3.609$ rad/s. A 1 cm error in $d$ changes $\omega_n$ by about 0.7 %.
The poles are $s = -\zeta\omega_n \pm j\omega_n\sqrt{1-\zeta^2}$, very close to the imaginary axis, and the 2 % settling time is about $T_s \approx 4/(\zeta\omega_n)$. The measured settling time is the time after which the cycle amplitude stays below 2 % of the release angle. On the sample the two estimates predict 97 s and 63 s, while the swing takes 116 s: the damping is mostly air drag, which weakens as the amplitude falls, so one $\zeta$ taken from the early cycles does not describe the whole decay (demo 2).
The interactive version runs the same steps on the sample or on your own file. You choose where the peaks and the fit window start after the release, how many peaks the decrement uses, and how long the fit window is; a window that starts later starts at the next turning point of the swing, so the fit again begins from rest. At high sampling rates noise and quantization can flatten a crest or split it into neighbouring samples of nearly equal height; log_decrement keeps the peaks at least half a period apart and takes the centre of a flat crest, so each crest counts once. The optional 0.1 s moving average scales all peaks by the same factor and leaves the decrement unchanged. Enter your own $d$, $h$ and $w$ for the comparison with the length.
Interactive: log decrement, second-order fit, poles and settling time
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.
04_pendulum_sample: source = simulated measured setup: pivot to phone centre d = 0.750 m, phone 0.150 x 0.072 m release at t = 3.00 s, gyro bias -0.0025 rad/s, release angle 34.9 deg log decrement (first 30 peaks): zeta = 0.0114, omega_n = 3.5963 rad/s, T_d = 1.7472 s second-order fit (40 s): zeta = 0.0178, omega_n = 3.5807 rad/s, K = -0.607 rad (theta0 = 34.8 deg), rmse = 0.0293 rad omega_n: simple pendulum 3.6166, physical pendulum 3.6092 rad/s (L_eq = 0.7531 m) log decrement 3.5963 rad/s: -0.36 % vs physical; implied length g/wn^2 = 0.759 m 2nd-order fit 3.5807 rad/s: -0.79 % vs physical; implied length g/wn^2 = 0.765 m a 1 cm error in d changes omega_n by 0.67 % log decrement poles -0.0411 +/- 3.5961j 1/s -> Ts = 4/(zeta wn) = 97 s 2nd-order fit poles -0.0637 +/- 3.5802j 1/s -> Ts = 4/(zeta wn) = 63 s measured 2 % settling time: 116 s



Python output
(appears after the first live run)
Show code
Loading the source...Demo 2: where the linear second-order model stops
The model $\ddot\theta + 2\zeta\omega_n\dot\theta + \omega_n^2\theta = 0$ assumes $\sin\theta \approx \theta$ and a damping force proportional to the speed. A real swing violates both assumptions. At large amplitude $\theta_a$ the period grows,
$$ T \approx T_0\left(1 + \frac{\theta_a^2}{16} + \frac{11\,\theta_a^4}{3072}\right), $$and air drag grows with the square of the speed, so the damping ratio depends on the amplitude. The same free decay, analysed cycle by cycle, shows both effects. The period data are fitted with $T = T_0(1 + c\,\theta_a^2)$, which is linear in $T_0$ and $T_0 c$; theory gives $c = 1/16$, and the intercept $T_0$ is the small-angle period, which gives the length $L = g(T_0/2\pi)^2$. Per cycle, $\zeta_k \approx \ln(A_k/A_{k+n})/(2\pi n)$ with $n = 5$ cycles to reduce the noise. For damping $2\zeta_l\omega_n\dot\theta + c_q|\dot\theta|\dot\theta$, an energy balance over one cycle gives the equivalent
$$ \zeta(A) = \zeta_l + \frac{4}{3\pi}\,c_q A , $$a straight line in the amplitude, and integrating $\dot A = -\zeta(A)\,\omega_n A$ from the release angle predicts the envelope. The predicted settling time is the time the envelope takes to fall to 2 % of the release angle, the threshold of the measured settling time in demo 1.
On the sample the fit gives $T_0 = 1.7410$ s against 1.7409 s from $L_{eq}$, $c = 0.0637$, and the first cycle at 29° is 1.6 % slower than $T_0$. The damping line gives $\zeta_l = 0.0060$ and $c_q = 0.082$ 1/rad, close to the values 0.0060 and 0.080 used in the simulation. A single $\zeta = 0.0164$ from the first cycles predicts a settling time of 68 s; the amplitude-dependent $\zeta(A)$ predicts 115 s, close to the 116 s measured in demo 1 with the same threshold. The linear model is still the right local description: around any amplitude it gives the correct frequency and decay rate, which is how linearization is used in control design.
The amplitude window in the interactive version selects which cycles enter the two fits. Restricting the period fit to small amplitudes, for example, leaves too little curvature to determine $c$, while the damping line can still be fitted there. Each fit needs at least three values inside the window, and a damping point counts at the mean amplitude of its $n$ cycles, so a large A_min removes the damping line first. On the sample the damping line survives up to A_min = 16.5° and the period fit up to 21.5°; a release of 20° to 30° allows about 11° to 15° for the damping line. Above that limit the module reports which fit is missing and the largest A_min that still gives it.
Interactive: period and damping against the amplitude
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.
88 cycles with amplitude from 28.6 to 0.3 deg fit: T0 = 1.7410 s (theory 1.7409 s, +0.01 %), c = 0.0637 (theory 1/16 = 0.0625) length from T0: 0.753 m (L_eq 0.753 m); first cycle at 29 deg is 1.6 % slower than T0 zeta(A) = 0.0060 + 0.0346 A -> zeta_lin = 0.0060, c_quad = 0.082 1/rad simulation truth: zeta_lin = 0.0060, c_quad = 0.080 1/rad 2 % settling: linear model with early zeta 0.0164 -> 68 s; amplitude-dependent model -> 115 s

Python output
(appears after the first live run)
Show code
Loading the source...Homework: your own phone pendulum (100 points)
The homework runs on your own recording, together with a photo of the setup and your measured $d$, $h$ and $w$ with their uncertainties; students without a phone use a simulated backup file with a longer pendulum ($d$ = 1.05 m from the pivot to the phone centre) and say so in the report. The pendulum stands in for the swinging load of a small crane whose damping a controller must improve. Every number in the report must come from the student’s own script, built from hw_starter.py and submitted with the report. The interactive demos above can load the recording and may be used to check those numbers; most of the points are for the parts they do not do: choosing and justifying the peak ranges and fit windows, estimating uncertainties and propagating them, the plots, the comparisons between methods, and the explanations. 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 backup data file is in its data/ folder. Clone the repository, or download it as a zip file.
- Recording and loading (10 points)
- Logarithmic decrement (15 points; L7)
- Second-order fit (15 points; L6, L8)
- Length (15 points; L3)
- Poles (10 points; L16)
- Settling time (10 points; L16)
- Beyond the linear model (15 points)
- Engineering judgement (10 points)