Page 39 of 40

Re: IPM Motor Simulation and FOC Software

Posted: Tue Apr 18, 2023 11:24 pm
by johu
Just a reminder, this rather important thread is going a bit astray with boost converters and gear boxes. Can you please continue that discussion elsewhere, thanks :)

Re: IPM Motor Simulation and FOC Software

Posted: Wed Apr 19, 2023 9:23 am
by Pete9008
johu wrote: Tue Apr 18, 2023 11:24 pm Just a reminder, this rather important thread is going a bit astray with boost converters and gear boxes. Can you please continue that discussion elsewhere, thanks :)
Boost converter already split to another thread here viewtopic.php?t=3546 - but to go off topic on gearboxes again ;)
Ev8 wrote: Tue Apr 18, 2023 5:53 am Can I ask how you plan on connecting a Prius transaxle to a 5 speed gearbox? (I have done this with a Lexus rx400h transaxle it’s no small undertaking! I would advise a simpler route)
Also using the boost inductor is going to seriously limit potential power output,
I'd agree with Ev8 here, converting a FWD box to work in a RWD car is no trivial task and combined with all the work to get the boost converter working is going to make for a very challenging project. Even then the total power available is likely to be limited to just over 40kW. Something like the Outlander rear coupled on to the BMW box but still using the Prius inverter has been done a couple of times now (@bobby_come_lately 's - Z3, @FFMan 's BMW Touring. It would be a lot more straight forward and the guys might even be able to share gearbox adaptor designs? It would also give twice the power of the Prius gearbox. Not sure what availability is like there but in the UK they can be picked up for very reasonable money too.

Although having said all that if it's the challenge that attracts you then go for it :) (although probably best start a new thread to discuss further!)

Re: IPM Motor Simulation and FOC Software

Posted: Thu Apr 20, 2023 6:58 pm
by Pete9008
Just going to leave this link on feed forward terms in FOC control here for when my brains working a bit better (it might help with loop stability at higher speeds) - https://electronics.stackexchange.com/q ... rward-term

Re: IPM Motor Simulation and FOC Software

Posted: Thu Apr 20, 2023 8:29 pm
by johu
Yes, optimization time.
While Janosch drove from Dover to London I was able to monitor id/iq a bit. Found iq was regulated quite well but id was oscillating really badly, between 0 and -70A or so while cruising the highway. I think I'll add an extra kp parameter for the id controller, it seems it must be lower.

Re: IPM Motor Simulation and FOC Software

Posted: Fri Apr 21, 2023 6:58 pm
by Ev8
Interesting could this be a cause for an audible oscillating noise (sounds like a torque ripple but can’t feel it) I get when cruising that all but disappears if I lower max fw current (obviously doing so creates unwanted regen)

Re: IPM Motor Simulation and FOC Software

Posted: Sat Apr 22, 2023 6:12 pm
by Pete9008
Unless you have already ruled it out by plotting Ifw I'd be more suspicious of the field weakening controller causing the Id oscillation, especially if it's at higher speeds.

Something along the lines of FW starts to come in (-Id increases), torque drops slightly, motor slows slightly, FW drops slightly (-Id drops), torque increases, motor speeds up slightly and repeat. Could probably simulate it by modelling steady state driving uphill (to simulate drag) just as FW starts to come in and see if it happens.

Re: IPM Motor Simulation and FOC Software

Posted: Sat Apr 22, 2023 10:37 pm
by johu
Well ifw was at 0 at that point. We drove in 4th gear at 4000 rpm or so, far away from needing FW.
I've compiled a firmware that allows setting iqkp and idkp separately and will test it later in the week.

Re: IPM Motor Simulation and FOC Software

Posted: Sun Apr 23, 2023 5:46 am
by Ev8
Pete9008 wrote: Sat Apr 22, 2023 6:12 pm Unless you have already ruled it out by plotting Ifw I'd be more suspicious of the field weakening controller causing the Id oscillation, especially if it's at higher speeds.

Something along the lines of FW starts to come in (-Id increases), torque drops slightly, motor slows slightly, FW drops slightly (-Id drops), torque increases, motor speeds up slightly and repeat. Could probably simulate it by modelling steady state driving uphill (to simulate drag) just as FW starts to come in and see if it happens.
I will have to find a willing volunteer to come and do some logging with me at some point it’s so much easier with an assistant, unfortunately my wife gets bored of all this electric car stuff rather quickly!

It’s definitely medium load cruising where I hear an oscillation however as I still haven’t replaced my noisy differential I could be looking in the wrong place! Just reducing fw making a difference is odd, current software doesn’t have any tuning for the fw controller and main controller gain changes don’t seem to make a difference…
Don’t get me wrong with my whole cobbled together twin motor setup I’m never going to achieve oem levels of driveline noise!
I will jump of the simulator later and see if I can recreate and oscillation in ifw

Re: IPM Motor Simulation and FOC Software

Posted: Sun Apr 23, 2023 10:59 am
by Pete9008
Occurred to me that it's going to be very slow to reproduce this with the sim as is because it always starts from 0 so will take ages to get to steady state. To fix this you can change a line in the restart() function motormodel.cpp from m_speed=0; to say m_speed=10; (where the units are vehicle speed in m/s). The simulation will then start at that speed each time (the data will go a little crazy for the first half second at higher starting speeds while the controller tries to synchronise to the already spinning motor though). Probably worth adding this as a simulation parameter at some point in the future.

I've given it a quick try but can't reproduce any instability in the FW controller but then I may not be operating it in quite the right speed/power area.

Re: IPM Motor Simulation and FOC Software

Posted: Sun Apr 23, 2023 12:50 pm
by Pete9008
johu wrote: Sat Apr 22, 2023 10:37 pm Well ifw was at 0 at that point. We drove in 4th gear at 4000 rpm or so, far away from needing FW.
I've compiled a firmware that allows setting iqkp and idkp separately and will test it later in the week.
Oops, missed this!

That's pretty conclusive, can't be the FW controller.

It's not surprising that different kp values could be needed for the two controllers, the measurements for Lq and Ld have been showing a significant difference between the two.

Wondering whether it would be possible to actually scale the Q controller kp value by the ratio of Lq/Ld to get to a value for the D controller without having to add another parameter? Essentially have Lq and Ld parameters and then calculate lqminusld and the kp scaling factor from them. I'm also wondering whether this could be taken a stage further and the two kp values actually be calculated from the Lq and Ld values so avoiding the need to tune them - no idea whether it would work but could be worth a look?

Best way to evaluate it would be to collate everyone's tuned kp and ki values vs their motor type. Given that we now have a pretty good idea of what Lq and Ld are for most motors (and an easy way to find them for new motors) it should be fairly straight forward to see if there is a clear relationship between them.

If people want to post their motor type, Lq and Ld values (if they know them) and their kp and ki values here I'm happy to collate and graph them to see what the relationship looks like?

Re: IPM Motor Simulation and FOC Software

Posted: Sun Apr 23, 2023 2:03 pm
by Romale
Pete9008 wrote: Sun Apr 23, 2023 10:59 am The simulation will then start at that speed each time (the data will go a little crazy for the first half second at higher starting speeds while the controller tries to synchronise to the already spinning motor though).
I got into an error over current in motion at 120 km/h. I just rebooted the controller and it perfectly instantly synchronized with the motor, which had more than 6000 rpm. so there shouldn't be any problems on this side.

Re: IPM Motor Simulation and FOC Software

Posted: Sun Apr 23, 2023 2:31 pm
by Pete9008
Romale wrote: Sun Apr 23, 2023 2:03 pm I got into an error over current in motion at 120 km/h. I just rebooted the controller and it perfectly instantly synchronized with the motor, which had more than 6000 rpm. so there shouldn't be any problems on this side.
It's more when you are initialising the controllers and the motor is already spinning above base speed (so the motor voltages are already above above battery voltage so producing heavy unwanted regen - don't recommend trying this in real life!). Even then it will resync, it just takes a few hundred ms for the FW, and so the motor voltages/currents, to stabilise.

At speeds below base speed it should just sync up immediately as you describe.

Re: IPM Motor Simulation and FOC Software

Posted: Sun Apr 23, 2023 2:36 pm
by Romale
Pete9008 wrote: Sun Apr 23, 2023 2:31 pm so the motor voltages are already above above battery voltage so producing heavy unwanted regen - don't recommend trying this in real life!
the base speed of the Nissan gen2 motor is 2100 rpm at 100 volts. this gives 7560 rpm base speed at 360 volts! so everything is ok.

Re: IPM Motor Simulation and FOC Software

Posted: Mon Apr 24, 2023 8:10 pm
by johu
So for now here is the firmware with the extra gain. curkp has simply been renamed to iqkp and will keep the last saved value, idkp will start out with 32.

I just did a quick spin-up test, so as always test carefully.

Test might not be so interesting, I don't expect there to be large performance improvements, just less oscillation on id. Will test on the way to Farnborough whether it helps that.

Re: IPM Motor Simulation and FOC Software

Posted: Tue Apr 25, 2023 6:33 am
by Ev8
Cool, I will test when I get a chance, any chance of a build with the overmodulation as well or perhaps we can make modmax a parameter?

Re: IPM Motor Simulation and FOC Software

Posted: Tue Apr 25, 2023 6:36 am
by johu
Guess what's already in there 😊

Re: IPM Motor Simulation and FOC Software

Posted: Tue Apr 25, 2023 7:49 am
by Ev8
You are the best!

Re: IPM Motor Simulation and FOC Software

Posted: Thu May 04, 2023 9:04 am
by johu
Here are some plots of currents. As you can see iq is nicely controlled while id jumps all over the place. With the hill-hold function it looked like LARGER idkp actually helps reduce oscillation. In movement I couldn't spot much difference between idkp=16 and idkp=100. iqkp=60 all the time.

Re: IPM Motor Simulation and FOC Software

Posted: Thu May 11, 2023 11:58 am
by Pete9008
Missed this!

Not convinced that's control loop oscillation, it looks too stable.

I'm more wondering whether it is a harmonic/saliency. It would be interesting to see whether it is phase locked to the motor current?

Edit - If those two plots are on a similar time scale then I'm pretty sure that's a harmonic current that the control loops are too slow to handle. Been discussed before somewhere on one of catphish's induction motor threads and there was a link to a v.good article on it but can't find it now.

Edit2 - Found it - viewtopic.php?p=52161#p52161.

Re: IPM Motor Simulation and FOC Software

Posted: Sat May 13, 2023 7:34 pm
by johu
Very cool should be easy to implement.
Linking it here again: https://build-its-inprogress.blogspot.c ... onics.html

Re: IPM Motor Simulation and FOC Software

Posted: Tue Jun 13, 2023 7:50 am
by rstevens81
Just a FYI, I think the simulator might be broken with the latest release (2weeks ago)... I am am only amateur will dig a bit more and report back if i find an easy fix.
Item_0.png
ITEM_2003.png
ITEM_2004.png

Re: IPM Motor Simulation and FOC Software

Posted: Tue Jun 13, 2023 10:31 am
by Pete9008
Thanks for the heads up.

Looks like it's due to the changes on the param_prj.h file in the new release, probably just needs the Qt project version of the file updating to match the new format. Will try to have a look in the next day or so.

Re: IPM Motor Simulation and FOC Software

Posted: Tue Jun 13, 2023 3:23 pm
by Pete9008
Wondering whether the param_prj.h file in the simulator project directory could now just be deleted (the one in the OpenInverter source code would then be picked up and used by Qt instead and would still need modifying to suit your motor). If so it should fix the above problems.

Trying to remember why the replacement file was needed, think it was primarily to override the resolver, pinswap and syncofs values which could cause problems with simulation. However, the simulator should now override these in the code so the param_prj.h file changes may no longer be needed.

I'll hopefully have a look at it in the next day or so but in the meantime deleting the file might be worth a try as a quick fix?

Re: IPM Motor Simulation and FOC Software

Posted: Wed Jun 14, 2023 6:12 am
by rstevens81
Delting the file almost works....
sim.png
sim.png (7.81 KiB) Viewed 5248 times

Re: IPM Motor Simulation and FOC Software

Posted: Wed Jun 14, 2023 6:15 am
by johu
Ah that's because these kps have been split into idkp and iqkp
Will need to be accounted for by adding an edit field to the GUI