simplefoc / Arduino-FOC

Arduino FOC for BLDC and Stepper motors - Arduino Based Field Oriented Control Algorithm Library
https://docs.simplefoc.com
MIT License
1.95k stars 511 forks source link

[FEATURE] Foc_current mode and Current feed forward #317

Open Candas1 opened 9 months ago

Candas1 commented 9 months ago

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.

Candas1 commented 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

Candas1 commented 9 months ago

I think I am wrong about the feedforward: image

Only those values are being added as feedforward term after the PI output:

That technique is called decoupling. Vesc seems to give different options.

phase_resistance * Iq and phase_resistance * Id might be already covered by the PI controller.

Candas1 commented 9 months ago

So something like that could be done. In move() function for voltage mode

In loopfoc() function for all modes:

Candas1 commented 9 months ago

Nice video about the cross decoupling: https://www.youtube.com/watch?v=bOr_EgJUakI

Candas1 commented 9 months ago

Nice article, and the benefit we could expect: image image