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 »

Thanks, will have a play and see what the simulator says.

Are you using the latest values from the calculator for flux linkage and L in both the sim and on the car? Did the bigger Icrit value fix all the issues you were having?
User avatar
Ev8
Posts: 801
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 41 times
Been thanked: 149 times

Re: IPM Motor Simulation and FOC Software

Post by Ev8 »

Yes I’m currently running all the latest calculated values and yes raising the icrit on mg2 anywhere above 120a I have no more unwanted regen
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

Well I have followed the wikipedia pages as close as I can think of and have things happening :).

Waveforms are not the same as in wikipedia, I have attempted to make all the settable parameters exactly the same:
image.png
Thank you all!
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 »

Looks like you're getting there :)

There are a couple of things that don't quite look right though. In particular the discontinuity you have at around 5sec and the sudden appearance of the phase currents in the Motor Currents graph at that point. The trajectory on the Operating Point graph also looks wrong.

This is what I get with a clean github checkout of the simulator and the last OpenInverter FOC specific build (777271e - Nov 27, 2022) which is what I'd expect to see with those settings:
StdRun.png
Wondering whether some of the recent sin changes could be having an impact? I'll update my version of the OpenInverter firmware to include them and give it another try.

Edit - Nope, just updated to the latest (git tag 6ff84fc) and I get exactly the same result. Only thought - was your plot from a single simulator run or did you run it to 5sec and then change settings/parameters before running again (but without hitting Restart first)?
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

You really are a marvel Pete9008:
image.png
Now I can try all sorts of things :)

Kind regards!
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 »

Had a thought about stability last week while pondering on the differences between simulation and reality highlighted in this thread viewtopic.php?p=53773#p53773.

It's occurred to me that the Ld and Lq values that we are using are right for the motor model, and reproduce the motors torque/power/FW behaviour correctly, but aren't the whole story. The magnetising/leakage inductance (not sure what the correct term is when referring to motors) of the motor is missing. This is the bit of the inductance that doesn't couple to the rotor and so has no real effect on the motor power/torque/FW but it does still affect how quickly the motor current changes in response to external voltages. This could explain why the simulation appears less stable than reality. In real life the leakage inductance will slow the rate of change of current so reducing ripple current and also increasing control loop stability.

Would appreciate any thoughts on this?

If the above is correct then the easiest fix would just be to add an extra motor parameter to the simulator for the leakage inductance. This could then be used to work out a fudge factor for the current delta produced from the Ld and Lq terms.

Note - the above would also explain why the inductance values calculated using the calculator (viewtopic.php?t=3047) tend to be a bit lower than those from a physical measurement using a LCR bridge (the former are pure Ld/Lq while the later includes leakage inductance).

Edit - it's also occurred to me that the calculator could potentially be modified to also work out the leakage inductance too, might give it a try later (it might also explain why the match between the modelled and real data in the calculator was never quite as good as was hoped).

Edit2 - Nope, the calculator can't measure it. The effect of leakage inductance on the values logged is relatively small and is swamped by the noise in the system (idea should work but would need much better quality data). Doing the testing has convinced me that it has the effect outlined above though. Next time I'm working on the simulator I may try adding a leakage inductance term to get a better handle on how much is needed to improve loop stability.
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

This leakage inductance would be a fairly small number for high inductance motors, but may be a lot more important for low L motors I presume?
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

I think there is value in boost converters for high L motors. To me it seems the higher the battery/boost voltage the more efficiently the motor can run (apart from extra losses in the boost system).

Limits of boost system are: current boost inductor and IGBTs can handle, and I think power capability of inductor.

If I am right, algorithm for control could be: As current through Boost inductor approaches current limit, raise boost voltage. Upper limit will be boost power limitation.

Secondly, if a boost inductor system is good for 20kW, it boosts voltage from say 200V battery voltage to say 400V, at 100A.
BUT, battery supplies 200V at 100A or 20kW itself. THEREFORE, total power supplied is 20kW+20kW = 40kW.

Does this look right?
User avatar
Romale
Posts: 441
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 204 times
Been thanked: 45 times

Re: IPM Motor Simulation and FOC Software

Post by Romale »

johnspark wrote: Sun Mar 26, 2023 9:46 pm
BUT, battery supplies 200V at 100A or 20kW itself. THEREFORE, total power supplied is 20kW+20kW = 40kW.

Does this look right?
No. this is not right. if 200 volts and 100 amperes (20 kW) are taken from the battery and increased to 400 volts, then the power in the motor will come less than 20kW. (in ideal conditions, it would be the same 20 kW = 400 volts and 50 amps) It's all about the efficiency of the converter. it is always below 100%. for example, the efficiency of a step-up inverter is 90%, which means that from 20 kW there will be 18 kW for the motor. at 400 volts, it will already be less than 50 amps.
evil neodymium :twisted:
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

Thank you Romale, I will think about this a bit more...
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 »

johnspark wrote: Sun Mar 26, 2023 9:41 pm This leakage inductance would be a fairly small number for high inductance motors, but may be a lot more important for low L motors I presume?
Been thinking about this a little more. Although normally inductors are designed to minimise leakage inductance there are exceptions where having teh leakage inductance is actually useful - I'm wondering if motors are one of those exceptions. I think the leakage inductance is what is used as part of the switch mode converter inherent in PWM motor drive and is what allows things like regen below base frequency to work (where the inductance is used to boost the bemf up to battery voltage). It also helps smooth the ripple current produced by the PWM. On low inductance motors (e.g. Outlander) having a bit more leakage inductance than you might expect allows Lq and Ld to remain low, so allowing higher motor speeds, while keeping some of the benefits that higher inductance gives (lower ripple, greater loop stability.

Once I've got mine running I need to take some measurements to get a better feel for it.
johnspark wrote: Sun Mar 26, 2023 9:46 pm I think there is value in boost converters for high L motors. To me it seems the higher the battery/boost voltage the more efficiently the motor can run (apart from extra losses in the boost system).

Limits of boost system are: current boost inductor and IGBTs can handle, and I think power capability of inductor.

If I am right, algorithm for control could be: As current through Boost inductor approaches current limit, raise boost voltage. Upper limit will be boost power limitation.

Secondly, if a boost inductor system is good for 20kW, it boosts voltage from say 200V battery voltage to say 400V, at 100A.
BUT, battery supplies 200V at 100A or 20kW itself. THEREFORE, total power supplied is 20kW+20kW = 40kW.

Does this look right?
I agree completely that there is potential in the boost converter, that's why Toyota put it there :)

Also agree with Romale that you can only get out what you put in so when boosting 20kW in (100A @ 200V) must equal 20kW out (50A at 400V - or a little less allowing for losses).

I find the easiest way of thinking about the way the boost circuit works it is that the inductor is always trying to carry a fixed, unchanging current, that's what inductors do. In the ideal case with infinite inductance this will be the case, in the real world with smaller inductance you will get a ripple current around the average level. The actual current being carried will depend on the load and boost ratio. With no boost the circuit can be considered straight through (low side IGBT never on), the input and output voltages are equal and the input current = inductor current = output current. As the boost ratio increases, and the lower IGBT starts to switch on this will change. When the lower IGBT starts to turn on it effectively shorts the inductor between the input and ground which will cause the inductor current to increase. When the lower IGBT switches off the inductor will try to maintain the increased current flow, it does this by generating a flyback voltage which increases the output voltage which maintains the flow of current into the load. The result of this is that the output voltage rises. You will notice that to achieve this the input current has increased which means the input power has also increased.

The other complication is that while the lower IGBT is on the input is NOT transferring any power directly to the output, the output capacitor has to maintain the output during this period. Now as the lower IGBT on time increases this effect gets worse. Say you have got to the point where half the time is spent with the lower IGBT on, or charging the inductor, and the other half with the lower IGBT off and the inductor discharging to the output. In this state the output capacitor must support the output current for half the time. This means that during the other half of the time the inductor must be supplying both the output current and replacing the power that the output capacitor is using. In effect the inductor current must be twice the output current. So in the example above to get 50A out at 400V you need an average inductor current, and input current of 100A.

Based on internet reading the inductor seems to be rated at 100-120A so with the standard Toyota battery of 200V it can handle around 20kW. If the input voltage was increased to say 380V (96s) it should be able to handle maybe 40kW which for motors like the MGR or Prius may well be worthwhile having? If doing this you would need good control of the boost converter though. If it's response was too slow it would be very easy to over volt the inverter when motor load changes.
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

Thank you Pete9008, perhaps we can think of the boost inductor system as a transformer in the AC world so power in is power out, but we can double output voltage at expense of output current being only 1/2 the input current.
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

I have made an LTspice XVII model, and have put one graph on the forum:
image.png
Operation is more complicated than I thought it would be.

I have included the file as well below.

So far my model only has equal mark / space ratio, but battery voltage and parameter values can be changed.

If anybody wants to, we can explore what this model can do for us with boost.

With this nonlinear stuff, sometimes it is better to use simulation models rather than maths I find.

Kind regards

Johnspark.
Attachments
AVV50xCamryBoostConverter.zip
(1.04 KiB) Downloaded 61 times
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 »

Good idea, that looks interesting :)

Need to install LTspice before I can have a play (used it a lot in the past but never got round to installing on Linux).

All looks to make sense but can't quite see what is causing the oscillation in the input current on the RHS of the plot, guessing the inductor and input/output capacitors could be resonating a little? Might be worth also plotting the inductor current to check? If it is then including a little bit of series resistance in the inductor might help clean it up (increase damping/reduce Q).

Not sure you need the flip flop. If you drive the sig gen straight into the buffer you should be able to use the sig gen parameters to set the duty cycle.
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

Will try these things Pete9008 .
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

Today I was able to measure the inductance of a MG1 generator from a Prius V2. Please note, I did not turn the shaft for these measurements.

Here are the values,
These measurements are across 1 phase and the other two phases placed in parallel.
M1 = 2.2mH
M2 = 1.2mH
M3 = 2.2mH.

Using your formulas Pete9008, I get:
La = 0.6mH
Lb = 0.6mH
Lc = 1.6mH

All at 1kHz, using a LCR meter DE-5000.

Resistance values measured were not realistic (~1-2 ohms) so are not recorded here.

I also measured phase to phase and got the following 3 values:
2.2mH
2.2mH
4mH

Also at 1kHz.
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

i took your advise Pete and got rid of the D flip flop. But found I could replace it and the buffer with a schmitt buffer. Now I am getting sensible results. For a 250V battery and approx 500V output, current from battery is approx double that going to load resistor.

Also that saw tooth waveform superimposed on the carrier is gone :).
image.png
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

I can also adjust mark space ratio by adjusting +/-DC offset of sinewave generator. So model becoming more realistic and simpler.
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

This model now has adjustable mark/space ratio via the adjustable battery.
Very happy with this model, it can be adjusted, and gives realistic values :).

For this example, I have 3 different mark space ratios for initial conditions, to reduce the large inrush current (slows down speed of getting HV).
image.png
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 »

Looking good :)

Thanks for posting the Prius MG1 data, been hoping to do a bit of simulation to see what it might be able to do for a while now.

I was wondering what to do about the power up current surge as it could saturate the inductor but your soft start does a good job of controlling it.

Might be worth having a look at using the PULSE function instead of SINE for the sig gen. If you give it a Tperiod it generates a continuous stream of pulses rather than a single pulse. You can either use it either with zero rise and fall times and use the Ton argument to control the dutycycle to get a square wave or use Trise and Tfall to generate a sawtooth or triangle waveform to do the kind of control you have above (but more linear). I suppose the next step would then be adding a feedback loop and a comparator to control the switching point based on output voltage to have a fully regulated model?

What's the goal here, are you looking to use it to boost the voltage to the inverter to drive the motor?

Might also be worth starting a separate thread for it to make it easier to find?
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

So what I am doing, is using Prius Gen 2 MG1 and MG2 with 5 speed manual gear box, with up to 350 V battery, and AVV50R inverter. So need to use the boost converter. My car is an E39. Yes I know, far too heavy etc. Its about history. When I started it was about looking for a 13 inch DC motor, or $30k AC motor and I didn't want that. Then thought about 11 inch DC motor but decided I don't like that, and wanted some sort of regeneration possibilities. If I started now would use better suited motor. (Wife has had 10 operations in 5 yrs so life is more about being a carer than EV enthusiast).
So way I will proceed, is use boost converter as resistor during traffic light start, and boost inductor at higher RPMs. I intend putting higher voltage into boost mode than original Gen 2 inverter, AVV50 goes up to 600V I think, (maybe creep up to 550V). I am sure windings will take it. May put my 1000 volt Megger on windings to check it sometime...
If car is too sluggish or converter burns out, will do Romale trick and rewind MG2 for double winding thickness and 1/2 voltage needed, so 350 V battery and no boost will work based on other threads here. [I have access to a motor re-winder or will do myself, have a motor repair book by Rosenberg to help if necessary and also Romale :)].

For this simulation exercise, I wish to make boost converter dance for the above, but also, get boost converter to dance for off grid converters etc.
So like you idea Pete of the comparator. I do have a paper about using variable DC voltage for the inverter, so perhaps will post here or new boost converter site thingy.

My project unfortunately will be the test case for using MG2 and MG1 together, use 50V more than the original Gen 2, the boost converter via Toyota serial bus with zombieverter, and viability of Prius Gen 2. Whoa, feeling a bit giddy.

So intend to start another thread just about boost converters.

Kind regards to all who spent time reading this).
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

I would like to start a boost converter simulation topic under Software, but cannot find a 'New topic' button, would someone please start one for me,

Kind regards,

Johnspark
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 »

Sorry to hear about your wife's health, hope the operations are helping.

If you are using both MG1 and MG1 you might not need the boost converter. Johannes has seen, I think, 40kW peak from MG2. This currently drops off with speed but I'm hoping that some of the MTPV work will help maintain this at say 30kW. Hopefully MG1 can contribute around half this which would then give 60kW peak dropping to 45kW at speed (around 80bhp dropping to 60bhp), not massive but should be enough to be usable. I need to get back to the MTPV stuff but having a few health issues of my own at the moment so productivity has dropped massively. Without the MTPV the boost converter should allow around 42kW to be maintained with the standard code.

Regarding the new topic you need to drop down into one of the sub-forums, a New Topic button should then appear at the top left of the thread list.
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: IPM Motor Simulation and FOC Software

Post by johnspark »

Thank you for your thoughts Pete9008. Sorry about your health issues.
Sounds very interesting about not needing the boost converter. Reduces the complexity quite a bit.
User avatar
Ev8
Posts: 801
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 41 times
Been thanked: 149 times

Re: IPM Motor Simulation and FOC Software

Post by Ev8 »

Can I ask how you plan on connecting a Prius transaxle to a 5 speed gearbox? (I have done this with a Lexus rx400h transaxle it’s no small undertaking! I would advise a simpler route)
Also using the boost inductor is going to seriously limit potential power output,
Post Reply