Lebowski
10 MW
I think I need to clarify a bit more what the control loop coefficients do. This is taken from v2.10:
Lets assume a f_sample of 40kHz
Every cycle of f_sample (so 40000 times a second) the controller decides by how much to upgrade the phase and amplitude of the 3 signals driving the motor. The coefficients e to g are the maximum updates for the phase loop, the coefficients h to j the max updates for the amplitude loop. To make the algorithm fast to calculate, an update is either to add the coefficients or subtract the coefficients from the internal variables.
The internal phase is called phi. phi has a range from 0 to 65535 (32 bit, with 16 before the comma and 16 after) representing 0 to 360 degrees.
The internal amplitude is called ampli (inventive, ey ?) and has a range from -32767 to +32767 (again 32 bit with 16 after the comma), with 32767
being the maximum voltage to the motor (with Vbat lets say 60V at max ampli (so 32767) the sines to the motor will have 1.15*60 = 69 V peak to peak).
The controller uses moving-midpoint, meaning it can output sine waves with a peak-peak 15% larger than the supply, this is the reason for the 1.15.
The output voltage are like the tips of a 3-prong propellor blade, the moving midpoint means the center of the propellor moves up and down. All very
much like the rotor in a Wankel engine.
Every cycle the controller determines whether to increase or decrease phi and ampli (so phase and amplitude of the 3 motor signals).
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 320 represents (320/65536)*360 = 1.76 degrees
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 16 represents (16/65536)*360 = 0.09 degrees.
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 f. For stability g must be less than 1/40th of f.
When the motor is running at a constant speed, all contributions from coefficients e and 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 e and f, but coefficient 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 = 21.97 times 360
degrees, so 21.97 e-rotations per second (times 60 for per minute = 1318 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...
hope this clarifies things a bit...
Code:
phase control loop, drive 2
e) 1st order:320
f) 2nd order:16
g) 3rd order:0.4
amplitude control loop
h) 1st order:120
i) 2nd order:6.0
j) 3rd order:0.15
Lets assume a f_sample of 40kHz
Every cycle of f_sample (so 40000 times a second) the controller decides by how much to upgrade the phase and amplitude of the 3 signals driving the motor. The coefficients e to g are the maximum updates for the phase loop, the coefficients h to j the max updates for the amplitude loop. To make the algorithm fast to calculate, an update is either to add the coefficients or subtract the coefficients from the internal variables.
The internal phase is called phi. phi has a range from 0 to 65535 (32 bit, with 16 before the comma and 16 after) representing 0 to 360 degrees.
The internal amplitude is called ampli (inventive, ey ?) and has a range from -32767 to +32767 (again 32 bit with 16 after the comma), with 32767
being the maximum voltage to the motor (with Vbat lets say 60V at max ampli (so 32767) the sines to the motor will have 1.15*60 = 69 V peak to peak).
The controller uses moving-midpoint, meaning it can output sine waves with a peak-peak 15% larger than the supply, this is the reason for the 1.15.
The output voltage are like the tips of a 3-prong propellor blade, the moving midpoint means the center of the propellor moves up and down. All very
much like the rotor in a Wankel engine.
Every cycle the controller determines whether to increase or decrease phi and ampli (so phase and amplitude of the 3 motor signals).
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 320 represents (320/65536)*360 = 1.76 degrees
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 16 represents (16/65536)*360 = 0.09 degrees.
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 f. For stability g must be less than 1/40th of f.
When the motor is running at a constant speed, all contributions from coefficients e and 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 e and f, but coefficient 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 = 21.97 times 360
degrees, so 21.97 e-rotations per second (times 60 for per minute = 1318 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...
hope this clarifies things a bit...