Arduino-FOC
Arduino-FOC copied to clipboard
[FEATURE] Foc_current mode and Current feed forward
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.
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:
- Vq += BEMF + SPEED * Ld * Id
- Vd -= SPEED * Lq * Iq That could be added before the PID output ramp limiting.
That technique is called decoupling. Vesc seems to give different options.
- only BEMF decoupling :
Vq += BEMF - cross decoupling :
Vq += SPEED * Ld * IdandVd -= SPEED * Lq * Iq - both :
Vq += BEMF + SPEED * Ld * IdandVd -= 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
- if phase_resistance is available,
Vq = phase_resistance * IqandVd = phase_resistance * Id
In loopfoc() function for all modes:
- if phase_inductance is available
Vq += SPEED * Ld * Id - if KV_rating is available
Vq += BEMF - if phase_inductance is available
Vd -= SPEED * Lq * Iq
Nice video about the cross decoupling: https://www.youtube.com/watch?v=bOr_EgJUakI
Nice article, and the benefit we could expect: