Halved current during field weakening

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: Halved current during field weakening

Post by bexander »

I'm starting to think something is going on in the SW from 5.00 and forward.
With any SW, when I start in "run" I get a audible high pitch tone with low amplitude which I think is the resolver excitation signal.
With 5.00 and forward, as soon as I hit "start inverter in manual mode", this tone disappeares and I can't get any manual id/iq output. No respons in Ud/Uq either.
With 4.94 I still hear the tone after "start inverter in manual mode" and manual Id and Iq commands works as expected.
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

ok, will check that
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Halved current during field weakening

Post by celeron55 »

I'm up for some more motor control alchemy. Are you? :mrgreen:

There was this "speedy_gonzalez" person who posted some really interesting stuff about "infinite speed drive" class motors in viewtopic.php?f=7&t=1628 and said that the Prius motors are of such type. They since deleted all the content of their posts. No idea why. I saved the graph they posted and will attach it here too. I'm going to completely botch the terminology because I didn't save the posts and can't be bothered to dig up the papers they posted that I didn't bookmark. They said something like: These motors have three operating modes or regions instead of two. Two being (1. non-FW and 2. normal FW), three being (1. non-FW, 2. normal FW and 3. current-limited FW).

Basically it was so that you have a maximum field weakening (-Id) current that you can use, and once you reach the maximum you're in mode 3 and have to start decreasing Iq in order to stay in FW (to advance the current vector further without increasing -Id), I recall you then ramp Iq down in such a way that the motor power stays the same.

I'm going to suppose the MGR is also this type of motor, and also that it's basically the same as the Prius motor and also similar to the graph in the image.

I believe we're still very far in terms of correct Id-Iq distribution. And of course we don't have any of the limits implemented, but we have to start from the lower speed distributions.

In the graph you can see at the mode 1 -> mode 2 transition point the Id-Iq relation is about Id=-0.7*Iq, at mode 2 -> mode 3 it's Id=-2.3*Iq and at the end of mode 3 it's Iqd=-7*Iq.

Now, these modes seem to be only or mostly dependent on motor speed and there's no information on what the speeds would be. Given that moving current from Iq to Id increased performance when starting from about a 1:1 distribution at 2300rpm, I would reason 2300rpm is close below to the mode 2 to mode 3 transition point. Maybe the transition point is somewhere between 2500-3000rpm.

The goal would be now to make the motor accept full power (45kW) at around 2300rpm (153Hz) and when that is achieved there should be a very steep performance loss at some higher RPM if the currents aren't appropriately limited - however we can try to use the idcmax value to implement mode 3. When mixed in with syncadv, it will result in something surprisingly close to ideal control I believe.

To make 45kW at 2300rpm, given that it's where I think it is, looking at the graph, the motor wants about Id=-2*Iq. To make that happen using syncadv, current vector needs to be advanced to 153 degrees from the regular 127 degrees, that's 26 degrees and, given a syncadv of +10 at this speed will give 7.5 degrees, we want a syncadv addition of 35, that's a value of 10+35=45.

Then to limit power to 45kW as a mode 3 implementation, set idcmax to... uh, bexander: what's your battery voltage again? If it's 350V, set idcmax to 128. Well anyway, it should be 45000/udc (I=P/U).

bexander: Brave enough to try this? Make sure to disable regen completely, it won't work correctly. Anything using syncadv like this will completely break regen.
Attachments
FieldWeakening.JPG
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Hmm, very strange those deleted posts. Was it that confidential?
Anyway, how about switching between MTPA and something more static based on speed (for now)?. So when fstat > x Hz instead of MTPA we split is into 1/3 iq and 2/3 id (again, the ratio should be configurable). Might be worthwhile to have a transition ramp, so between x-20 Hz and x Hz we ramp over from the MTPA distribution to "the other" distribution.
This would be more explicit than messing with syncadv.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
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: Halved current during field weakening

Post by bexander »

I'm up for testing but lets first do some reasoning in the matter.

Changing current distribution based on static speeds might work, I have no idea, but the motor base speed is dependent on what current you try to push through the motor so not a static thing, at least not according to what I have linked to previously.
Then, for FW one needs both voltage and current limited maximum torque (VCLMT). This will then determine the current distribution, for any case of requested torque.
So what I'm trying to say is that a motor is not a static device and so trying to control it as such might be difficult.

Regarding Mode2 and Mode3 of FW seem to be basically the same as VCLMT.
My suggestion is to start with VCLMT and go from there. Using a dynamic base speed to determine when to shift from MTPA to VCLMT. If this does not work, then try to implement more forced current distributions.
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Halved current during field weakening

Post by celeron55 »

I just thought it would be nice and easy to just start playing with existing parameters as they might get us quite far, at least to prove we're heading to the right direction. The syncadv + idcmax hack basically goes right along that rather complex graph line as far as I can see. The reason to start writing code would be to get the inverter simultaneously output the required Id-Iq ratio (or current vector angle, as I like to think about it) and know what the motor position actually is in order to get regen working.

I think the "ramp" should be continuous from a minimum (configurable) fstat value, and it should basically increase the -Id/Iq ratio along with fstat indefinitely, i.e. no transition, but simply a (configurable) factor.

Additionally the maximum -Id value should be configurable. After the maximum -Id is reached, the inverter should start limiting Iq in such a way that the -Id/Iq ratio is maintained.

So, I'll name the parameters with some values that might work here:

fwrampstart = 100 (fstat @ 1500rpm)
fwrampfactor = 50 (Basically if motor spins at 3000rpm, add (3000-1500)/1500 * 50 = 50A of -Id)
fwmax = 100 (maximum -Id current after which Iq is limited to maintain ratio)

And the algorithm would be, on top of what the current software does:

Code: Select all

if(fstat > fwrampstart){
	// Mode 2 of an infinite speed drive
	Id -= (fstat - fwrampstart) / fwrampstart * fwrampfactor;
	if(-Id > fwmax){
		// Mode 3 of an infinite speed drive:
		// -Id is too much. Divide Iq by how much too much -Id there is and then clamp -Id to where it has to be. This maintains the -Id/Iq ratio and limits -Id.
		Iq = Iq / (-Id / fwmax);
		Id = -fwmax;
	}
}
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Halved current during field weakening

Post by celeron55 »

To be honest I'm not willing to start reading research papers for this, at least not until I'm proven it won't make more power otherwise. Too boring for a hobby.

I'd be doing this testing myself but I really need to know whether the MGR can put out 40kW at high speed or not before I can be bothered to start figuring out how to even get it installed. I have a GS450H transmission waiting for the case it can't. But I definitely don't want to use it if I don't need to. That and the diff combined weigh like 170kg and I'd rather use that for batteries and passengers. And not even talking about the space...
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Re your code: I'd rather make this proportional to the commanded throttle to prevent the car doing silly stuff because of misaligned syncofs/syncadv. So your point of experimenting with high syncadv/idcmax to gain knowledge is good. Provided bexander keeps playing Guinea pig ;)
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Halved current during field weakening

Post by celeron55 »

Oh yeah, feel free to keep it proportional to throttle. I was mostly thinking about full-on acceleration when writing that algorithm.
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: Halved current during field weakening

Post by bexander »

As long as my car is in running condition I should be able to test stuff.

I don't think any research papers is need to be read to get VCLMT. I'll look into the present code and put in the existing variables into the fancy equations and then write some pseudo code for it. If you like it, then perhaps it can be translated to software?
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: Halved current during field weakening

Post by bexander »

bexander wrote: Fri Jun 25, 2021 11:14 am I'm starting to think something is going on in the SW from 5.00 and forward.
With any SW, when I start in "run" I get a audible high pitch tone with low amplitude which I think is the resolver excitation signal.
With 5.00 and forward, as soon as I hit "start inverter in manual mode", this tone disappeares and I can't get any manual id/iq output. No respons in Ud/Uq either.
With 4.94 I still hear the tone after "start inverter in manual mode" and manual Id and Iq commands works as expected.
johu wrote: Fri Jun 25, 2021 9:05 pmok, will check that
Any news on this? What have changed from 4.94 to 5.00? Do I need to send extra start command after the inverter is set to "manualrun"? Still can't figure out what I'm missing hence can't do the syncadv tuning.
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Ok, I checked this. Same result as you: when switching from Run mode to ManualRun mode specifying manualid/q does not change anything. Also I noticed CPU usage drops to 1% which means the PWM code is no longer executed.
Only when I switched directly from stop to ManualMode it actually worked. In my case this is possible because the VCU NEVER drops the DC-contactor after startup. When the contactor is inverter-controlled this won't work.

I don't yet understand by this happens as there were tons of changes between 4.97 and 5.00. What I do see is that PwmGeneration::SetOpmode() is never called with ManualMode. But it should at least stay in Run mode and not drop CPU usage to 1%.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Halved current during field weakening

Post by celeron55 »

I decided to start doing at least a temporary MGR installation to get on board with testing. Won't have much time sooner than after two weeks though.

I will be using a Leaf gen2 inverter for this, and a 96S battery pack - pretty much the beefiest stuff within reason.
20210701_171824.jpg
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Nice!
I tested the revised MTPA formula today and it was crap. Commands way too little id and the car becomes sluggish.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
mikmur
Posts: 46
Joined: Sat Jul 18, 2020 7:37 am
Location: Georgia/Batumi
Has thanked: 33 times

Re: Halved current during field weakening

Post by mikmur »

User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Hi mikmur, syncadv is only available in test firmwares posted later in this thread. Your other questions would fit better here: viewtopic.php?f=14&t=190&p=28374 because this is just about a specific software issue.

And lets come to that. I have played around with the MTPA formula and I find it a bit weird. If I leave it like it is, changing lqminusld and fluxLinkage actually make a difference. If I change it to the one advertised by TI or Mathworks, it always results in a pretty linear 50:50 distribution of id and iq
Bildschirmfoto vom 2021-07-07 17-50-26.png
fluxLinkage=0.5
Bildschirmfoto vom 2021-07-07 17-49-40.png
Without the factors, fluxLinkage=0.1
Bildschirmfoto vom 2021-07-07 17-48-06.png
Formula with the "8" and "4" factor in it

So I don't know what to conclude. Is TIs formula wrong? Or do we not understand it correctly? A formula that hardly responds to its input parameters doesn't seem very useful. I think I will make a firmware with "our" interpretation of MTPA and have fluxLinkage be a parameter.
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: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Investigated a bit further. So in TIs formula we have the term
fl²/(16*ldminuslq²) (fl being fluxLinkage). If I plug in our commonly used values, the result is about 18. To that is added is²/2.
Now if it is like 100A it will be totally dominating with a value of 50000. The other term just makes it 50018.

So it's almost like writing sqrt(is²/2) or is/sqrt(2). Then in front of the square root we have fl/(4*ldminuslq) which results in about 4.

So we essentially calculate 4-is/1.41. This can't be right?
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: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Now given the hunch that MTPA does nothing useful at higher currents I decided to bring back an old friend: throtid and throtiq. So now you can manually set which current component you want. I think you might obtain higher torque at high speed when throtid exceeds throtiq. So like throtiq=1.5 and throtid=-2 or so.

Maximum FW current is throtid*50.

The firmware has some quirks at low speed, ignore that for now.

source here: https://github.com/jsphuebner/stm32-sin ... oMTPA-test
Attachments
stm32_foc.bin
(46.92 KiB) Downloaded 109 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
mikmur
Posts: 46
Joined: Sat Jul 18, 2020 7:37 am
Location: Georgia/Batumi
Has thanked: 33 times

Re: Halved current during field weakening

Post by mikmur »

can I install this firmware too? I think yes.
Thank you so much. I'll try.
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: Halved current during field weakening

Post by bexander »

To my understanding the MTPA calculation works fine below base speed. I find it reasonable to have a close to 50:50 distribution of currents at this stage. When above base speed the VCLMT should be used and that should provide a different current distribution that varies a lot more with different motor parameters.
Capture.PNG
Capture.PNG (7.55 KiB) Viewed 4285 times
I've had a lot to a work lately so not had any time to look into this VCLMT part yet. Hopefully will have more time as soon.
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Played with the formular a bit, it only works for certain values of omega because otherwise the term in the square root becomes negative.
Attachments
mtpa-fw.ods
(22.98 KiB) Downloaded 96 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
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: Halved current during field weakening

Post by bexander »

To my understanding "omega e" is the stator speed, hence same as "frq" in SW.
Id_fw is to be used above base speed and Id_mtpa below where the base speed is calculated by
image_2021-07-08_163235.png
image_2021-07-08_163235.png (3.29 KiB) Viewed 4252 times
Note, this is the rotor base speed. Remove the 1/p for stator base speed.
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: Halved current during field weakening

Post by bexander »

Also, there are a lot of different currents used in different equations and I don't understand what is what. In Id_fw Imax is used and I don't think that is the same current as Is in SW. I think this is maximum current the motor can handle, i.e. a constant, but I really don't know.
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Yes i_max is confusing but it would be really strange if it were constant. Then there would be no throttle dependent variable in there.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
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: Halved current during field weakening

Post by bexander »

Indeed, very good point!
I also realized frq is not the same as omega e. There is a 2pi factor between them as frq is in Hz and omega e is in rad/s.

At Is = 100 with current distribution as per MTPA I reach base speed at 17km/h according to equations.
Post Reply