Skip to main content
NewEpisode 3a is out: Carry the conversation onWatch →

This part is for members

Membership opens soon. Leave your email and we'll tell you the day it does. Founding members get the launch price.

Keep watching the free parts
Control loops · 13a

Speed observer 1: one tick of the PLL

Every speed in the firmware comes from one estimate, speed_now_rad_s, and nothing measures it directly. Running example: the PP move of episodes 1, 3 and 4 (two turns, 600 rpm) on the bench motor wb40st (131,072 counts a turn, 5 pole pairs), stopped at tick 1527, 152.8 ms after the target write, with the motor really at 599.75 rpm. Eight stops in the order the code runs: every 100 µs PosSpeedCtlLoopTask hands enc_sum_p (134,743) to speed_obs_pll; subtracting, a 133-count step says 608.83 rpm, one count per tick is 4.58 rpm, and over the cruise subtraction misses the true speed by 4.23 rpm (sd) against the observer's 1.23; the idea is a model that chases the encoder (toy: 36 counts a turn); error = this step + the gap carried from the last tick (−0.0062692) = +0.0001064 rad, 2.2 counts, clamped to ±1 rad; speed += wn²·tp·error = +0.387 rad/s, 62.528 → 62.915 (600.79 rpm), and only the kept copy is clamped to 753.98; the model moves (1.414·wn·e + ω)·tp = 133.1 counts, leaving −0.0062759; wn_Hz defaults to 800 and is overwritten by the motor header's 960 (the gim6010 says 1200), saved to flash; five readers: protect_check's overspeed check, pos_speed_ctl_pip, the electrical speed × 5 pole pairs (9b), the host's 600.79 rpm, and MIT mode (not called in PP). Your turn: tick 1528 steps 131 counts and the speed still rises to 600.93.

Up next13b · Speed observer 2: choosing wn_Hz→