"Every cycle the controller determines whether to increase or decrease phi and ampli (so phase and
amplitude of the 3 motor signals).
b, e: every cycle this coefficient is added or subtracted from the phase phi, but it's contribution will be
forgotten by the next cycle. It is kind of a momentary jump in phase, one which will be forgotten by the next
cycle. It is a coefficient necessary for loop stability, it's minimum value is 20 times coefficient f. The
value 240 represents (240/65536)*360 = 1.32 degrees
c, f: every cycle this coefficient is added to or subtracted from the phase phi but its contribution is not
forgotten, it represents the phase advance (or retreat) every cycle. When a motor is running you need a
constant phase advance, as the back emf sine waves keep advancing and the controller needs to keep
up with this. The value of 12 represents (12/65536)*360 = 0.07 degrees.
d, g: every cycle the phase phi is also increased by a constant phase increase which I call phi_int. Phi_int is
updated every cycle by the value of coefficient g. So if phi_int for instance is 100, it means every cycle the
phase phi is automatically advanced by 100 (/65536 * 360 = 0.55 degrees). This automatic advance comes
on top of the advance of coefficient c,f. For stability d,g must be less than 1/40th of c,f.
When the motor is running at a constant speed, all contributions from coefficients b,e and c,f will average out
to 0. The phase advance of the internal variable phi purely comes from its automatic updating with phi_int.
When the motor slows down or speeds up, the controller will immediately respond with phase updates from
coefficient b,e and c,f, but coefficient d,g means also the automatic phase update phi_int will increase (speed
up) or decrease (slow down). Phi_int is a measure of motor speed. With phi_int = 100, phi will be increase
40000 times a second with 100, so a total phase advance of (100 * 40000) / 65536 times 360 =
61 times 360 degrees, so 61 e-rotations per second (times 60 for per minute = 3660 erpm) the amplitude coefficients work the same.
h: is added to the amplitude every cycle but will be forgotten by the next. With 60V battery, 120 represents
a peak-peak increase/decrease of (120/32767) * 1.15 * 60 = 0.253 V
i: is the update for the amplitude variable that will not be forgotten from cycle to cycle, 6 represents 12.6 mV
j: and this coefficient accumulates in the automatic amplitude update variable which will be added to the
amplitude every cycle...
The phase loop coefficients can be chosen differently for drive_2 (startup) and drive_3 (normal running).
Drive_2 benefits from a lower 3rd order coefficient as too high a value puts a lot of noise on the motor speed
variable phi_int which can make the controller jump too early to drive_3. Higher values for the 1st and 2nd
order coefficient makes the controller faster to respond (bigger phase steps) which is good when the motor
moves and you want the controller to immediately catch on.
In drive_3 it's best to let the coefficients have the ideal ratios b/c of 40 and c/d of 20. Higher values means
the phase updates for every cycle are larger: I can imagine this is good for a high speed motor, or when
the motor speed rises/drops sharply. "