IPM Motor Simulation and FOC Software

Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

That doesn't look like the bug as the currents are returning to 0 ok but you field weakening current is huge compared to Iq!

The parameters look OK. What speed is the motor running (a plot including frq would make it a lot easier to see what is going on).
User avatar
Romale
Posts: 451
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 214 times
Been thanked: 49 times

Re: IPM Motor Simulation and FOC Software

Post by Romale »

Pete9008 wrote: Sat Oct 22, 2022 11:10 am
Vq_Ld and Vd_Lq are the voltages generated across Ld and Lq by Id and Iq when the motor is turning (actual term is wLI so are proportional to speed). They are mostly a pain (these are what limit the performance of high inductan....
this is very difficult for me to understand.
if I turn off the fw and lqminusld, then there is a small current consumption and there is no heating of the controller.

what setting could I try to change in order to get the engine speed higher than the base and at the same time the absence of huge energy consumption without load on the motor shaft?
evil neodymium :twisted:
User avatar
Romale
Posts: 451
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 214 times
Been thanked: 49 times

Re: IPM Motor Simulation and FOC Software

Post by Romale »

Pete9008 wrote: Sat Oct 22, 2022 11:22 am That doesn't look like the bug as the currents are returning to 0 ok but you field weakening current is huge compared to Iq!

The parameters look OK. What speed is the motor running (a plot including frq would make it a lot easier to see what is going on).
at the time of this graph, it was 2700 rpm.
evil neodymium :twisted:
User avatar
Romale
Posts: 451
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 214 times
Been thanked: 49 times

Re: IPM Motor Simulation and FOC Software

Post by Romale »

Pete9008 wrote: Sat Oct 22, 2022 11:22 am That doesn't look like the bug as the currents are returning to 0 ok but you field weakening current is huge compared....
evil neodymium :twisted:
User avatar
Romale
Posts: 451
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 214 times
Been thanked: 49 times

Re: IPM Motor Simulation and FOC Software

Post by Romale »

Pete9008 wrote: Sat Oct 22, 2022 11:22 am a plot including frq would make it a lot easier to see what is going on
what exactly parameters should I display for the new graph? what are the settings of the fw and lqminusld to do this with?
evil neodymium :twisted:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

My guess is that you need a version of the code that limits the throttle to prevent excessive -Id. Think Johannes latest dev build has it but haven't tried it yet. Will probably be able to offer better advise once I've tried a few more things in the simulator.

Edit - see here viewtopic.php?p=46839#p46839

Maybe best start a new thread for this, looks like it's a bit too involved to try and sort here!
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

Not sure whether this looks right or not, going to post anyway in case anyone has any thoughts...

The following plots are with the revised simulator which uses the full motor model. It is using the low I values of 500uH and 160uH for motor Ld and Lq. The motor currents plot is replaced by one showing the voltages in the motor model. Also worth noting that throttle limiting is disabled for these.

First plot, no field weakening, no MTPA:
LoI_NoFW_NoMtpa.png
It can be seen that the motor accelerates to around 3900rpm with the torque reducing at higher speeds. On the motor voltage plot you can see that the bemf tops out at 200V (which I think is the battery voltage of plus the space vector modulation allowance). Pretty much as expected.

Next plot, FW added:
LoI_FW_NoMtpa.png
It now accelerates much more linearly reaching 4950rpm. While it would accelerate to higher frequencies it can be seen from the Ifw plot that the field weakening has already topped out and so the control loops will be starting to saturate.

Next plot, FW and Mtpa added:
loI_FW_Mtpa.png
Bit better acceleration, bit better top speed (~5400rpm), more instability in the FW control loop, still into saturation.

And finally two plots showing the effect of saturation. First one where the simulation stops accelerating and starts coasting before getting to saturation:
LoI_FW_Mtpa_BelowSat.png
Behaves as expected and coasts.

And finally one where the model accelerates into saturation and then coasts:
LoI_FW_Mtpa_AboveSat.png
Strong unwanted regeneration. Due to saturation the loops are running open loop and don't have the authority to keep control.

Edit - For completeness here is a plot with throttle limiting enabled:
LowI_FW_Mtpa_TLim.png
Works but the loop stability needs a bit of work.

It looks like this is modelling most of the behaviour seen in the real world, in particular the Vd and Vq voltages look much closer to the real world. Also worth noting that the control loops now seem to need a lot more integral gain than before presumably due to the significantly larger changes in Vd and Vq with speed (so it looks like I may have been wrong with my earlier thoughts on P and I gains :oops: ).

The big issue is that the motor is only getting to 50% over base speed (bit over 60mph by my sums!). I don't know whether this is representative of the Outlander motor in the real world or whether the model still needs some work on the bemf side of the model (but I haven't been able to find any reference material on how to improve it). Back to needing more data!

Comments welcome!
User avatar
johu
Site Admin
Posts: 5791
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1024 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

Looks like you made a big step towards physical reality :) Nice.

I test drove the throttle limiting and it is not drivable. I can use the rev band up to 4000 rpm as before and also more rpm at little throttle but as soon as the limiter kicks in the motor vibrates and no longer produces torque.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

johu wrote: Sat Oct 22, 2022 3:13 pm Looks like you made a big step towards physical reality :) Nice.
Hope so, it's definitely made it a lot harder to tune things!

What are your thoughts on how far it should be possible to go above base?
johu wrote: Sat Oct 22, 2022 3:13 pm I test drove the throttle limiting and it is not drivable. I can use the rev band up to 4000 rpm as before and also more rpm at little throttle but as soon as the limiter kicks in the motor vibrates and no longer produces torque.
That makes sense from what I've seen. I can get it a bit better in simulation by using P=0, I=100 but not really good enough to use.
User avatar
johu
Site Admin
Posts: 5791
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1024 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

Pete9008 wrote: Sat Oct 22, 2022 3:21 pm What are your thoughts on how far it should be possible to go above base?
Base speed is where rectified motor voltage is on par with battery voltage, right? For Leaf motor that seems around 6000 rpm. Nissan allow about 11000 rpm, so almost double base speed.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

johu wrote: Sat Oct 22, 2022 5:19 pm Base speed is where rectified motor voltage is on par with battery voltage, right? For Leaf motor that seems around 6000 rpm. Nissan allow about 11000 rpm, so almost double base speed.
So the 50% I'm seeing at the moment may be of the right order. Could probably get to 100% with a bit of tweaking of Ls and flux linkage values, the trouble is knowing what's realistic.

I'm wondering whether to try and add another feature into the simulator, basically the ability to import a real time log and then run the motor model against it while automatically tuning motor parameters until the best match is found. The values found could then be used in future simulations with the confidence that it should be a reasonably accurate simulation.
User avatar
Romale
Posts: 451
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 214 times
Been thanked: 49 times

Re: IPM Motor Simulation and FOC Software

Post by Romale »

Pete9008 wrote: Sat Oct 22, 2022 5:31 pm So the 50% I'm seeing at the moment may be of the right order. Could probably get to 100% with a bit of tweaking of Ls and flux linkage values, the trouble is knowing what's realistic.
this gave me the idea that maybe I have very large FW currents and the controller heating precisely because of the high speed additive! the base speed of my engine is 1047 rpm at 36 volts of battery. I accelerated it to 3000 rpm! I will try to limit the maximum frequency of the engine or increase the battery voltage.
evil neodymium :twisted:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

Yes it looks like the FW currents are what is causing the heating. Which firmware are you using, the latest should limit them to a much lower level than that (although to get 3x base speed that might well be what is needed!)?
User avatar
Romale
Posts: 451
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 214 times
Been thanked: 49 times

Re: IPM Motor Simulation and FOC Software

Post by Romale »

Pete9008 wrote: Sat Oct 22, 2022 5:50 pm Yes it looks like the FW currents are what is causing the heating. Which firmware are you using, the latest should limit them to a much lower level than that (although to get 3x base speed that might well be what is needed!)?
5.20 foc
evil neodymium :twisted:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

What's throtcurr set to?
User avatar
Romale
Posts: 451
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 214 times
Been thanked: 49 times

Re: IPM Motor Simulation and FOC Software

Post by Romale »

Pete9008 wrote: Sat Oct 22, 2022 6:18 pm What's throtcurr set to?
4.5
evil neodymium :twisted:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

That would explain it! The code allows 50% of throtcurr as FW current or in your case 225A and if you ask it to accelerate to too high a speed it will use all of it irrespective of whether it is doing any good or not. For now try reducing the max freq.

Hopefully future versions of the code will be better at only using as much FW current as is useful but at moment you will see this effect if you ask for too high a speed.

Edit - the other thing to try for now is to slowly accelerate while watching Id, at some speed Id should start to rapidly increase. Set fmax to just below that speed and you should avoid the high FW current.

Also bear in mind that if syncofs isn't absolutely, perfectly set up there is a real risk of overspeeding your motor when using FW or Mtpa on an unloaded motor!
User avatar
Romale
Posts: 451
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 214 times
Been thanked: 49 times

Re: IPM Motor Simulation and FOC Software

Post by Romale »

thanks a lot for the clarification. I will definitely check it all out.
evil neodymium :twisted:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

No problem, hope it helps.

Its pretty encouraging to see a motor spin that far past base speed; any idea what that motor's inductance a flux linkage values might be?
User avatar
Romale
Posts: 451
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 214 times
Been thanked: 49 times

Re: IPM Motor Simulation and FOC Software

Post by Romale »

Pete9008 wrote: Sat Oct 22, 2022 7:02 pm any idea what that motor's inductance a flux linkage values might be?
No, unfortunately I don't know that.
This is a small motor generator from Nissan note e-power. experience shows that at 360 volts there will be a base speed of 10000 rpm. this is decently higher than the Nissan leaf. this means that the winding has fewer turns and therefore a very low inductance.
evil neodymium :twisted:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

johu wrote: Sat Oct 22, 2022 3:13 pm Looks like you made a big step towards physical reality :) Nice.

I test drove the throttle limiting and it is not drivable. I can use the rev band up to 4000 rpm as before and also more rpm at little throttle but as soon as the limiter kicks in the motor vibrates and no longer produces torque.
Think I know why the throttle limiting isn't working well, its too slow. It needs to be done in the main control loop rather than the 10ms task. Not as nice architecturally but I'm fairly sure it will work much better. At the moment it's backing off too much on one call and then advancing too much on the next.

Will try and test the idea tomorrow but fairly sure it will fix it.

Edit - its done in the 10ms task because it needs to be done before the Mtpa calculation which, when done with floats, is too slow to go in the main loop - bit more thinking needed :(
User avatar
johu
Site Admin
Posts: 5791
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1024 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

How about decreasing iqref and idMtpa by the same factor? In FW region it's not in MTPA anyway but merely MTPV
Attachments
1-s2.0-S2405896318334931-main.pdf
(775.56 KiB) Downloaded 37 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

That looks about the only option at the moment. Not keen on going back to the fixed point Mtpa implementation as with the smaller L value it would really struggle (probably ought to rerun the checks on the float version and check it is happy with lower L values, may need to look at the param file too and possibly store in uH, using mH with the fixed point only gives 30uH resolution).

That paper is interesting, it's made me think about a few things in a new way. The critical point definition in particular:
critPt.png
critPt.png (4.92 KiB) Viewed 974 times
It would appear that this comes from setting the last two terms of the Vq equation to be equal to zero (and ignoring the voltage dropped across the winding resistance which would be small by comparison):
Vq.png
Vq.png (6.11 KiB) Viewed 974 times
Which backs up the way the model is currently set up (the voltage produced by the wLdId term balances the wx(flux link) term.

Edit - fairly sure that there is an error in that equation, it should be wLdId not WLqIq!

The Fig1 diagram is also interesting:
Fig1.png
It's not quite right for our motors though. Using current parameters gives a critical point of 90mW/160uH = -560A. This means that it is well outside the current limit circle (I'm setting Is to 300A) meaning that we can never fully field weaken the motor which means that the maximum speed will be limited. This again backs up the results that the model is currently giving. The critical point being outside the circle also changes the angle of the optimum trajectory when moving from Mtpa to something else/Mtpv.

Edit - In terms of our current control methodology zone 1 on the plot is arrived at using Mtpa, zone 2 is missing in the simulations as we follow Mtpa all the way to the current limit circle, zone 3 is the field weakening and zone 4 is the throttle limiting.

Edit2 - If we scale Iq and Id in throttle limiting that would give us a trajectory towards the origin, which probably isn't ideal but not sure what we can do that is better without a whole load more maths!

Edit3 - Looking at the graph again initially reducing Iq might be best (intuitively it feels wrong though). This approach would give the highest maximum speed which occurs when Iq = 0 for a critical point outside the current limit circle.

The above all goes wrong though if the critical point is inside the current limit circle though, does this ever happen on our motors? Not too sure would happen in that case but fairly sure it would not be good!

Edit4 - For a critical point inside the current limit circle scaling Iq and Id together would probably be the best approach. Wonder how difficult the maths would be to aim the trajectory towards the critical point, that would work reasonably well in all cases.

Edit5 - Don't think it would be too bad, can probably even avoid any trig and just use scaling. Might give it a go once - going to try simulating a high L motor first though.
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by celeron55 »

Have you thought about the critical point of the high inductance motors?
User avatar
johu
Site Admin
Posts: 5791
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1024 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

Yes, things are starting to repeat, celeron55 called this "characteristic current" search.php?keywords=characteristic&t=1683&sf=msgonly

So for the Prius motor that would be way less, if I remember 90mW and 2 mH, so 45A only!

Also for the first time I see syncadv for the inverse transform in a paper:
grafik.png
grafik.png (14.61 KiB) Viewed 967 times
Look in the upper right corner
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Post Reply