IPM Motors - MTPV

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 Motors - MTPV

Post by johnspark »

Perhaps this one Pee9008 will help with some of the understanding required here:


I did look for other MTPV papers, but most are not readily available, the reader has to ask for the paper.
Attachments
1-s2.0-S2405896318334931-main.pdf
(775.56 KiB) Downloaded 49 times
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motors - MTPV

Post by Pete9008 »

johnspark wrote: Sun Jan 22, 2023 5:34 am Perhaps this one Pete9008 will help with some of the understanding required here:
This is the paper that I was originally hoping to base the MTPV on but when I stated looking at it I noticed that the MTPA equations it uses are different to the Mathworks ones we already use successfully so stuck with the Mathworks MTPV equations too. I might try spreadsheeting this papers equations to see if they are any better.
This one looks interesting, it uses a slightly different way of doing it. Again, worth spreadsheeting to see what it looks like.

Thanks for those :)

I got a little further with a pseudo MTPV approach. It tries to produce the same operating point path without all the MTPV equations. It does need an integer square root doing in the main control loop which I'm not too keen on, @johu - what do you think?

Is=200A:
PseudoMTPV_200A.png
Is=100A:
PseudoMTPV_100A.png
The Ifw trace is not fw any more, it would be best thought of as a MTPV offset which moves the motor more towards reluctance torque when it runs out of Vd. Not tried this approach on a low inductance motor yet. Note both these are WITHOUT over-modulation so there should be a bit more performance available on top of this.

So virtually identical performance to the previous MTPV result but they also work properly in regen. There is a stability issue if the speed is pushed too high, around 500Hz for the motor parameters above. Not sure this is any worse than the current fw implementation but I'd like to improve it a little if possible. If the speed is kept below this it seems to work well.

Think I'll spreadsheet the approaches from the papers above and if either looks better try coding them up. Otherwise I'll stick with the pseudo approach.
User avatar
Ev8
Posts: 801
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 41 times
Been thanked: 149 times

Re: IPM Motors - MTPV

Post by Ev8 »

might this explain why i used to find an increase in performance (on an older firmware version) by advancing the syncof value or adding large snynadv I was moving timing towards the reluctance torque
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motors - MTPV

Post by Pete9008 »

Great point :)

Hadn't thought it about it like that but yes that's pretty much exactly what you would have been doing!

Edit - Although did you get more torque with the adjusted old firmware than you do with the new firmware? If yes then this is what you were doing, if not then possibly not.
User avatar
Ev8
Posts: 801
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 41 times
Been thanked: 149 times

Re: IPM Motors - MTPV

Post by Ev8 »

Yes that firmware made more torque advanced, hard to compare it to the current firmware As I’m running over modulated, and the new firmware is much better above base frequency than the old was anyway.
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 Motors - MTPV

Post by johnspark »

Pete9008 wrote: Sun Jan 22, 2023 11:27 am Think I'll spreadsheet the approaches from the papers above and if either looks better try coding them up. Otherwise I'll stick with the pseudo approach.

Here are links to two PID loop simulators in Excel that may be of help to you Pete9008:
Attachments
PID Loop tuning SpreadSheet .xls
(47.5 KiB) Downloaded 54 times
pid.xls
(156.5 KiB) Downloaded 43 times
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motors - MTPV

Post by Pete9008 »

Finally got round to having another look at this. It's still not proper MTPV but seems to provide similar benefits.

I've run simulations on three motor types we have good data for. The high inductance (MGR), medium inductance (rx400h MG2) and low inductance (Outlander front generator).

In the plots below the MTPV algorithm is on the left and 5.24r is on the right. Overmodulation is not used on either algorithm.

First the Outlander:
OutlanderGenerator_350A.png
The inductance on this motor is so low that it never makes it into field weakening, even at the top end of 8krpm. Because of this the MTPV changes have no effect at all. A little above 8krpm both the standard and MTPV firmware become unstable.

Next the rx400h MG2:
rx400h_MG2_400A.png
The MTPV code does seem to help here. Peak power lifts from 54kW to 67kW and the power stays up longer ending at 51kW for the MTPV vs 42kW for the standard code. I've not done exhaustive tests but stability on both seems very similar. I did have to drop Icrit a little on the MTPV version to compensate for the relatively low PI gains and so pull the Id down to the right level. Increasing the gains would be a better solution but limits stability at higher speed (on both MPTV and standard versions) so the choice here depends on what top speed is needed.

Finally the MGR:
MGR_100A.png
Again the MTPV code does seem to help. Peak power lifts from 18kW to 22kW and the power stays up longer ending at 17kW for the MTPV vs 13.5kW for the standard code. Again I've not done exhaustive tests but stability on both seems very similar.

Overall, on motors operating in FW, the MTPV code gives between 20% and 25% more power so seems worthwhile. Stability looks fairly similar but more tests are really needed.

The code is in a state where it should be ok to run on real hardware but it is completely untested on real hardware. Before using in real life it needs more simulations to check that it is as stable as the existing code on the target motor, both for high speeds and in regen. Execution speed would also need verifying (to check it still runs fast enough) on real hardware. If anyone fancies taking this on then let me know, otherwise I'll keep hold of it until I've at least been able to test the floating point version of it on my hardware.
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: IPM Motors - MTPV

Post by johu »

Quite impressed, will see if I get the chance to test on A2.

Where is the code? Didn't seem to reside on the MTPV branch on your github.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
Ev8
Posts: 801
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 41 times
Been thanked: 149 times

Re: IPM Motors - MTPV

Post by Ev8 »

Awesome stuff, I’m happy to test if your happy to post of send a .bin?
I’d also be interested in testing a version with over modulation as well
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motors - MTPV

Post by Pete9008 »

I'd forgotten to do the Leaf motor:
Leaf_400A.png
So again, increases peak from 87kW to 110kW.

The problem is what happens if you push the speed up too far:
Leaf_400A_unstable.png
With the standard code the loops go unstable but the car just stops accelerating (flat line on the simulation trace). On the MTPV code the loops go unstable at the same speed but instead of ceasing accelerating you get massive currents and massive deceleration, broken driveshaft time or worse.

The loss of control, when it happens, seems more severe with the MTPV code. I assume this is because with the motor being pushed that bit harder there is less margin for error?

Because of this I think I'm going to hold off releasing the code until I've had a chance to think about this a bit more :(
User avatar
Ev8
Posts: 801
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 41 times
Been thanked: 149 times

Re: IPM Motors - MTPV

Post by Ev8 »

Ok fair enough! I can see a sudden oscillation between positive 250nm and negative 300nm is going to break something! Still an exciting prospect seeing as I don’t use more than 4.5krpm so always within the stable region!
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motors - MTPV

Post by Pete9008 »

Ev8 wrote: Tue Feb 28, 2023 10:05 pm Ok fair enough! I can see a sudden oscillation between positive 250nm and negative 300nm is going to break something! Still an exciting prospect seeing as I don’t use more than 4.5krpm so always within the stable region!
That's the standard code, the MTPV is the one going from -11,000,000Nm to +11,000,000Nm :shock: (obviously impossible IRL but still not good!)
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: IPM Motors - MTPV

Post by bexander »

This is great!
I can do some more tests in first the sim and, if everything checks out, test on real HW as well.
User avatar
Ev8
Posts: 801
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 41 times
Been thanked: 149 times

Re: IPM Motors - MTPV

Post by Ev8 »

Oh yes sorry I got mixed up , makes me want to get another rx400 gearbox and build a bench setup to test what actually happens when you push it passed the stable region in real life!
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motors - MTPV

Post by Pete9008 »

Ev8 wrote: Tue Feb 28, 2023 10:05 pm Ok fair enough! I can see a sudden oscillation between positive 250nm and negative 300nm is going to break something! Still an exciting prospect seeing as I don’t use more than 4.5krpm so always within the stable region!
Thinking about it I hadn't noticed that, I'd just seen the simulation trace running at a steady speed and assumed it was a fairly benign failure mode but you're right a 600Nm oscillation isn't going to do anything much good even if the average torque is zero!

Fairly sure that the instability is nothing to do with the new code since it breaks at the same point on both the new and old code. Whatever I change I don't seem to be able to get a simulation to go much above 550Hz (electrical, 8000rpm with 4 poles). Have a feeling I'm missing something obvious here.

Question - what's the highest electrical speed anyone has successfully run a IPM motor using OpenInverter in real life (or simulation for that matter)?
User avatar
Bigpie
Posts: 1586
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: IPM Motors - MTPV

Post by Bigpie »

I regularly go over 8k rpm, pretty sure I've have 12 to 13k rpm in on of my logs.
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motors - MTPV

Post by Pete9008 »

Bigpie wrote: Wed Mar 01, 2023 12:38 pm I regularly go over 8k rpm, pretty sure I've have 12 to 13k rpm in on of my logs.
Could you post your parameters? I'd like to try simulating that.
How many poles is your motor?
User avatar
Bigpie
Posts: 1586
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: IPM Motors - MTPV

Post by Bigpie »

params (8).json
(1.47 KiB) Downloaded 63 times
These are my current params, it's 4 pole pairs.
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motors - MTPV

Post by Pete9008 »

Bigpie wrote: Wed Mar 01, 2023 1:01 pm params (8).json
These are my current params, it's 4 pole pairs.
Thanks, just tried that in the simulator, not sure whether I'm using the right Ld and Lq as they don't quite match your lqminusld value but they are the ones from the calculator so hopefully pretty representative.

The simulation starts to go unstable at 612Hz or 9180rpm (can just about get up to 10500rpm before it completely loses it). Would you say you have revved it that high with the 5.24r code? Could the higher speeds have been with an earlier version?

Here is a plot showing Vq and Iq at the point it loses it (Vd and Id are very similar):
Outlnder_instability.png
It's pretty clear that there is a 180degree phase shift there which explains the instability. The oscillation frequency is around 740Hz (period of 1.35ms) so a little surprised that the loops can't keep up with it. Need to do a bit more digging.

Edit - Anyone out there who is good at control theory? This is now a bit beyond me. My standard approach would be either to reduce the phase shift or reduce the gain at the problem frequency. Trouble is the phase shift is fixed by the motor inductance, control loop period and latency so can't be changed. The gain is already so low that control authority is a little marginal so can't drop much more. The approach I always hear is add a zero to the loop transfer function and I can just about understand what it's getting at but haven't a clue how to do it here. Fairly sure that the zero would also need to be tuned to the specific motor/inverter, no idea how to do that either.

Edit2 - Just thinking out loud here. My assumption was that I couldn't add a filter to the loop because the frequency I need to remove (a range of around 200-1000Hz as motor and control loop parameters change) is of the same order as the electrical frequency of the motor which is being controlled. Is that true? In steady state Vd,Vq,Id and Iq are virtually DC, could it be that the loops only need to be fast enough to keep up with rates of change due to changing load/torque which are much slower? Could the control loop bandwidth be limited to say 200Hz? Seems counter intuitive but maybe worth a try?

Edit3 - No it can't, adding filtering on ud and uq just slows the loop down and means that the instability occurs at a lower frequency.
User avatar
Bigpie
Posts: 1586
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: IPM Motors - MTPV

Post by Bigpie »

It's over my head now and has been quite a while :D I've been assuming I'm hitting fmax at about 60mph in first gear as it sort feels like it hits the limit, speed drops and little then throttle comes back in and repeat.

This happens at the same speed on 5.24 as the previous version. I'm not able to get the web logging to work at the moment.

I think I've got 0.3 and 0.1mH so 0.2 difference,
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motors - MTPV

Post by Pete9008 »

Bigpie wrote: Wed Mar 01, 2023 6:55 pm I've been assuming I'm hitting fmax at about 60mph in first gear as it sort feels like it hits the limit, speed drops and little then throttle comes back in and repeat.

This happens at the same speed on 5.24 as the previous version. I'm not able to get the web logging to work at the moment.
That could be the same effect, Iq and Id start to oscillate and torque drops. In simulation that happens at around 9krpm, would that be around 60?

Edit - Your fmax is set to 800 or 12krpm, do you know what the gearing is in 1st?

I can get it to spin to higher speeds but only by disabling the new syncadv. I think this has the effect of killing loop gain at high frequency so prevents the oscillation, it does destroy performance at the same time though.

Just as an aside it also goes unstable with zero current (rolling down a hill) at exactly the same speed!

The conclusion I've come to is that it is a limitation of the motor/inverter combination. If you want to spin the motor faster it needs a higher PWM frequency which reduces latencies, increases the oscillation frequency and so allows the motor to run faster.

It's probably also possible to put an extra zero into the loop filter to kill the oscillation but it would need tuning to each individual motor/inverter combination (and would also need to be done on the real motor not the simulator). This is probably how Toyota get the Prius Gen3 to spin faster without upping the PWM freq.
Bigpie wrote: Wed Mar 01, 2023 6:55 pm I think I've got 0.3 and 0.1mH so 0.2 difference,
Ahh, ok that makes sense, I've been using the newer values from the csv logs and the calculator.

Edit - using ratios off the web for a Beetle diesel autobox (final 3.38, first 3.77) and 24" tyres gives 9krpm=50mph and 12krpm=68mph, could be either depending on your speedo accuracy!
User avatar
Ev8
Posts: 801
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 41 times
Been thanked: 149 times

Re: IPM Motors - MTPV

Post by Ev8 »

does this mean a frequency dependent element to the controller gains might be useful again?
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motors - MTPV

Post by Pete9008 »

Ev8 wrote: Wed Mar 01, 2023 7:57 pm does this mean a frequency dependent element to the controller gains might be useful again?
Not sure. I think the old frequency dependant element could only increase gain with frequency, this would need to do the opposite. Can't say I'm keen on the approach though.

An alternative is to use the motor parameters to calculate Uq and Ud based on speed and load and then just use the control loops to fine tune the output. The pro is that it should allow much lower loop gains and so improved stability, the con is that there are a lot more ways to get it wrong if the motor parameters aren't right.

What makes all this very difficult is not being able to tune it to suit just one motor (like the OEMs do). Trying to make a single solution that gives good power, suits a wide range of motors, is easy to tune and is unlikely to break in nasty ways is proving challenging :(
User avatar
Bigpie
Posts: 1586
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: IPM Motors - MTPV

Post by Bigpie »

TBH, if this is the limit of my combination, I'm ok with that.

My gearbox is FCH
Screenshot_20230301-210902~2.png
I guess one way to find out is to increase fmax and see if I can go faster.
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
Post Reply