IPM Motor Simulation and FOC Software

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 »

Wow awesome work!
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 »

Any chance you have a build I can test later?
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, pretty happy with that result, it is the best result from the simulator so far :)

Not keen to generally release as I can't test it myself but if you are happy to take the chance I can pm you a load file?
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 »

Sounds good to me!
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 »

Will get the build done this afternoon and send it through. Bin or hex best?
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 »

Bin please
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 »

One final plot for completeness, a 100% run to around 3x base speed, a 2sec coast followed by 100% deceleration to zero:
Revised_AccelCoastDecel.png
So far it's looking promising. As long as the sync compensation value is kept sensible it seems to be more stable than the other builds tested on the simulator.

Edit - Just found what might be a slight bug in the OpenInverter code, not sure whether the vehicle control functions higher up the code (that the simulator doesn't call) will fix it but just in case they don't I'll mention it here. When coming to a stop under regen the Iq current drops to zero as soon as the vehicle is stationary due to the limits on the Iq PI controller, however, the -Id commanded by Mtpa continues for as long as the negative torque command continues (you can just see the effect at the right hand side of the above plot). As soon as the negative torque command is removed Id returns to zero.
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 Motor Simulation and FOC Software

Post by Bigpie »

Some findings from my playing around, I need to have quite a low curp of 30, I can get up to 540a on stall but as soon as the car is allowed to move it cuts out. At the lower values the min and max are much closer together. Need to do further debugging on why with the handbrake off it cannot get this high. This is with ldminusld of 0 but having 0.6 seems to behave the same.


p-30-i-40.csv
(1.92 KiB) Downloaded 37 times
540a.csv
(1.34 KiB) Downloaded 35 times
Screenshot 2022-09-19 at 12.45.35 pm.png
Screenshot 2022-09-19 at 12.41.11 pm.png
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
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 »

Have you tried a p led tuning? For me it delivered the same or better drivability with less spikes, Im currently happy running kp=400 ki=350 I know mine is gen 2 but…. It could be with a low kp your control doesn’t have the authority to catch them
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 Motor Simulation and FOC Software

Post by Bigpie »

p led tuning? With p above 50 the difference between the min and max values gets larger. I'm guessing my motor will have relatively low inductance compared to larger motors such as the Outlander rear or Leaf etc. Maybe that's a factor.
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 Motor Simulation and FOC Software

Post by Pete9008 »

Bigpie wrote: Mon Sep 19, 2022 11:47 am Some findings from my playing around, I need to have quite a low curp of 30, I can get up to 540a on stall but as soon as the car is allowed to move it cuts out. At the lower values the min and max are much closer together. Need to do further debugging on why with the handbrake off it cannot get this high. This is with ldminusld of 0 but having 0.6 seems to behave the same.



p-30-i-40.csv540a.csv
Screenshot 2022-09-19 at 12.45.35 pm.png
Screenshot 2022-09-19 at 12.41.11 pm.png
You're right that smaller motors will need lower kp but that does seem very low. Would expect some difference between min and max, say 20-30% (just not the 80-90% you had before) so might be worth increasing the values a bit.

Good to see that the Prius inverter looks happy at those currents, is it warming up much?

I'm becoming a little suspicious about the resolver measurement. Any idea what the motor position was doing in those plots?

Edit - just had a look at the csv files, the currents there do match surprisingly well which is good. I think you can get away with higher kp, maybe twice what you have, maybe even a bit more.

Very interested in seeing what the motor angle is doing while the motor is locked stationary.

Edit2 - Just to explain my reasoning on the above comment - the only explanations that I can see as to why integral led tuning could be an advantage is either if it was masking a bug (and there was the windup bug, now fixed, which it might have helped mask) of if there is a underlying noise problem. The integral term has a bit of a averaging effect which might help control noise. If this is the case then proportional led tuning could make things worse. There is no sign of noise being a problem on the current traces above which is what makes me wonder about the motor angle. Noise on the angle would also be more obvious when moving than when the rotor is locked.

Edit3 - out of interest did you take any plots using your original ki/kp values?
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 Motor Simulation and FOC Software

Post by Bigpie »

stationary.csv
(10.33 KiB) Downloaded 36 times
moving.csv
(7.98 KiB) Downloaded 47 times
This is with: curkp: 40, curki: 30, fwkp: 0, fwki:0, lqminusld: 0, throtramp: 100, throtcur:2
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
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 »

Have done some quick runs this afternoon, turns out with mtpa off I can use field weakening, but performance is pretty lacking (this is with synof centered) but everything behaves. With mtpa on I can’t go more than fwki=1 without getting unwanted throttle when f/w comes in. Regardless of where syncof is at. And also regardless of my mtpa settings I’ve tried between 0.5-3mH 90-150


Unfortunately it looks like In the chase for power it’s possible to gain positive torque by advancing syncof (at the cost of regen torque, a way of advancing syncof with throttle, (within confines) would work better than being linked to frequency.
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 »

Bigpie wrote: Mon Sep 19, 2022 2:42 pm stationary.csv
moving.csv
This is with: curkp: 40, curki: 30, fwkp: 0, fwki:0, lqminusld: 0, throtramp: 100, throtcur:2
There is something not quite right there. On the stationary plots first the current:
BP_Stat_I.png
Was that spike a trip?

On the angle:
BP_Stat_Ang.png
Now if it was trip then maybe that's to be expected, if not it shouldn't be there!

Edit - Just had a look at potnom:
BP_Stat_PNom.png
Surely that shouldn't be there?

BTW - all the above are for the stationary test.

Edit2 - Apart from the occasional noise spikes that seem to be appearing on multiple channels I can't see anything wrong here. Could they be a plotting artefact or are they real? If real it looks like they are either caused by or causing the trips?
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 »

Ev8 wrote: Mon Sep 19, 2022 2:47 pm Have done some quick runs this afternoon, turns out with mtpa off I can use field weakening, but performance is pretty lacking (this is with synof centered) but everything behaves. With mtpa on I can’t go more than fwki=1 without getting unwanted throttle when f/w comes in. Regardless of where syncof is at. And also regardless of my mtpa settings I’ve tried between 0.5-3mH 90-150
Interesting! Need to think about the interaction of Mtpa and FW a bit more, not too sure what's going on there. Surprised that syncofs doesn't affect this, could it need a power off for the new value to take? - need to check the code to see.

Edit - does FW behave correctly without Mtpa? No unwanted regen/acceleration and stable (poor performance without Mtpa is to be expected)?
Ev8 wrote: Mon Sep 19, 2022 2:47 pm Unfortunately it looks like In the chase for power it’s possible to gain positive torque by advancing syncof (at the cost of regen torque, a way of advancing syncof with throttle, (within confines) would work better than being linked to frequency.
Not keen on adjusting syncofs to look for power (it can be used this way but will also have side effects), it really should be set to the middle of the deadband. What sync compensation (syncadv) value are you running (it's effect does scale with frequency in the build you have)?
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 always have to cycle power when changing syncof. F/W seems just fine with a range of syncofs

Some reading seems to suggest maybe advancing syncof at higher motor speeds could help gain power
The optimum angle to apply current for the magnet-flux component of torque is 90° (Equation 15.7); for Figure 15.26, the optimum angle of current (with respect to magnet flux) for the reluctance component of torque is 135°. The optimum angle for a hybrid motor at low speeds (that is, without field weakening) will be between 90° (magnet-flux optimized) and 135° (reluctance torque optimized). Since the reluctance component is usually a fraction of the magnet torque in PM motors, the optimal angle is much closer to 90° than it is to 135°. Still, some angle advance (perhaps 10° or 15°) will often increase the torque of a motor as much as 15%. This is one example of how to take advantage of reluctance torque; there are other motor structures that use reluctance torque differently.
https://www.sciencedirect.com/topics/en ... nce-torque
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 »

Ev8 wrote: Mon Sep 19, 2022 3:27 pm Yes I always have to cycle power when changing syncof. F/W seems just fine with a range of syncofs

Some reading seems to suggest maybe advancing syncof at higher motor speeds could help gain power



https://www.sciencedirect.com/topics/en ... nce-torque
Agree, that's what Mtpa does. If you take the vector sum of Id and Iq then that its the angle the article talks about. For a low saliency motor Id is low and the angle is near 90degrees, on a higher saliency motor Id increases and so does the angle.

Edit - see what you mean - bit more reading needed!

Edit2 - no think that agrees with the Mtpa algorithm we use. When the article uses the term low speed they mean outside FW. Above base speed extra Id is needed which has to reduce the angle (and reduce torque) but that's the compromise for running above base speed.

Edit3 - in fact I've seen that article before, it's the one that suggsets 10-15degrees advance and what made me wonder about the amounts of -Id that were being used. Our motors do seem to need a lot more than 15degrees based on the lqminusld that everyone seems to need to use (Iq and Id roughly the same size will put us near the 135degree maximum quoted there).
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 »

Ev8 wrote: Mon Sep 19, 2022 3:27 pm Yes I always have to cycle power when changing syncof. F/W seems just fine with a range of syncofs

Some reading seems to suggest maybe advancing syncof at higher motor speeds could help gain power



https://www.sciencedirect.com/topics/en ... nce-torque
What syncadv value are you running? It should be 5.

Edit - could really do with a plot of what happens when FW comes in, is there any chance that your wifi is up to it?
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 »

Ok that makes sense. Back to the thinking! When I run mtpa and f/w on your build I use a syncadv of 5
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 »

I will try to log when next out but man my Wi-Fi sucks
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 »

Ev8 wrote: Mon Sep 19, 2022 3:37 pm Ok that makes sense. Back to the thinking! When I run mtpa and f/w on your build I use a syncadv of 5
You could try a little more but with the warning that the simulations showed stability dropping fast above 5. This would give you a little more advance at high speeds. Any value less than 5 should be fine and reduces the angle advance.
Ev8 wrote: Mon Sep 19, 2022 3:37 pm I will try to log when next out but man my Wi-Fi sucks
Any idea why it's so bad, is the ESP module inside the ECU case or outside?
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 »

Ev8 wrote: Mon Sep 19, 2022 3:37 pm Ok that makes sense. Back to the thinking! When I run mtpa and f/w on your build I use a syncadv of 5
I'd use syncadv=5 all the time in my build. It's effect should be useful whether or not Mtpa and FW are enabled.
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 should have worded that differently it’s always on 5
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 Motor Simulation and FOC Software

Post by Bigpie »

Pete9008 wrote: Mon Sep 19, 2022 2:58 pm There is something not quite right there. On the stationary plots first the current:
BP_Stat_I.png
Was that spike a trip?
No trips on this test
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
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 »

now I want to read this about mtpa
Abstract:Due to the nonlinearity of the flux-linkage profiles of the interior permanent magnet synchronous machine (IPMSM), the conventional motor model cannot be used for both maximum torque per ampere (MTPA) control and torque estimation. This paper proposes a nonlinear flux-linkage model for IPMSM with eight coefficients to fit the real d-axis flux-linkage, q-axis flux-linkage, MTPA, and torque. The corresponding torque equation and MTPA condition are presented. The factors in the proposed model can be obtained by solving an optimization problem with the limited information from the machine instead of the measurement throughout the map. The comparison of the characteristics between the proposed algorithm and FEA data is illustrated.View less
https://ieeexplore.ieee.org/document/7520215/
Post Reply