Testing FOC for synchronous motor

User avatar
johu
Site Admin
Posts: 6713
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 368 times
Been thanked: 1542 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Didn't work that way. Current have kp=2. Anything more will lead to trips, so I guess thats oscillation? But it doesn't keep id at zero as set.
Adding more ki eventually leads to the motor spinning even with 0 id and iq commanded. I guess thats down to the remaining offset of the sensors.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
nailgg
Posts: 119
Joined: Sat Dec 22, 2018 8:40 pm

Re: Testing FOC for synchronous motor

Post by nailgg »

johu wrote: Mon Jun 03, 2019 1:27 pm Adding more ki eventually leads to the motor spinning even with 0 id and iq commanded. I guess thats down to the remaining offset of the sensors.
Yes, probably. Maybe you can remember I tried to achieve zero current offset here: viewtopic.php?p=416#p416

When the inverter is started software finds the current offset, but also when the gate drivers draw current from the 5V line more (negative) offset is added because of a small drop in the 5V. So I fed the current sensors through a separate 5V DC/DC with common ground to the main PCB, and scaled the outputs to 3.3V through voltage dividers. Offset is no more.
kiwifiat
Posts: 99
Joined: Sat Dec 22, 2018 9:39 pm
Location: Vancouver, Canada
Been thanked: 11 times

Re: Testing FOC for synchronous motor

Post by kiwifiat »

johu wrote: Mon Jun 03, 2019 6:18 am Now I'm wondering, does it make any sense to make id dynamic below field weakening. Like right now I'm scaling it with throttle. Should I rather set it to a fixed value?
When you say fixed value do you mean x amps or do you mean x=-y%Iq?

To achive MTPA on an IPM motor Id = -x%Iq . In the case of say a gen2 toyota prius x turns out to be -30 % of Iq. x needs to be determined experimenally and is different for IPM motors of different designs primarily because in FOC speak the inductance on the d axis is determined by the physical structure of the rotor. So from that perspective Id must be dynamic for best performance. And we should only employ FW once we have approached the maximum rpm with the available line voltage.
User avatar
johu
Site Admin
Posts: 6713
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 368 times
Been thanked: 1542 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Yes that clear things up, thank you!
So currently you can configure A/% for id and iq separately. So you could set it to 3 for iq (resulting in max 300A torque current) and -1 for id for x=-33%
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: 6713
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 368 times
Been thanked: 1542 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

I submitted new code that limits the maximum modulation and gives priority to id.
I have only tested with my "HIL" as the Touran is out of service due to some resolver problem.
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: 6713
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 368 times
Been thanked: 1542 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

So one more round of testing now that I'm back from holiday. I've reduced PWM frequency to 8.8kHz as learned in Sweden and also increased deadtime to 75.

I've fixed the integrator windup so now ki should actually have an effect. I still don't quite get the expected results. So yes I can spin but the current draw is still too high.

I also forced iqref=0 and searched the syncofs where the motor produced no torque at all. That seems somewhere around 62000. But then the measured iq is not 0 but almost equal to id. Also when I set iqref to a positive value it reads a negative value :?

It looks different when I put the car into gear and put the hand brake on. Then the commanded id and iq values are hit spot-on. Its only when the thing starts moving that things go weird. Anyone?

Forgot to pull a parameter dump, basically synofs=62000, curqkp=curdkp=30, curqki=curdki=10. throtid=-1, throtiq=3
Attachments
stm32_sine.zip
(63.02 KiB) Downloaded 208 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
nailgg
Posts: 119
Joined: Sat Dec 22, 2018 8:40 pm

Re: Testing FOC for synchronous motor

Post by nailgg »

johu wrote: Sun Jul 07, 2019 7:14 pm Also when I set iqref to a positive value it reads a negative value :?

It looks different when I put the car into gear and put the hand brake on. Then the commanded id and iq values are hit spot-on. Its only when the thing starts moving that things go weird. Anyone?
Welcome back :) So if it works nicely when there's no movement, maybe you need to "unswap" the resolver sin/cos?
User avatar
johu
Site Admin
Posts: 6713
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 368 times
Been thanked: 1542 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Thanks :) Did all sorts of swaps yesterday and so far they all resulted in either no movement or instant over current. Then the wifi kept dying on me and I quit. Will try to be more systematic today.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
purplespark
Posts: 52
Joined: Fri Feb 15, 2019 10:22 am
Location: United Kingdom

Re: Testing FOC for synchronous motor

Post by purplespark »

Hi folks,
Please excuse me butting in , I don't know much about motors or coding , but Paul Holmes runs a routine
that establishes the motor parameters first, and after that it's good to go . I presume it's something along the lines of
the leaf resolver code stamped on the motor ?
Sorry to interrupt.
User avatar
johu
Site Admin
Posts: 6713
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 368 times
Been thanked: 1542 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Yes he has a procedure to find the best offset I believe. That is useful to have once the basics are sorted.

So today I did a successful test drive :) It's still not mighty powerful but improving. I could go 30 km/h up hill.

In idle things are as weird as ever. Commanding positive iq and getting negative.

I changed the resolver code to give a sample every time, not just every other. But that didn't change things either.

Updated code is on github (foc-test branch!)
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: 6713
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 368 times
Been thanked: 1542 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Finally! The first test drive with some serious power. At least more serious than anything so far.

What was the problem? The motor is spinning backwards, as indicated by "angle" running from 360 to 0°. And that means we need NEGATIVE iq reference!

Now I can spin to 4000rpm without tripping and without excessive currents and most of all without iq going negative even though being commanded positive.

I started out with maximum iq of 300A and maximum id of 200A but thats still leading to frequent over-current trips. When set to 200A I can floor throttle without tripping. So still some room for improvement but I think I'm on the right track now.

EDIT: also theres some strange whine from the inverter when flooring the throttle, maybe regulator oscillation?

Software and parameters attached, video coming.
Attachments
Leaf 2019-07-10.json
(1.25 KiB) Downloaded 253 times
stm32_sine.zip
(61.65 KiB) Downloaded 247 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
arber333
Posts: 3563
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 134 times
Been thanked: 335 times
Contact:

Re: Testing FOC for synchronous motor

Post by arber333 »

johu wrote: Wed Jul 10, 2019 6:46 pm Finally! The first test drive with some serious power. At least more serious than anything so far.

EDIT: also theres some strange whine from the inverter when flooring the throttle, maybe regulator oscillation?
Congratulations, crossing my fingers here...

Yes if you listen carefully in this video you can hear the same whine from Leaf motor that Stane has in his Mazda. We use Lebowski FOC code here. Code is proprietary, but brain schematic is free.
I think this is the rotating field overtaking the mechanical rotor and colapsing the energy when encoder reports everything is not correct. I think i will have to tinker with FOC settings further....
nailgg
Posts: 119
Joined: Sat Dec 22, 2018 8:40 pm

Re: Testing FOC for synchronous motor

Post by nailgg »

johu wrote: Wed Jul 10, 2019 6:46 pm Finally! The first test drive with some serious power. At least more serious than anything so far.

What was the problem? The motor is spinning backwards, as indicated by "angle" running from 360 to 0°. And that means we need NEGATIVE iq reference!

Now I can spin to 4000rpm without tripping and without excessive currents and most of all without iq going negative even though being commanded positive.
Congratulations! But I have to say I was surprised that you achieved it with negative iq reference. What about the id? If iq needs to be negative in your case, the id reference probably needs to be positive (according to Id = -x%Iq suggestion by @kiwifiat). Looking at your parameters, gains of both id and iq have the same sign. Maybe this is the reason for over current? I'm not sure.

Anyway, after we can verify the FOC works well for Leaf, we can integrate FOC for ACIM as well. Just need to replace the angle read by resolver with the rotor flux angle calculated by using the "current model". We only need to know the mutual inductance.
arber333
Posts: 3563
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 134 times
Been thanked: 335 times
Contact:

Re: Testing FOC for synchronous motor

Post by arber333 »

I am also waiting on results of FOC and hoping it could be adapted to ACIM. My Mazda ACIM motor still shows vibration when throttle is near 0%.
Also regen over 30% causes violent jerks that have to be dampened by reducing regen power or stopping the car. I think FOC will help with regen a lot.
kiwifiat
Posts: 99
Joined: Sat Dec 22, 2018 9:39 pm
Location: Vancouver, Canada
Been thanked: 11 times

Re: Testing FOC for synchronous motor

Post by kiwifiat »

Great progress, congratulations.

We know from the 202kW dyno run of Arlo1's Leaf motor driven Honda CRX over on Endless-Sphere that FOC works extremely well on IPM motors. No doubt it is just a matter of time before the open inverter is performing just as well.
User avatar
johu
Site Admin
Posts: 6713
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 368 times
Been thanked: 1542 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Thanks everyone.

So yes I do consider using FOC also for async motors but thats a low priority now as slip control works well. Depending on the outcome I might split into 2 firmwares, FOC and slip control. Reason being I want to limit the number of parameters.

I will try positive id today. Whichever one revs higher is the correct one.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
purplespark
Posts: 52
Joined: Fri Feb 15, 2019 10:22 am
Location: United Kingdom

Re: Testing FOC for synchronous motor

Post by purplespark »

Well done Johannes !
Can I just ask about your DC-DC converter - Is it a meanwell ac/dc psu ? I've been looking at the meanwell range
and their dc/dc converters are quite expensive .
User avatar
johu
Site Admin
Posts: 6713
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 368 times
Been thanked: 1542 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Thanks :)
Yes it's AC/DC and they also specify up to 380V DC input. When the battery is full (4.1 Vpc) that's 393V, I hope that's within tolerance.
I will eventually put it somewhere where there is no spray water as it's not water proof
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Rogue_Ant
Posts: 3
Joined: Thu Jan 03, 2019 6:27 pm

Re: Testing FOC for synchronous motor

Post by Rogue_Ant »

With normal FOC control, Iq's sign is direction of torque production.

Consider the 4-quadrant operation:
Motor direction = forward; Positive Iq = motoring torque.
Motor direction = forward; Negative Iq = regeneration torque.
Motor direction = reverse; Negative Iq = motoring torque.
Motor direction = reverse; Positive Iq = regeneration torque.

An IPM will always want negative Id:
IPM.JPG
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: Testing FOC for synchronous motor

Post by johnspark »

Meanwell dc supplies are often used in electrical substations so they have a reasonable reliability.
User avatar
johu
Site Admin
Posts: 6713
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 368 times
Been thanked: 1542 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Ok, thats very interesting. So motoring in forward works out to regen in backward and vice versa. id always negative, understood.
Any idea why regen became more pronounced with rising speed? Some phase lag perhaps?
johnspark wrote: Fri Jul 12, 2019 9:18 am Meanwell dc supplies are often used in electrical substations so they have a reasonable reliability.
Thats a good sign. I have a limited experience of 3 devices that have been running for quite a while and never failed. As opposed to noname Chinese ones you get on ebay. They failed after 3 months because the main inductor lost its coating :shock:
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Rogue_Ant
Posts: 3
Joined: Thu Jan 03, 2019 6:27 pm

Re: Testing FOC for synchronous motor

Post by Rogue_Ant »

johu wrote: Fri Jul 12, 2019 9:23 am Ok, thats very interesting. So motoring in forward works out to regen in backward and vice versa. id always negative, understood.
Any idea why regen became more pronounced with rising speed? Some phase lag perhaps?
If the regen increased, you should see the Iq change accordingly...

On regen, the leg voltages are phase delayed compared to motoring. So, if you have lagging leg voltages as RPMs rise, then that will reducing motoring effort (when motoring is desired), and increase regen effort (when regen is desired).
arber333
Posts: 3563
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 134 times
Been thanked: 335 times
Contact:

Re: Testing FOC for synchronous motor

Post by arber333 »

Rogue_Ant wrote: Fri Jul 12, 2019 10:16 am
johu wrote: Fri Jul 12, 2019 9:23 am Ok, thats very interesting. So motoring in forward works out to regen in backward and vice versa. id always negative, understood.
Any idea why regen became more pronounced with rising speed? Some phase lag perhaps?
If the regen increased, you should see the Iq change accordingly...

On regen, the leg voltages are phase delayed compared to motoring. So, if you have lagging leg voltages as RPMs rise, then that will reducing motoring effort (when motoring is desired), and increase regen effort (when regen is desired).
So like i told in the beginning when i tested Leaf motor with old code, you have to provide a bit of positive excitation (throttle) to maintain 0 torque. If you release throttle you get humongous torque at low RPM. Er... it sounds strange, but magnet vector is allways pulling back on the rotor.

Does this make IPM any less efficient vs ACIM in case of road glide?
We need to implement 0 torque mode though in order to be able to shift normally.
User avatar
johu
Site Admin
Posts: 6713
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 368 times
Been thanked: 1542 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Now I'm starting to wonder if there is some kind of asymmetry built into the leaf motor. In one direction I can spin up to almost any speed (off the scale of the 8krpm rev counter). Now if I only change the sign of the desired iq it does spin in the other direction as expected but it doesn't spin as fast and has a tendency to trip out. It could be the motor spins in the other direction when in the Leaf.

So, anyone ever experienced a preferred spinning direction with the Leaf motor?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
arber333
Posts: 3563
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 134 times
Been thanked: 335 times
Contact:

Re: Testing FOC for synchronous motor

Post by arber333 »

johu wrote: Fri Jul 12, 2019 4:14 pm Now I'm starting to wonder if there is some kind of asymmetry built into the leaf motor. In one direction I can spin up to almost any speed (off the scale of the 8krpm rev counter). Now if I only change the sign of the desired iq it does spin in the other direction as expected but it doesn't spin as fast and has a tendency to trip out. It could be the motor spins in the other direction when in the Leaf.

So, anyone ever experienced a preferred spinning direction with the Leaf motor?
Yes i had the same experience with Pauls controler, but at 100Vdc. Can you try changing the resolver wires and phases and then spin it in another direction with positive Iq? Maybe it is asymetrical only when progressing not reversing. I remember someone said IPM motors effect is similar to ACIM slip in one direction.
Post Reply