IPM Motor Simulation and FOC Software

Topics about inverter software, improvements and bug fixes. Also release announcements are found here
User avatar
Bigpie
Posts: 1041
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 17 times
Been thanked: 34 times

Re: IPM Motor Simulation and FOC Software

Post by Bigpie »

I've not updated to 5.24 yet, still on 5.20Pete not had chance to workout the critical current value and verify the flux linkage. Will give it a go soon though and try your fix.
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
2x Golf GTE batteries
User avatar
johu
Site Admin
Posts: 4318
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 35 times
Been thanked: 203 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

Pete9008 wrote: Mon Nov 28, 2022 11:37 am I can't quite remember why this block is here but would reducing the frq threshold from 30 to 5Hz be acceptable as it virtually eliminates the problem?
Thanks for checking. The block removes juddering at low speed that I traced down to uq changing sign. When I stopped it from changing sign, the issue disappeared. So again, not super scientific.

I noticed on the Prius motor frequency jumps straight from 0 to 7 Hz because of them resolution limitation (that maybe could be fixed). How about changing it to 10 Hz for now?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Pete9008
Posts: 1152
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 42 times
Been thanked: 126 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

Bigpie wrote: Mon Nov 28, 2022 2:38 pm I've not updated to 5.24 yet, still on 5.20Pete not had chance to workout the critical current value and verify the flux linkage. Will give it a go soon though and try your fix.
The same line of code is there in 5.20, see line 116 on the logging version, so could still be it.
johu wrote: Mon Nov 28, 2022 2:42 pm
Thanks for checking. The block removes juddering at low speed that I traced down to uq changing sign. When I stopped it from changing sign, the issue disappeared. So again, not super scientific.

I noticed on the Prius motor frequency jumps straight from 0 to 7 Hz because of them resolution limitation (that maybe could be fixed). How about changing it to 10 Hz for now?
Was this on the Prius Gen2 or Leaf? If the former could it have been the current offset bug with the intelligent drivers? Can't really think why changing sign should be an issue.

10Hz would be better than 30Hz. You can see on the above plots where is starts to become an issue and even 5Hz doesn't completely get rid of it.
User avatar
Bigpie
Posts: 1041
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 17 times
Been thanked: 34 times

Re: IPM Motor Simulation and FOC Software

Post by Bigpie »

currently

Code: Select all

      qController.SetMinMaxY(dir < 0 ? -qlimit : 0, dir > 0 ? qlimit : 0);
replace with

Code: Select all

         qController.SetMinMaxY(dir <= 0 ? -qlimit : 0, dir >= 0 ? qlimit : 0);
right?

*EDIT* Also is it worth adding release builds to the wiki so more people can play without having to build? Tie the release builds to the OI version?
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
2x Golf GTE batteries
Pete9008
Posts: 1152
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 42 times
Been thanked: 126 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

My preference would be to lose that line completely to allow the controller to always use the full range. The latest code disables the line above 30Hz and my suggestion for now is to drop this frequency as low as possible, but the ideal would be to get rid of it completely.

Really need Johannes thoughts here though as he knows the details of why and when it was added and what the implications of removing it would be.

Edit - sorry, brains not working! I dont mean lose the line, I mean lose the limits by losing the if statement in the new code! In the 5.20 code that line would be replaced by

Code: Select all

      qController.SetMinMaxY(-qlimit, qlimit); 
User avatar
Ev8
Posts: 542
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 18 times
Been thanked: 33 times

Re: IPM Motor Simulation and FOC Software

Post by Ev8 »

Thanks Pete
User avatar
Ev8
Posts: 542
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 18 times
Been thanked: 33 times

Re: IPM Motor Simulation and FOC Software

Post by Ev8 »

ok wow, will have to try another day to install qt as the laptop im currently working on doesn't have a spare 215GB free! lol
Pete9008
Posts: 1152
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 42 times
Been thanked: 126 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

Wow indeed!

Pretty sure my install is nowhere near that. Must be some optional components that can be deselectected. Does it try to install any android support or support for other platforms? If so then they can all be deselected.

Edit - thinking about it the last qt install I did was to a virtual pc and that would have only been 10-20GB total disk space so there must be a lot of stuff that can be left out.
User avatar
Ev8
Posts: 542
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 18 times
Been thanked: 33 times

Re: IPM Motor Simulation and FOC Software

Post by Ev8 »

lol yep just deselecting android drops it to 31gb
Pete9008
Posts: 1152
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 42 times
Been thanked: 126 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

That sounds more like it :)
If it installs previous versions you too can probably lose them too. Fairly sure that features can be added after install if needed but never tried it.
User avatar
Ev8
Posts: 542
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 18 times
Been thanked: 33 times

Re: IPM Motor Simulation and FOC Software

Post by Ev8 »

So I got the sim up and running after the cat woke me up at 5am, all I can say is wow thank you so much, I found settings in half an hour that stopped the over current trip I was getting on mg1, improved oscillation and found more power too! I don’t think I would have found this tune with hrs of on road tuning, it’s close enough to really life to be a complete game changer
Pete9008
Posts: 1152
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 42 times
Been thanked: 126 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

No problem, thanks for the thanks!

Great to hear it seems close(ish) to reality and is being useful :)

If you're into C/C++ it's worth having a play with the Qt debugger. The ability to set break points, step though code and see the value of variables makes it much easier to debug code and understand how the it all works. I know my understanding of the OI code would be a lot worse if I hadn't been able to use it.
User avatar
Ev8
Posts: 542
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 18 times
Been thanked: 33 times

Re: IPM Motor Simulation and FOC Software

Post by Ev8 »

Cool will take a look sometime!
User avatar
Ev8
Posts: 542
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 18 times
Been thanked: 33 times

Re: IPM Motor Simulation and FOC Software

Post by Ev8 »

ok Im struggling with the simulator, despite the first time i used it everything working fine, I now cant build a version that seems to work right, the hrottle reduction trace is missing from motor currents and it seems to not give me the same results twice, ive tried starting completely from scratch but still get the same issue, ive also tried compling in ubuntu using Johannes instructions in his readme but get the error:

/usr/bin/qmake -o Makefile ../IPMMotorSim/IPMMotorSim.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
make: /usr/bin/qmake: Command not found
make: *** [Makefile:563: Makefile] Error 127
MattsAwesomeStuff
Posts: 638
Joined: Fri Apr 26, 2019 5:40 pm
Has thanked: 62 times
Been thanked: 51 times

Re: IPM Motor Simulation and FOC Software

Post by MattsAwesomeStuff »

On the DIY EC forums, the topic of the Toyota Highlander MGR came up (because both the Outlander Hybrid and the IS300H are not sold in North America, but the Highlander Hybrid is).

I went into a bit of detail about why the MGR was abandoned in favor of the Outlander. Something about the MGR being designed for 600v and basically no one could manage to pull decent power out of it. There was some hope that field weakening might change that, but then that kinda flopped IIRC. My memory was too loose to make recommendations.

... Might this simulator and new developments/improvements code-wise help turn the corner on the MGR and why it was getting next to no power? Or, is that deservedly still put to rest as a viable EV platform?
User avatar
celeron55
Posts: 603
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by celeron55 »

I'm going to run tests with MGR in a real car, but cannot spare the time currently as I started another project while waiting for FW development.

My guess is that at 350V it will be possible to get it up to 25kW or 30kW. Previously only about 15kW was possible.
User avatar
Romale
Posts: 223
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 20 times
Been thanked: 8 times

Re: IPM Motor Simulation and FOC Software

Post by Romale »

recently, with the wheels removed, I checked the latest firmware from a voltage of 120 volts (motor leaf gen 2) I tried increasing the fw from -100 to -500. at -500, I got a furious acceleration up to 14000 rpm and was not reset by pressing the brake. even when I turned on the neutral, the speed dropped to 12000 rpm and only stopped the power off for the controller.
I don't know if it's important or not, but I decided to let you know.
If this had happened in motion, my car would have raced like a horse at a speed of 200 + km / h.
At the same time, a limit of 400 Hz is set.
Screenshot_20221129-182644.png
It seems to me that it is very important to get real speed limits from the controller according to the fmax line in all modes. it is especially scary to set up an syncofs, there is always a motor accelerates to breakneck speeds even from 25 volts
evil neodymium :twisted:
User avatar
mjc506
Posts: 336
Joined: Wed Sep 09, 2020 9:36 pm
Location: Wales, United Kingdom
Has thanked: 27 times
Been thanked: 23 times

Re: IPM Motor Simulation and FOC Software

Post by mjc506 »

Romale wrote: Thu Dec 08, 2022 8:07 am
The simulator won't help with setting offsets (but will simulate the effects of a bad offset)

Setting the resolver offset really is a fundamental step, and has to be done right (as you've discovered!), the controller can really do very little to control a motor if it isn't where it thinks it is.
User avatar
johu
Site Admin
Posts: 4318
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 35 times
Been thanked: 203 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

I suppose the speed limiter now needs to be moved/added to the core control loop. It could just ramp down idref and iqref as a final step before entering the controllers. It's probably more graceful to leave the existing limiter in place and set this one at 50 Hz higher or so.

I currently cannot test except in the simulator. I can write some code but someone would need to test it
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
mjc506
Posts: 336
Joined: Wed Sep 09, 2020 9:36 pm
Location: Wales, United Kingdom
Has thanked: 27 times
Been thanked: 23 times

Re: IPM Motor Simulation and FOC Software

Post by mjc506 »

I'm not sure what the current speed limiter actually does, but...
Existing speed limit + 50Hz = hard backoff of currents? (won't help during regen)
Existing speed limit + 100Hz = fault?
Pete9008
Posts: 1152
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 42 times
Been thanked: 126 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

Ev8 wrote: Wed Dec 07, 2022 8:02 pm ok Im struggling with the simulator, despite the first time i used it everything working fine, I now cant build a version that seems to work right, the hrottle reduction trace is missing from motor currents and it seems to not give me the same results twice, ive tried starting completely from scratch but still get the same issue, ive also tried compling in ubuntu using Johannes instructions in his readme but get the error:

/usr/bin/qmake -o Makefile ../IPMMotorSim/IPMMotorSim.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
make: /usr/bin/qmake: Command not found
make: *** [Makefile:563: Makefile] Error 127
Afraid I can't help too much with that. I know you can build Qt projects from the command line but you have to make sure that qmake is run correctly and that all the paths are set up right. I allays build from within Qt and this is the process that works for me viewtopic.php?p=49176#p49176

One thought, have you got the motor and resolver pole pairs set to the same value? For some reason the simulator really doesn't like it if they are set different (should have a look to see why but have never got round to it).
mjc506 wrote: Thu Dec 08, 2022 2:29 pm I'm not sure what the current speed limiter actually does, but...
Existing speed limit + 50Hz = hard backoff of currents? (won't help during regen)
Existing speed limit + 100Hz = fault?
Bit tricky this. When above fmax i's going to be well into field weakening (above base freq) so any hard backoff or shutdown will cause very strong regen as the motor voltage rises uncontrollably. Johannes' ramping of id and iq would probably be a safer approach.
User avatar
Romale
Posts: 223
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 20 times
Been thanked: 8 times

Re: IPM Motor Simulation and FOC Software

Post by Romale »

johu wrote: Thu Dec 08, 2022 2:15 pm I can write some code but someone would need to test it
I am a great master of accelerating motors to huge uncontrolled speeds 8-)

I will be a tester with pleasure
evil neodymium :twisted:
User avatar
mjc506
Posts: 336
Joined: Wed Sep 09, 2020 9:36 pm
Location: Wales, United Kingdom
Has thanked: 27 times
Been thanked: 23 times

Re: IPM Motor Simulation and FOC Software

Post by mjc506 »

Pete9008 wrote: Thu Dec 08, 2022 5:40 pm Bit tricky this. When above fmax i's going to be well into field weakening (above base freq) so any hard backoff or shutdown will cause very strong regen as the motor voltage rises uncontrollably. Johannes' ramping of id and iq would probably be a safer approach.
Certainly be a good rev limiter :-)
User avatar
johu
Site Admin
Posts: 4318
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 35 times
Been thanked: 203 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

Indeed, I think it will only step in effect when either your syncofs is far out and ud creates way too much accidental iq OR your freewheeling the motor in which case the unwanted regen wouldn't hurt much. Still, ramping is more gradual and would ultimately also result in killing off field weakening.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
arber333
Posts: 2721
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 25 times
Been thanked: 49 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by arber333 »

johu wrote: Thu Dec 08, 2022 2:15 pm I suppose the speed limiter now needs to be moved/added to the core control loop. It could just ramp down idref and iqref as a final step before entering the controllers. It's probably more graceful to leave the existing limiter in place and set this one at 50 Hz higher or so.

I currently cannot test except in the simulator. I can write some code but someone would need to test it
Hi J

I can offer to test some further hgh speed OI functionality. That would be a good project during winter if you like.
My hardware:
1.Hyundai HSG motor with resolver setup. Now this is very approprite fo testing. It has a belt drive that i could connect to some load. I can use my Volt inverter and gen2 OI board

2. I could just buy another HSG and use its belt drive to get into singularity... minus the friction losses :). Seriously the more i think about it the more logical this step seems.

3. I have 360Vdc 9kW VW Passat battery in my workshop perfect for experimenting. I already setup my car simulator so i can connect OI as in any car with throttle pedal precharge and contactor.

4. As for the serial connection i have both wifi ESP module and TTL cable.

It would be a small setup and not much expenses invested for potentially huge gains:).
I am not a software engineer and high math problems can be confusing so i would leave firmware solutions to you. You can give me instructions which parameters to observe during testing.
Post Reply