Calculating idc from FOC quantities

Post Reply
User avatar
johu
Site Admin
Posts: 5836
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 163 times
Been thanked: 1058 times
Contact:

Calculating idc from FOC quantities

Post by johu »

I am currently looking into improving the calculation of idc (DC current) in FOC software. It is needed for actual meaningful limitation of DC current via idcmin/idcmax.

Now, from back in the days working on solar inverters, that also use FOC, I remember that iq is the current actually fed to the grid (active current) and id is current that swings back and forth between grid and inverter (reactive current). On the DC side you only see the active current and the losses created by reactive current.

With that info I go about and calculate

Code: Select all

idc = (iq * uq) / FOC::GetMaximumModulationIndex()
So active current times active voltage, divided by maximum possible voltage. It results in a too low value if I remember correctly, will check tomorrow. So I went to search for a better one and found this:
https://e2e.ti.com/support/microcontrol ... 12#1693712
Here they calculate, transformed to my code:

Code: Select all

idc=(Vd * Id + Vq * Iq)/ FOC::GetMaximumModulationIndex() * 1.5
So both iq and id find equally weighted input to DC current. Which is a bit weird, because throwing plain id at the motor will not generate any torque, only some heat losses. Whats the 1.5 factor?
What makes it even more confusing is that on IPM motors id combined with iq generates more torque than plain iq. So yes, id should somehow find entry to idc calculation?

Are there any gurus who know how to do this correctly?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
arber333
Posts: 3276
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 239 times
Contact:

Re: Calculating idc from FOC quantities

Post by arber333 »

I remember reading somewhere that point of the BLDC motor control is to use the same math as for the brushed motor control. And they use DC current yes? We are still talking BLDC motor which are wired ABC vs PMSM which are wired VWY. Nature of the wiring means BLDC lend easier to simpler step control but PMSM use true sine AC function.
Also i remember from using Emrax motor with Unitek/Emsiso inverter it ran much quieter than using a simple BLDC Kelly controler. And it is wired VWY as far as i know.

EDIT: Sorry i meant UWV wiring :)....

That would be my logic for DC current inside your math...
User avatar
Zapatero
Posts: 443
Joined: Fri Oct 25, 2019 11:08 am
Location: Germany, Ulm
Has thanked: 25 times
Been thanked: 39 times
Contact:

Re: Calculating idc from FOC quantities

Post by Zapatero »

Reading this with a lot of interest, as i'll be a strong (also monetary) supporter of the progress of this feature. Limitations give me a headache in programming into my custom ECU. If the Inverter would take care of this, everything just would get so easy! And also it would feel more like a factory electric car!

Thanks Johannes for taking care of this!
nailgg
Posts: 119
Joined: Sat Dec 22, 2018 8:40 pm

Re: Calculating idc from FOC quantities

Post by nailgg »

Not a guru, but the factor of 1.5 comes from the power-invariancy or amplitude-invariancy stuff. Detailed explanation can be found here: https://e2e.ti.com/support/microcontrol ... 58#1000558

In your code you're using power-invariant form of the Clarke Transformation, so the multiplier must be sqrt(3/2) if I'm not mistaken.
So both iq and id find equally weighted input to DC current. Which is a bit weird, because throwing plain id at the motor will not generate any torque, only some heat losses.
Throwing plain id at the motor generates no torque but generates heat, so the energy of the heat produced comes from the batteries, so why not include id in the idc calculation?
User avatar
johu
Site Admin
Posts: 5836
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 163 times
Been thanked: 1058 times
Contact:

Re: Calculating idc from FOC quantities

Post by johu »

Philip, thanks for sponsoring :)
In our discussion we considered sending the BMS measured DC current to the inverter. But of course this introduces another depedency and config burden.

Nail, yes id generates heat but independently of motor speed. Say 250A id will generate 2 kW of heat (about 5A DC for 380V). It will generate 2 kW no matter if the motor spins at 5000 rpm or is stationary. Where 250A iq will result in different DC currents depending on speed.

Anyway, I did a test drive and plotted BMS measured idc and inverter calculated idc. Turns out at low throttle they are not too far apart. Which makes sense because at low throttle MTPA avoid reluctance torque and feeds mostly iq to the motor.
But then at full throttle I saw 350A on the BMS and just 100A on inverter.

Now I applied the formular as suggested:

Code: Select all

idc = (iq * uq + id * ud) / FOC::GetMaximumModulationIndex();
idc = FP_MUL(idc, FP_FROMFLT(0.81649658092772603273));
And the result is indeed much better :) Observe polarity is swapped. Inverter regards regen as negative and BMS regards regen as positive.
Maybe add a 1.05% factor for estimated inverter efficiency and we should be pretty good.
Attachments
idc-inv.png
idc-bms.png
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
johu
Site Admin
Posts: 5836
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 163 times
Been thanked: 1058 times
Contact:

Re: Calculating idc from FOC quantities

Post by johu »

So just tested the idcmin and idcmax limits with the new calculation. They work super smooth!
I set idcmax to 200 and indeed BMS reported 210A peak current with hardly any overshoot. Also tried a 20A limit and crawled up the hill at walking pace :) Then with throttle floored I increased to 40A which gave a little shake and speed sortof doubled.

Will be in the next release, thanks for your input everyone.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
johu
Site Admin
Posts: 5836
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 163 times
Been thanked: 1058 times
Contact:

Re: Calculating idc from FOC quantities

Post by johu »

Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
Zapatero
Posts: 443
Joined: Fri Oct 25, 2019 11:08 am
Location: Germany, Ulm
Has thanked: 25 times
Been thanked: 39 times
Contact:

Re: Calculating idc from FOC quantities

Post by Zapatero »

Thanks you Johannes for solving my request so quickly!
I'm happy i do have meaningful ampere-limits now that i can work with. Brings me a bit closer to the OEM feeling that i'm looking for.
Also i think this is a huge improvement for every one out there using the openinverter software!
User avatar
johu
Site Admin
Posts: 5836
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 163 times
Been thanked: 1058 times
Contact:

Re: Calculating idc from FOC quantities

Post by johu »

So turns out this needed a bit more tweaking, reason being quite noisy current measurements:
noise.png
Now just added some heavy filtering to idc which removes stuttering when the limiter steps into action.
Not so happy about this much noise in general but it doesn't seem to have practical implications.

Will release a fix release soon.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Post Reply