Page 1 of 3

IPM Motors - MTPV

Posted: Fri Jan 13, 2023 9:05 pm
by Pete9008
Been looking at some of bexander's data, logs and in particular the plot he found of what the MGR should be able to do viewtopic.php?p=51135#p51135. Now looking at this, and even allowing for the reduced voltage, it was fairly clear that Lexus manage to get more power out of the motor than we do. Now this is a simulator plot using bexander's current/best settings (which has taken him a lot of work/optimisation to get to):
Baseline.png
So a peak of 29kW dropping to 19kW by 2400rpm.

I've also been reading up a bit on Most Torque Per Volt (MTPV) algorithms, in particular, where the operating point should be at each point. Now rather than trying to code stuff up straight away it seemed sensible to test the principle first so here is a plot where I'm trying to over-ride the controllers to force the operating point to roughly where it should be using manualiq and manual id (afraid it only goes up to 2.4krpm because the control loops have an increasing tendency to oscillate if I get it slightly wrong):
Manual MTPV.png
Now I couldn't get it to go quite where I wanted (and the above took quite a few attempts to get anywhere close) but the peak power is up to 32kW (ish, I saw nearer 35 on one run) and is still up at 24kW at 2400rpm so a gain of around 25%. I'm sure there is more there too once the operating point is right over where it should be (following the Is circle round before heading to the critical current point), at least another 10%?

So this is looking quite promising :D

Not sure I'm going to get a lot further with it this today as I need to spend a bit of time figuring out exactly how to integrate all the different modes (fairly sure I know how but needs a bit more pondering) but just thought this worth posting in the meantime.

Edit - Take some of that back, the above is about the limit and I don't know how to integrate the different modes yet.

Re: IPM Motors - MTPV

Posted: Sat Jan 14, 2023 2:57 am
by bexander
Could this MTPV result in more power during FW as well?

Re: IPM Motors - MTPV

Posted: Sat Jan 14, 2023 9:17 am
by Pete9008
Think so. Part of the problem is that what we are calling fw doesn't work properly for high inductance motors, works well on low L motors but ones like the MGR need a different approach.

Having slept on this it seems a bit clearer now so going to describe my current thinking here to a) try and get it clear in my head and b) allow everyone to pick holes in the logic!

If you look at the plots above fw current starts to come in at around half a second. Now this is way too low a frequency to be caused by back emf, and we are well below base freq, so why is it needed? The MGR has around 20x the inductance of the outlander motors (10x a leaf) so the wLqIq term is huge by comparison and it is this that is causing the voltage to max out, if you look at the plots it is Vd not Vq (as it would be for back emf driven field weakening) that is maxed out. This needs a slightly different approach and that is what MTPV tries to do.

The MTPA algorithm already use works out how we can most efficiently use limited amps to generate torque. MTPV works out how be can best use limited volts to generate torque. The way I'm thinking about it is when you have plenty of volts available MTPA chooses the optimum ratio of quadrature and reluctance torque to give max torque, if the wLqIq terms starts to max out we need to move more towards reluctance torque (more Id, less Iq) so reducing Iq and so Vd and restoring voltage margin. This does take us above the critical current which would be bad if we were above base frequency but the MTPV algorithm allows for this and moves the operating point as speed increases.

The plan is, operate on MTPA untill the voltage margin starts to limit. Use the margin error to drive a move in the operating point from the MTPA calculated point towards the MTPV calculated point. Once the operating point arrives at the MTPV point further reduction in margin then moves the operating point from the MTPV point towards Icrit (effectively backing off the throttle).

The questions are how heavy is the math, can it be done fast enough, would it be possible to pre-compute at start up and use look up tables and does it work!

Re: IPM Motors - MTPV

Posted: Sat Jan 14, 2023 9:41 pm
by RetroZero
Man, you sure have a nuclear power station in that head of yours. I get 1% of what you say, but starting to get an idea of where this is all going.Thanks for all your work!

Re: IPM Motors - MTPV

Posted: Sun Jan 15, 2023 7:20 am
by mikmur
RetroZero wrote: Sat Jan 14, 2023 9:41 pm Man, you sure have a nuclear power station in that head of yours. I get 1% of what you say, but starting to get an idea of where this is all going.Thanks for all your work!
I join. you got ahead of me :)

Re: IPM Motors - MTPV

Posted: Sun Jan 15, 2023 12:15 pm
by Pete9008
Thanks guys. Not sure I'd call this work though, it's what I do when I can't face real work :) I quite enjoy working things out/solving problems/improving things - even if it can be a little frustrating at times!

Little more progress, think I know how to do it all. Decided to graph the algorithms in a spreadsheet first just to make sure what they were doing made sense before trying to port them into the OI firmware. To plots:
graphs.png
It looks sensible, above 40Hz (which is roughly where MTPA runs out of steam and fw starts to come in in the above plots) it starts following the MTPV curve and moving current from Iq to Id. This reduces Vd and holds the total motor voltage stable at 200V (this is the value used in spreadsheet for udc/2). Once the speed gets to around 140Hz this is no longer enough and this is where the operating point would need to start moving from the MTPV point towards the critical current point (throttle reduction).

So it all looks like it should work, just need to get the equations into the firmware now...

Re: IPM Motors - MTPV

Posted: Sun Jan 15, 2023 4:04 pm
by Ev8
Awesome stuff as ever! I expect this will benefit my motors aswell

Re: IPM Motors - MTPV

Posted: Sun Jan 15, 2023 4:30 pm
by Pete9008
Some progress but not making quite as much sense as I would like and it doesn't want to transition cleanly into MTPV. I think the problem is mostly that I don't fully understand the mathworks equations that I'm using. Also need check how frq is generated as I'm wondering whether it lags slightly and this is causing the problem.

First the original FW results:
Baseline.png
Now MTPV with the same settings:
MTPV_2A.png
So that's around 1.6seconds less time to the same speed as before (8.4sec vs 10sec), 33kW peak, 22kW at 2400rpm and 18kW at 4800rpm (compared to 29kW, 19kW and 14.5kW for the FW code)

Dropping throttle current from 2A to 1.5A gives:
MTPV_1A5.png
33kW peak, 21kW at 2400rpm and still 18.5kW at 4800rpm so a much less peaky and more usable power curve and not significantly slower.

Question - there is a lot more maths there, it will be more complicated to set up and probably more sensitive to errors in the motor parameters. Is the ~3kW gain across the rev range (~10% at low speeds, ~25% at high speeds) worth the bother?

Re: IPM Motors - MTPV

Posted: Sun Jan 15, 2023 4:58 pm
by Ev8
I think Id be happy with 10% increase in performance, that could equate to around 10kw for me! every little helps

Re: IPM Motors - MTPV

Posted: Sun Jan 15, 2023 5:11 pm
by Pete9008
Ev8 wrote: Sun Jan 15, 2023 4:58 pm I think Id be happy with 10% increase in performance, that could equate to around 10kw for me! every little helps
Think I agree having played a little more!

Found a bug in my code so it's working a little better now. Have also added 10Hz to the frequency used for MTPV to force it to give a little more advance. It now transitions into MTPV much more cleanly. Three more plots:

Is=300A:
300A.png
40kW anyone! (not recommended, right on the limit and only for a few 100ms)

Is=200A:
200A.png
Better behaved than above.

Is=100A:
100A.png
For me this is the winner, just as quick as the FW version but using less current and with a much flatter torque curve :)

BTW - ignore the FW current trace, it's not current any more and it's just being used for debugging.

Re: IPM Motors - MTPV

Posted: Sun Jan 15, 2023 5:17 pm
by Ev8
This with the over modulated code could be interesting

Re: IPM Motors - MTPV

Posted: Sun Jan 15, 2023 5:18 pm
by Pete9008
Remind me how to turn on over modulation, I'll give it a try.

Edit: can't find anything in the param_prj, guessing it was a custom build? If so it will have to wait.

Re: IPM Motors - MTPV

Posted: Sun Jan 15, 2023 5:29 pm
by Ev8
Increase modmax to 44000

Re: IPM Motors - MTPV

Posted: Sun Jan 15, 2023 5:41 pm
by Pete9008
Thanks, well found!

@bexander - have you been using the over modulation code of the standard code?

Here you go, with over-modulation too.
300A:
300A_Overmod.png
200A:
200A_overmod.png
100A:
100A_Overmod.png
That's another 3kW on the 100A plot! Not bad :)

That's me about done for today. Think I need to move from an IIR filter to a PI controller to control the limiting. The IIR works well for the FW but I can't seem to get the right response for this, and then need to recheck that transition to coast and decel, but that's for another day.

Re: IPM Motors - MTPV

Posted: Sun Jan 15, 2023 6:45 pm
by bexander
This is fantastic work!!

I'm running the standard code at the moment. Haven't gotten to the point where I'm ready to test the overmodulated code yet.

It would be great for any increase in power at high rpm for the MGR. The increase at low rpm is a bonus. Really love the power curve in the last 100A plot. And the operating plot look very good to. Looks like 40% increase in power at 4700rpm!

How can I help you develope this further?

EDIT: Just relized, are those last plots with MTPV and overmodulation?

Re: IPM Motors - MTPV

Posted: Sun Jan 15, 2023 7:12 pm
by Pete9008
You've already helped a lot (so thank you!), both in your old posts when I was starting on the simulator, and with the logged data which gave me confidence that the simulator was getting close enough to reality to start looking at things like this. Plus it was that Lexus plot you found that convinced me that MTPV would be worth another look. Without having a car or motor to test on myself real data is the thing I'm short of so your data has been fantastic.

Yes, the last plots are with over-modulation (will edit above to make clear). The MTPV stuff gives around +25% at the top end and then the over-modulation another 10%.

Re: IPM Motors - MTPV

Posted: Sun Jan 15, 2023 7:23 pm
by Ev8
I know it’s early doors but you know I’m always happy to test new code in the car!

Re: IPM Motors - MTPV

Posted: Mon Jan 16, 2023 8:27 am
by Pete9008
Thanks! Likely to be towards the end of the week before its ready for real world tests, will let you know.

Re: IPM Motors - MTPV

Posted: Mon Jan 16, 2023 8:36 pm
by Pete9008
Ev8 wrote: Sun Jan 15, 2023 7:23 pm I know it’s early doors but you know I’m always happy to test new code in the car!
While I was looking at your syncadv value in the simulator I decided to try the MTPV algorithm on your setup. Not sure I have your parameters quite right but it gives the general idea (both these are without over-modulation):

Std FW:
Ev8_std.png
MTPV:
Ev8_MTPV.png
Edit - probably got the voltage set too high so these might both be a bit optimistic but the delta still gives an idea of the difference.

Edit2 - The power curve does benefit a bit from higher ki (2000) with MTPV but your value seems to work better on FW. I think the slightly slower loop response is helping move the operating point slightly in FW in a way that helps prolong the peak power!

Edit3 - And one more plot, MTPV but with ki=2000, offers better control of the current at higher speeds and straightens the torque curve. Note that I have had to reduce the simulation time from 5sec to 3.4 sec to maintain the same terminal speed.
Ev8_MTPV_Ki2000.png

Re: IPM Motors - MTPV

Posted: Mon Jan 16, 2023 9:22 pm
by Ev8
wow, nice work, cant wait to test!

Re: IPM Motors - MTPV

Posted: Mon Jan 16, 2023 9:27 pm
by Pete9008
It's looking promising but needs a bit more tuning, can't think clearly enough tonight though so will have to wait till another evening, hopefully have something by the weekend :)

Re: IPM Motors - MTPV

Posted: Tue Jan 17, 2023 7:05 am
by celeron55
Those plots are starting to look like the MGR is going to be able to propel my second minivan into highway speeds at 360V! And I like seeing peak torque getting closer to 1000Nm. That's fairly crucial also.

Re: IPM Motors - MTPV

Posted: Fri Jan 20, 2023 9:41 pm
by Pete9008
Had another look at this and it doesn't handle regen very well, essentially it doesn't allow enough Iq to do any significant regen when past base freq :(

Need to go back and review the MTPV equations to see what I'm doing wrong.

Re: IPM Motors - MTPV

Posted: Sat Jan 21, 2023 4:23 pm
by Pete9008
So had another look at the equations and have decided that the Mathworks MTPV equations aren't a complete solution - kind of explains why they are half as complicated as all the other references I've found. All the other equations I have come across are either too complicated or too poorly documented to try and do in real time. If anyone knows of any good MTPV references please post links to them.

Not all doom and gloom though. The work so far has convinced me that with the right operating point there is at least another 25% torque to be had at higher speeds on motors like the MGR. It has also given me a good idea of how the operating point needs to move. It should be possible to produce something close using an approach that I tried before. At the time it didn't give great results but I'm hoping that it can be improved.

Re: IPM Motors - MTPV

Posted: Sat Jan 21, 2023 6:18 pm
by Ev8
Still a very promising prospect, I hope someone cleverer than me can can help here