IPM Motor Simulation and FOC Software

User avatar
Bigpie
Posts: 1585
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 »

I have fmax set to 800, I've not logged what I manage to get it up to, again, I'll log it.
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 »

Assuming a 4 pole motor 800Hz would be 12000rpm, the simulation is only running to 3000rpm. If you let it run to a higher speed in the simulator you will see more power. The power should level out, probably by 6000rpm, when you hit base freq and enter the constant power region. At 3k you are still in the constant torque region.
User avatar
Bigpie
Posts: 1585
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 »

4 pole motor, 12000 rpm is reasonable, motor rated to 14k so might up some more.
Screenshot 2022-11-16 at 1.56.48 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
SciroccoEV
Posts: 369
Joined: Thu Oct 10, 2019 1:50 pm
Location: Luton UK
Been thanked: 15 times

Re: IPM Motor Simulation and FOC Software

Post by SciroccoEV »

Pete9008 wrote: Wed Nov 16, 2022 10:43 am That looks like a usefull refernce book, is it worth buying?
It's a pretty good book, obviously a bit dated in places. It cost me something like £65 back in 1999 or so. There's a used copy on Amazon right now for £12, which is well worth it.

The EV section of the book is based on work done by Motorola for Ford and what ended up going into the 1998-2002 Ford Rangers; https://en.wikipedia.org/wiki/Ford_Ranger_EV

Motorola's own test platform was a bit different and might not have made Ford all that happy; https://www.thedrive.com/news/culture/w ... -the-1990s
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 »

SciroccoEV wrote: Wed Nov 16, 2022 1:57 pm It's a pretty good book, obviously a bit dated in places. It cost me something like £65 back in 1999 or so. There's a used copy on Amazon right now for £12, which is well worth it.
Thanks, I'd noticed that already, if its still there will probably order it.
SciroccoEV wrote: Wed Nov 16, 2022 1:57 pm Motorola's own test platform was a bit different and might not have made Ford all that happy; https://www.thedrive.com/news/culture/w ... -the-1990s
:lol: Probably not happy at all!

Edit - does the book go into motor equations at all or is it more the electrical side?
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: Wed Nov 16, 2022 1:57 pm 4 pole motor, 12000 rpm is reasonable, motor rated to 14k so might up some more.
Ahh, ok, see what you mean now. The control loops aren't't looking too happy at higher speeds at all :( which code is that, guessing mine as it does tend to do that. If so it is worth dropping curkifrqgain or fwki to see if it helps.

Johannes new IIR filter version does seem to help avoid that control loop oscillation at higher speeds.
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: Wed Nov 16, 2022 1:57 pm 4 pole motor, 12000 rpm is reasonable, motor rated to 14k so might up some more.
Just tried to reproduce and I can't get anything to stay stable in FW.

The thing that seems to make the biggest difference is Ld. I'm wondering if your bridge is under reading slightly, with a value of 0.16mH everything behaves much better and the power is back up to 75kW.

What is the resolution of your LCR bridge? If it is only 0.1mH then the actual inductance could have been up to 0.199mH??
User avatar
Bigpie
Posts: 1585
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 »

It shows to 2 dp, one reading was 0.25 part way though a rotation, I also had a 0.13mH. Lowest was 0.10mH and highest was 0.30mH it was cheap so not expecting high accuracy.

I'm still running your code on the car and simulator for now.
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 »

I'd use 0.15mH for the time being, 0.1mH does seem very low. Any idea what frequency the Outlander OEM inverters run at?

It's been a while since I used the master branch on the simulator (I've been running the experimental branch) and It really isn't that good in terms of stability above base freq (not too surprising as it is essentially 5.20 code plus logging).

It would be worth moving either to Johannes latest (safest but no logging yet) or my experimental (untested but has the logging). As there is no rush on data I'd probably go for the former and hope that Johannes gets the logging going before we need it. Both options are better then the old code that you are currently running.
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 »

@johu - just trying to update the simulator for the latest build. Got a build error and it looks like the definition

Code: Select all

uint16_t    PwmGeneration::slipIncr;
is missing from the top of pwmgeneration.cpp.

I'm using a fresh git checkout so could you check this against your local repo?
User avatar
Bigpie
Posts: 1585
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 »

I've not calculated the icrit yet, but might get chance to try it out at the weekend, plus the current code works great for me.
Just uploading a log to my drive where the car had a cut out event though.
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: Wed Nov 16, 2022 4:08 pm I've not calculated the icrit yet, but might get chance to try it out at the weekend, plus the current code works great for me.
Just uploading a log to my drive where the car had a cut out event though.
Fair enough, just don't pull the latest simulator when I update it as it won't build with your code (no new features though so not a big issue).

When did it trip, from stationary or while moving?

Have you fixed the final overflow bug in your code (not sure I ever pushed it to the master github branch)?
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 »

johu wrote: Sun Nov 06, 2022 3:20 pm More combined simulator and car tuning today (Prius that is). Today it seems simulator and car match up quite well.
I struggle to get more than 20kW constant power both in the car and the simulator:
image.png
image.png (40.95 KiB) Viewed 1334 times
Controllers are very smooth now. The code is based on the recent github master commit, slightly modified for the simulator (e.g. export vlim). fwkp means filter constant!

The car starts out very powerful but quickly looses grunt above 40 kph. I saw 120A@360V which is a nice 43 kW. But then when at "speed", say 60 kph, I only see about 70A or 25 kW. So more than in the simulator but similar drop off. Any ideas how to obtain more constant power?

Had one uncontrolled regne event with some delay though, when coming off throttle at 100 kph
run01.png
@johu - updating the simulator to support you latest code, all the mods are done but I don't seem to be able to reproduce your results. The plot which should reproduce the above comes out looking like this:
johu_5.24.png
Have you changed anything else that might affect this?

Edit - BTW - best to run with the extra cycle box checked as otherwise it doesn't accurately simulate the hardware PWM load delay.

Edit2 - Looks to be something to do with the IIR filter which is producing silly results but can't figure out what. Assume that 11 is right for vlimflt?
User avatar
Bigpie
Posts: 1585
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, tried to set off too quick. Can't get the decoder to decode it though unfortunately.

I'm not sure if the final overflow bug is fixed, got the commit id?
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: Wed Nov 16, 2022 4:21 pm Stationary, tried to set off too quick. Can't get the decoder to decode it though unfortunately.

I'm not sure if the final overflow bug is fixed, got the commit id?
Not sure it got commited as a standalone mode, fairly sure it's in the experimental branch. If your InvParkClarke function looks like this (particularly the ua/=2 and ub/=2 lines):

Code: Select all

void FOC::InvParkClarke(int32_t ud, int32_t uq)
{
   //Inverse Park transformation
   s32fp ua = FP_MUL(cos, ud) - FP_MUL(sin, uq);
   s32fp ub = FP_MUL(cos, uq) + FP_MUL(sin, ud);
   //Inverse Clarke transformation
   DutyCycles[0] = ua;
   ua /= 2;
   ub /= 2;
   DutyCycles[1] = (-ua + FP_MUL(SQRT3, ub));
   DutyCycles[2] = (-ua - FP_MUL(SQRT3, ub));
Then it's been done.
User avatar
Bigpie
Posts: 1585
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 »

I've checked my stm32-pete, looks like I've not.

Code: Select all

void FOC::InvParkClarke(int32_t ud, int32_t uq)
{
   //Inverse Park transformation
   s32fp ua = FP_MUL(cos, ud) - FP_MUL(sin, uq);
   s32fp ub = FP_MUL(cos, uq) + FP_MUL(sin, ud);
   //Inverse Clarke transformation
   DutyCycles[0] = ua;
   DutyCycles[1] = (-ua + FP_MUL(SQRT3, ub)) / 2;
   DutyCycles[2] = (-ua - FP_MUL(SQRT3, ub)) / 2;

   int32_t offset = SineCore::CalcSVPWMOffset(DutyCycles[0], DutyCycles[1], DutyCycles[2]);

   for (int i = 0; i < 3; i++)
   {
      /* subtract it from all 3 phases -> no difference in phase-to-phase voltage */
      DutyCycles[i] -= offset;
      /* Shift above 0 */
      DutyCycles[i] += zeroOffset;
      /* Short pulse suppression */
      if (DutyCycles[i] < minPulse)
      {
         DutyCycles[i] = 0;
      }
      else if (DutyCycles[i] > maxPulse)
      {
         DutyCycles[i] = (FP_FROMINT(2)-1);
      }
   }
}
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 »

That's the old code, could well be causing the trip.
User avatar
Bigpie
Posts: 1585
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 »

Sadly not, stamping from standstill still cuts out. Doing so while moving is ok it seems
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
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

Pete9008 wrote: Wed Nov 16, 2022 4:20 pm @johu - updating the simulator to support you latest code, all the mods are done but I don't seem to be able to reproduce your results. The plot which should reproduce the above comes out looking like this:
johu_5.24.png
Have you changed anything else that might affect this?

Edit - BTW - best to run with the extra cycle box checked as otherwise it doesn't accurately simulate the hardware PWM load delay.

Edit2 - Looks to be something to do with the IIR filter which is producing silly results but can't figure out what. Assume that 11 is right for vlimflt?
Yes I had changed something just for the simulator. Let me see:

Code: Select all

      /*if (frqFiltered < FP_FROMINT(30))
         qController.SetMinMaxY(dir <= 0 ? -qlimit : 0, dir > 0 ? qlimit : 0);
      else*/
         qController.SetMinMaxY(-qlimit, qlimit);
simulator didn't like that.

vlimflt=11 is good. I had tried with that delay checkbox + syncadv 10 and got some infinite currents. So disabled it and didn't investigate further.
Bigpie wrote: Wed Nov 16, 2022 5:14 pm Sadly not, stamping from standstill still cuts out. Doing so while moving is ok it seems
Had that with Leaf motor and had to lower curkp from 150 to 60
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
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 »

That's a shame :(
Still a bit suspicious about the current sampling on low L motors. There were some very odd current waveforms in you early logs but not sure whether it was the card or real.

Edit - still also wonder whether adding transmission play to teh simulator would help with modelling those 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 »

johu wrote: Wed Nov 16, 2022 5:18 pm Yes I had changed something just for the simulator. Let me see:

Code: Select all

      /*if (frqFiltered < FP_FROMINT(30))
         qController.SetMinMaxY(dir <= 0 ? -qlimit : 0, dir > 0 ? qlimit : 0);
      else*/
         qController.SetMinMaxY(-qlimit, qlimit);
simulator didn't like that.
Thanks, that's fixed it. Could do with figuring out what the problem is or add some conditional compilation.
johu wrote: Wed Nov 16, 2022 5:18 pm vlimflt=11 is good. I had tried with that delay checkbox + syncadv 10 and got some infinite currents. So disabled it and didn't investigate further.
Running without it does make life a lot easier for the control loops but unfortunately isn't very realistic :(

Right, going to push the latest simulator code up to github then I can get to the stuff I meant to do this afternoon!
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 »

OK, latest version of the simulator that supports Rel 5.24 of the inverter code is now on github. Note the change in the above post that is needed to keep things happy.

Also note that this version will not work with previous versions of Johannes or my code!
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by johu »

Nice, thanks :)

would it make sense to tie in the matching version as a submodule?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
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 »

Could do, not sure how to tie the sub module to a specific build though?
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 »

SciroccoEV wrote: Wed Nov 16, 2022 1:57 pm It's a pretty good book, obviously a bit dated in places. It cost me something like £65 back in 1999 or so. There's a used copy on Amazon right now for £12, which is well worth it.
Was about to order this but just checked and it would be coming from the USA - £33.58 delivery :o so think I'll leave it!
Post Reply