IPM Motor Simulation and FOC Software

Topics about inverter software, improvements and bug fixes. Also release announcements are found here
User avatar
SciroccoEV
Posts: 347
Joined: Thu Oct 10, 2019 1:50 pm
Location: Luton UK

Re: IPM Motor Simulation and FOC Software

Post by SciroccoEV »

Pete9008 wrote: Wed Nov 16, 2022 8:07 pm Was about to order this but just checked and it would be coming from the USA - £33.58 delivery :o so think I'll leave it!
If I can find room to set up my book scanner, I'll scan some of the more interesting chapters.
Pete9008
Posts: 851
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 1 time
Been thanked: 5 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

SciroccoEV wrote: Wed Nov 16, 2022 8:14 pm If I can find room to set up my book scanner, I'll scan some of the more interesting chapters.
Thank you for the offer! The main thing that I'm interested in is the derivation of the IPM motor equations, in particular where the wLdId and wLqIq terms come from. If it has anything related to those then I would be very interested in seeing just those bits?

I think I know where they come from. We treat Ld and Lq as if they are separate, and they are for a stationary motor. The trouble is some of the flux that contributes to them is in the rotor and some in the stator. The bits in the rotor move with it so effectively stay with Ld or Lq as it rotates. The bits that are in the stator (the majority) don't move though so as the motor rotates the bits that were associated with Lq become part of Ld and vice versa. I think this is where those terms come from. What surprises me is that they are that simple, I would have expected something much more complicated, and so I'm keen to know whether the equations we are using are approximations of whether the maths really does does all cancel down to something that elegant?
Pete9008
Posts: 851
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 1 time
Been thanked: 5 times

Re: IPM Motor Simulation and FOC Software

Post by Pete9008 »

Thought it would be usefull to capture my thoughts on future enhancements for the simulator while it's fresh in my mind. I'm unlikely to get to any of these for a little while but at least if they are posted here I'm less likely to forget about them.

In a vague order of implementation:
  1. Logged data import and comparison - essentially allow the import of logged inverter data (ESP32 high speed log only). This would pop up another window which would allow a file to be selected, it would then run the logged motor voltage data through the motor model and correlate the results against the logged current data. Optionally it would allow a monte carlo style multiple run analysis to search for better matching motor parameters.
  2. Motor Loss Modelling - At the moment the simulator reports motor shaft power. By also calculating electrical power going into the motor it would be possible to calculate and plot motor efficiency.
  3. Inverter Modelling - Desat - At the moment there is no current limiting in the model, infinite currents are allowed! It would be better to have a configurable threshold at which point a likely desat event is flagged and the simulation paused.
  4. Inverter Modelling - Losses - At the moment the inverter is considered lossless. It would be possible to calculate the IGBT/diode voltage drops and IGBT switching losses and use these to reduce the DC bus voltage that is available to the motor. There is an accurate way and a simple way to do this. The accurate way is to break each control loop period down into the individual phase switching events and then run the motor model for each of these states. The simple way is to pro-rata the IGBT/diode voltage drops based on PWM value. The accurate way will give very good results but slow down the simulation. The simple way is likely to be 80-90% accurate and have no real impact on simulation speed. Not sure which way to go but probably the simple one. Either way switching losses would just be based on PWM frequency, configurable IGBT turn on/off times and estimates of average current decay profiles.
  5. Battery Loss Modelling - Very simple approach, just allow the battery internal impedance to be entered and use this to calculate a voltage drop and power loss.
1. is mainly to see if we are using the right motor parameters.

2. 3. 4. and 5. are more to improve the realism of the simulation but also to allow the effect of different mtpa/mtpv schemes, particularly on efficiency, to be evaluated.

Really should also add some sanity checks on data entry fields and possibly allow changes to inverter parameters to be persisted across program restarts (rather than just reinitialising from the param_prj.h file each time - a button would also be needed to allow a manual refresh from the file though.

Any other ideas, or differing views on priorities, please let me know.
User avatar
johu
Site Admin
Posts: 4130
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 8 times
Been thanked: 71 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

Thumbs up on the above.

Got an early forum release for you
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: 4130
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 8 times
Been thanked: 71 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

Prius likes over modulation very much! Cranked up modmax to 44000 and went for a drive
overmod.png
So when we do (iq * uq + id * ud) / FOC::GetMaximumModulationIndex() we arrive at 43000*90/44000=88A DC (because uq=0) and that is pretty much what I saw on my power meter. So now I can maintain 30 kW across the constant power region.

I think on the next release I will made modmax a parameter that defaults to 2/sqrt(3)*32768 and can be increased up to... 45000 or so. Then by default over modulation is off and maybe brought in
Attachments
stm32_foc.bin
(47.81 KiB) Downloaded 4 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
SciroccoEV
Posts: 347
Joined: Thu Oct 10, 2019 1:50 pm
Location: Luton UK

Re: IPM Motor Simulation and FOC Software

Post by SciroccoEV »

johu wrote: Wed Nov 23, 2022 1:55 pm Prius likes over modulation very much! Cranked up modmax to 44000 and went for a drive

How about going to six step?
User avatar
johu
Site Admin
Posts: 4130
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 8 times
Been thanked: 71 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

SciroccoEV wrote: Wed Nov 23, 2022 2:15 pm How about going to six step?
That's pretty much what it is. I reckon crank the amplitude up even higher, that's where you'd arrive. Don't know by how much though

EDIT: see waveform here https://openinverter.org/forum/viewtopi ... 638#p48638
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
Ev8
Posts: 443
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 4 times
Been thanked: 5 times

Re: IPM Motor Simulation and FOC Software

Post by Ev8 »

Hmm gen2 inverter likes over modulation, makes you wonder if thats the intelligent gate drives doing something interesting, it would be interesting to go full square wave on the inverter input and scope the output
User avatar
Bigpie
Posts: 978
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 4 times
Been thanked: 4 times

Re: IPM Motor Simulation and FOC Software

Post by Bigpie »

Some way of simulating a syncoffs error would be nice to have, both for simulating the affect and potential for developing code to auto tune.

Edit, just noticed it's already a parameter :D
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
2x Golf GTE batteries
User avatar
Ev8
Posts: 443
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 4 times
Been thanked: 5 times

Re: IPM Motor Simulation and FOC Software

Post by Ev8 »

I can confirm that the Prius gen2 inverter does indeed love a bit of over modulation… I’ve now seen for the first time over 300amps on the dc bus, (twin motors remember) however I did once trip mg1 inverter and instead of it restarting and resuming as normal when lifting off the pedal it restarted with the motor chattering which persisted even when stationary…this stoped after a proper key off restart
User avatar
Romale
Posts: 201
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 4 times
Been thanked: 1 time

Re: IPM Motor Simulation and FOC Software

Post by Romale »

is this release useful only for Toyota motors with high inductance, or will the latest official firmware be better for Nissan too?
evil neodymium :twisted:
User avatar
johu
Site Admin
Posts: 4130
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 8 times
Been thanked: 71 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

It should squeeze more power from the Nissan also, but I haven't tested. For me Nissan is already powerful enough without it, I even don't max out the inverter (throtcur could be 6.5 but I set it to 5.5)
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
Bigpie
Posts: 978
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 4 times
Been thanked: 4 times

Re: IPM Motor Simulation and FOC Software

Post by Bigpie »

What sort of figures are high inductance vs low inductance? I'd assume my motor (0.1mH to 0.3mH) is low inductance?
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: 4130
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 8 times
Been thanked: 71 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

I guess it's a pretty arbitrary classification and practically also linked to flux linkage. I'd say a motor whos base speed is below 150 Hz or so needs strong field weakening more than a motor whos base speed is above that.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
Bigpie
Posts: 978
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 4 times
Been thanked: 4 times

Re: IPM Motor Simulation and FOC Software

Post by Bigpie »

Trying to build with the 5.24R but struggling:

Code: Select all

/Users/jamiejones/open-inverter/IPMMotorSim/build-IPMMotorSim-Qt_6_3_2_for_macOS-Debug/pwmgeneration.o:-1: error: Undefined symbols for architecture x86_64:
  "PwmGeneration::slipIncr", referenced from:
   PwmGeneration::SetFslip(int) in pwmgeneration.o
   PwmGeneration::CalcNextAngleAsync(int) in pwmgeneration.o
   PwmGeneration::CalcNextAngleConstant(int) in pwmgeneration.o
any ideas? Tried different QtKits but I'm not vary familiar with Qt. pwmgeneration.cpp does contain them definitions.
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
2x Golf GTE batteries
User avatar
Romale
Posts: 201
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 4 times
Been thanked: 1 time

Re: IPM Motor Simulation and FOC Software

Post by Romale »

johu wrote: Thu Nov 24, 2022 10:56 am ...needs strong field weakening more...
in firmware 5.20, it was intuitively clear how to disable the weakening completely and it worked. in new firmware, to completely disable, fwcurmax you need to put -1000 or 0
evil neodymium :twisted:
User avatar
johu
Site Admin
Posts: 4130
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 8 times
Been thanked: 71 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

Bigpie wrote: Thu Nov 24, 2022 1:59 pm Trying to build with the 5.24R but struggling:

Code: Select all

/Users/jamiejones/open-inverter/IPMMotorSim/build-IPMMotorSim-Qt_6_3_2_for_macOS-Debug/pwmgeneration.o:-1: error: Undefined symbols for architecture x86_64:
  "PwmGeneration::slipIncr", referenced from:
   PwmGeneration::SetFslip(int) in pwmgeneration.o
   PwmGeneration::CalcNextAngleAsync(int) in pwmgeneration.o
   PwmGeneration::CalcNextAngleConstant(int) in pwmgeneration.o
any ideas? Tried different QtKits but I'm not vary familiar with Qt. pwmgeneration.cpp does contain them definitions.
Almost seems like a CONTROL=FOC directive missing somewhere.
EDIT: no, it's probably because it's a debug build it doesn't dismiss unused functions. May nee to copy the definition of uint16_t PwmGeneration::slipIncr; from pwmgeneration-sine.cpp to pwmgeneration.cpp
Romale wrote: Thu Nov 24, 2022 2:24 pm in firmware 5.20, it was intuitively clear how to disable the weakening completely and it worked. in new firmware, to completely disable, fwcurmax you need to put -1000 or 0
-1000 to disable? nooooo. 0 it is
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
Bigpie
Posts: 978
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 4 times
Been thanked: 4 times

Re: IPM Motor Simulation and FOC Software

Post by Bigpie »

Screenshot 2022-11-24 at 4.27.02 pm.png
Looks to be already there.
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: 4130
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 8 times
Been thanked: 71 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

That's just the declaration, doesn't allocate memory
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
Bigpie
Posts: 978
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 4 times
Been thanked: 4 times

Re: IPM Motor Simulation and FOC Software

Post by Bigpie »

Code: Select all

uint16_t PwmGeneration::slipIncr;
In pwmgeneration-foc.cpp, as you said :D
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
2x Golf GTE batteries
Post Reply