Arduino-FOC icon indicating copy to clipboard operation
Arduino-FOC copied to clipboard

[FEATURE] Foc_current mode and Current feed forward

Open Candas1 opened this issue 2 years ago • 10 comments

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 avatar Sep 23 '23 08:09 Candas1

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 avatar Sep 27 '23 06:09 Candas1

I think I am wrong about the feedforward: image

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 * Id and Vd -= SPEED * Lq * Iq
  • both : 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.

Candas1 avatar Oct 01 '23 10:10 Candas1

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

  • if phase_resistance is available, Vq = phase_resistance * Iq and Vd = 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

Candas1 avatar Oct 01 '23 10:10 Candas1

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

Candas1 avatar Oct 02 '23 07:10 Candas1

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

Candas1 avatar Oct 06 '23 10:10 Candas1