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
Motion modes · 27b

MIT mode 2: choosing Kp and Kd

MIT mode, part two: how to choose Kp and Kd. It opens with the whole episode on one framework page: 27a's tick closes into a loop, the master's Kp and Kd → the formula → the clamp → the current → the motor's inertia J → the encoder → the observer → MitCtlStep → back into the formula. Three marks on the loop: the inertia turns Kp and Kd into a ringing spring (√(Kp/J), damping ratio Kd/(2√(Kp·J)), worked out from the code); the damper uses the observer's speed, about two ticks late, so Kd has a floor and a ceiling; the clamp caps the torque at 6.5 A × 0.05 = 0.325 N·m. Beside it, the window as measured: a Kp × Kd grid of 220 runs. Running example: the SIL's wb40st (1:1, J 5e-6, observer 960 Hz); the master wants a joint 20 times stiffer, Kp 20, and the same 0.1 N·m push at 50 ms; what Kd goes with it? Five stops go round the loop once: any number goes in (set_app_MIT_kp/kd's range check is still a TODO; Kp 50 is taken too); the spring on paper (Kp 20 rings at 318 Hz; 27a's Kd 0.005 gives a damping ratio of 0.25, 44 % overshoot in the textbook, 93 % measured); the textbook Kd (ratio 0.7 → 0.014, 4.6 % on paper; guess first; 25.7 % measured); where the speed comes from (speed_obs_pll chases the encoder count, wn_Hz 960; at tick 505 the true speed is −8.135 and the observer says −6.967, about two ticks late → episode 13); a late brake (tick 505 by hand, 3.235 A as the bench prints; the damper brakes 14 % short, then too hard five ticks later; a what-if feeds the formula the true speed and the overshoot falls to 13.3 %). Then: the window at Kp 20 (guess: does more Kd always help? It settles from 0.004 to 0.03, 12.4 % at 0.02, 11.4 % at 0.025, worse again above); two ways out (too little Kd rings at about 294 Hz, near the spring's own frequency; too much buzzes at 668 / 722 Hz whatever Kp is: the damper alone would stop the motor in J/Kd, faster than the observer's lag); the whole window (the stiffer the spring, the narrower the window: at Kp 32 only 0.012–0.02 is left, from Kp 35 nothing; with the true speed Kp 50 settles; at observer bandwidths of 240 / 480 / 960 Hz the Kd ceiling is 0.012 / 0.02 / 0.04); the clamp (Kp 20, Kd 0.02: a 0.01 rad target move overshoots 9.5 %; guess; a 1 rad move 39.8 %: the formula asks for 400 A and gets 6.5, and the spring is not a spring any more); how to choose (four rules, on the framework page). Not shown: a gearbox, halt and quick stop → 27c; the price of a faster observer → 13b. Your turn: with the observer at 480 Hz, all twenty Kd at Kp 20 keep buzzing. The bench sil-mac/ep27 mit27 gained --pll and a labelled what-if, --true-speed; servohub is unchanged.

Up next27c · MIT mode 3: the spring behind a gearbox→