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
Current loop · 10a

The current loop 3: where the PI's numbers come from

The current loop runs on two numbers: kp = 0.633 and ki = 1050. The virtual rotor is clamped (a change to the bench's motor model; the firmware is untouched) so the loop is seen alone, on episode 9a's 0 → 2 A step. kp is written three times before the first tick: MotorCtlSmInit works it out by formula for a default motor (1.86), MotorCtrlInit overwrites it with the header's typed macro (0.633), and on the board flash overwrites it again (worked out from the code). Why 0.633: kp·dt/L = 1/6, so each tick closes a sixth of the remaining gap: 0.33 A after one tick, 1.26 A at 0.3 ms. Why 1050: ki = R/L, so the integrator supplies the resistor's voltage at the winding's own pace (0.95 ms) and ends at 0.40 V = R × 2 A; ki = 0 stops at 1.52 A, 260 leaves a tail, 4200 overshoots to 2.39 A. bandwidth_percentage scales only the P term, and the integral with it: 0.76 A at 50 %, 1.79 A at 200 %. In the SIL 600 % gets there in one tick, but with the board's late tick added (labelled as a model) 200 % overshoots to 2.14 A and 400 % to 3.22 A. Your turn: another motor's header, where kp is 1.6 times the formula.

Up next10b · The current loop 4: why iq stops short of 2 A→