Open Candas1 opened 9 months ago
This estimation function can also be reused in angle mode and velocity mode
Now it looks like that: Vq = phase_resistance Iq + BEMF Vd = - SPEED L * Iq
It could be later updated for field weakening in this way: Vq = phase_resistance * Iq + BEMF + SPEED L Id Vd = *phase_resistance Id* - SPEED L * Iq
Later, for salient motors like IPMSM, it could be updated to handle Ld and Lq: Vq = phase_resistance Iq + BEMF + SPEED Ld Id Vd = phase_resistance Id - SPEED Lq Iq
I think I am wrong about the feedforward:
Only those values are being added as feedforward term after the PI output:
That technique is called decoupling. Vesc seems to give different options.
Vq += BEMF
Vq += SPEED * Ld * Id
and Vd -= SPEED * Lq * Iq
Vq += BEMF + SPEED * Ld * Id
and Vd -= SPEED * Lq * Iq
phase_resistance * Iq
and phase_resistance * Id
might be already covered by the PI controller.
So something like that could be done. In move() function for voltage mode
Vq = phase_resistance * Iq
and Vd = phase_resistance * Id
In loopfoc() function for all modes:
Vq += SPEED * Ld * Id
Vq += BEMF
Vd -= SPEED * Lq * Iq
Nice video about the cross decoupling: https://www.youtube.com/watch?v=bOr_EgJUakI
At the moment in voltage mode, if information like phase_resistance, phase_inductance and KV_rating are provided, q and d currents are used as target and the q and d voltages are estimated.
The foc_current could benefit from that and use those values as feedforward for the q and d PI controllers. The q and d voltage estimation could be made a separate function not to duplicate the code.
That would probably improve the dynamics of the foc current control.