IPM Motor Simulation and FOC Software

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: IPM Motor Simulation and FOC Software

Post by johu »

Very good, I will code something up in the coming days and post it here
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by arber333 »

I just ordered another cheap HSG motor. I will love to design a belt drive for both of them. Any particular request for my setup?
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 »

For me it needs to be high speed testing to check at what speed the control loops go unstable.

See here https://openinverter.org/forum/view ... 49#p49849 for more details or search for "latency" in this thread.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by arber333 »

Pete9008 wrote: Tue Dec 13, 2022 1:13 pm For me it needs to be high speed testing to check at what speed the control loops go unstable.

See here https://openinverter.org/forum/view ... 49#p49849 for more details or search for "latency" in this thread.
Ok i am working on a 12krpm setup which is something HSG is fully capable of. This is the reason i bought two of the same.
I will think on using less voltage from battery to raise FW threshold. Bt i think any motor i seen starts to FW past 8000RPM

Since we are talking control loop instability, i can go further and provide a setup for testng both drive and regen at high speeds.
I will use Volt inverter dual IGBTs with Lebowski on one side and OI on the other side.
My Lebowski version controler is incredibly stable at high RPM. I can use this to drive one motor and force OI to regen into it and get some data usually you only get in a car downslope.
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 »

Sounds good :)

How many pole pairs does the HSG have?

Edit - see https://openinverter.org/forum/viewto ... e#p46938 , 4 pole pairs and 30rpms/volt so reducing voltage may be beneficial.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: IPM Motor Simulation and FOC Software

Post by arber333 »

Pete9008 wrote: Tue Dec 13, 2022 1:41 pm Sounds good :)

How many pole pairs does the HSG have?
3 pole pairs
Here is the data
viewtopic.php?p=29225#p29225

And some testing from my side viewtopic.php?p=26602#p26602
Video of simiar power section...
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, will need to go to a slightly higher speed to compensate for the reduced pole count.
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 »

still having issues building a working version of the sim, again, God only kno how it worked once but not since! obviously if you git clone the stm32-sine repo itll clone the latest commit, but the sim readme asks for 5.24 so what is the best SHA to build from?


also when building in qt creator i get a whole host of issues, most seem to be referring to unused variables, but there are a couple of wreorder issues flagged up, is this a problem?
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: IPM Motor Simulation and FOC Software

Post by johu »

This one's got stm32-sine linked as a submodule: https://github.com/jsphuebner/IPMMotorSim/
Plus a Makefile in the build/ directory so you don't need to launch QTCreator

Code: Select all

git clone --recurse-submodules https://github.com/jsphuebner/IPMMotorSim.git
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 »

Just done a clean checkout to test and it all seems to work fine, I did:

Code: Select all

git clone https://github.com/Pete9008/IPMMotorSim
cd IPMMotorSim/
cd IPMMotorSim/
git clone --recurse-submodules https://github.com/jsphuebner/stm32-sine
opened qt, opened the project, accepted the default config, rebuilt and ran and it works fine.

I do change a line at the top of pwmgeneration-foc.cpp from

Code: Select all

#define QLIMIT_FREQUENCY FP_FROMINT(30)
to

Code: Select all

#define QLIMIT_FREQUENCY FP_FROMINT(-1)
to clean up the plots at low speed but that's it (and it will run fine without the change).

I get 126 warnings pretty much as you describe. Really should look at tidying them up sometime!

Would be worth letting us know what OS you are on and what version of Qt?
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 »

Thanks will try a clean build of everything again, running windows 10, version 22h2 and qt 6.4.1

I use wsl and Ubuntu for compiling stm ect and have managed to build the sim using Johannes makefile bit unsure of what to do with the output it creates…
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've only tried it on Linux (Mint/Ubuntu), will give it a try on Windows tomorrow.
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 »

Thanks guys I think i'm back up and running, no idea what was going on there but a fresh start seems to have things giving more repeatable results
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: Thu Dec 22, 2022 11:05 pm Thanks guys I think i'm back up and running, no idea what was going on there but a fresh start seems to have things giving more repeatable results
Glad you got it working :)

You've done better than me - I had a go on windows but all I've managed to do is to kill the Qt install. It was an old version that didn't support charts, updated it but somehow messed up the whole install, removed and reinstalled and Qt Creator still won't run!

I now remember why I rarely use Windows these days!

If you have a choice of OS then Linux may be best for Qt.
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 »

Links to what might be considered the most interesting/useful post in this thread now linked in first the post. Let me know if there is anything else that should be linked there. Still need to do some operating instructions though!

Edit - have also edited the motor theory post to include the later understanding of how the critical current impacts on field weakening.
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, (past) time for some instructions on how to use!

The IPM Motor Simulator - What is it
At its core the simulator is a mathematical model of an Interior Permanent Magnet (IPM) motor. This is wrapped with a Graphical User Interface (GUI) program that allows the voltage stimulus applied to the model, and the resulting motor currents and rotor position from the model, to be graphed. The program also includes hooks to allow the core control code from the OpenInverter (OI) firmware to be used to control the motor. The GUI allows the relevant parameter within the OI firmware, and the motor model parameters, to be adjusted to see what effect changes may have.

Please note that it is just a model, don't assume that just because code runs OK in the simulator that it will work in the real world, it's a different compiler and is running without any execution speed limitations found in the real world and does not simulate the full hardware system. Use just as much caution in real testing as you would without the simulator.

Now the model isn't perfect, and it isn't supposed to be, but it is pretty close and good enough for its intended purpose which is to allow an understanding of the effect of parameter changes and to provide a safe way to evaluate OI code changes before testing in the real world.

Now because it includes the OI code, and because it is intended that you can try different versions of the OI code, it is available as full source code rather than an executable, i.e. you have to install the development environment/compiler as well as the simulator source code and OI firmware and then build the code before you can use it. The process is pretty straightforward and allows the code to be run on multiple platforms (Linux, Windows and Mac to date), it also allows full source code debugging if you want to use it to develop the code or look for problems. The first thing to do is therefore to install the Qt development environment.

Installing Qt
To quote Wikipedia "Qt is cross-platform software for creating graphical user interfaces as well as cross-platform applications that run on various software and hardware platforms such as Linux, Windows, macOS, Android or embedded systems with little or no change in the underlying codebase while still being a native application with native capabilities and speed.". It comes in both open source and commercial versions and for home use the open source version is fine.

To install download the online installer from https://www.qt.io/download-qt-installer. You will also need to register for a Qt account. The default installation options should be fine. If you want to do a minimal install then you don't need the examples, documents or any extra architecture support although if you plan to use Qt for other work they might be worthwhile. Individual packages can always be removed or added post install too.

I don't have any screen captures for this but there are plenty of install guides for Qt online.

Installing the Simulator and OpenInverter Software
This assumes that git is already installed, if not you will need to install that first (https://github.com/git-guides/install-git)

Go to the directory where you would like to install and do:
git clone https://github.com/Pete9008/IPMMotorSim
cd IPMMotorSim/
cd IPMMotorSim/
git clone --recurse-submodules https://github.com/jsphuebner/stm32-sine
This will copy the simulator code onto your machine and copy the OpenInverter code into a subdirectory within it.

Johannes also has a fork of the repository which already includes the OI code it can be installed using a single command:
git clone --recurse-submodules https://github.com/jsphuebner/IPMMotorSim.git
Currently the only difference between the two is the way a line of OI code is handled, Johannes automatically comments out a line of code that causes an oscillation in the simulator output but keeps it for real firmware builds. I'm not too keen on this as I believe the line also causes problems in real life and I'd prefer to understand and fix it rather than mask it in the simulator and so I haven't pulled this change. See here for details viewtopic.php?p=49172#p49172. Otherwise both work the same.

Building the Software
Open Qt, go to 'Open Project' (either in the File menu or on the Home screen), browse to the directory where you installed the simulator and then go down into the 'IPMMotorSim' subfolder twice. In there there should be an 'IPMMotorSim.pro' file. Open this and you will get a 'Configure Project' dialog, just accept the default for this. You should see something like this:
start.png
To build the software go to 'Build' at the top and select 'Rebuild Project: IPMMotorSim'. This should do a full build of the simulator software and the OI firmware. On my Qt install (which is a little out of date) this results in 53 warnings. They are non-critical (mostly to do with type conversion in the OI fixed point math).
issues.png
With that done you can run the software either by clicking the 'Run' button (green triangle at the bottom left), the 'Start Debugging' button (other green triangle with a bug icon) or by selecting the same from the top menu. With that done you should see something like this:
initial.png
Now on the first run the window positions are not set so the first thing to do is to set the windows up how you like them, this is how I set it up:
ScreenPositions.png
On subsequent runs these positions are remembered. It's worth noting that the more windows you have active the slower the results are to draw so there is no point having windows up that you don't use.

The last thing to do is run the simulator to see if everything works, first change the values for Lq to 4 and Lq to 2 (so that it matches the Lq-Ld setting of 2 that has been pulled from the param file) and hit 'Run (1s)', you should see something like this:
FirstRun.png
Edit - Jan23 Updated to reflect code changes
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 »

Part2 - How to Use the Simulator

The first screen to explain is the main data entry and control window:
DialogWin2.png
This is split into 4 areas and I'll explain each of these in turn.

The first is the 'Vehicle Parameters'. These are the settings that only affect the motor model, they basically configure the model to match the parameters of your motor and vehicle, they can either be measured (see earlier posts in thread for details) or found online. The closer they match your vehicle/motor the closer the simulator results will be to the real world. The values are:

Vehicle Weight - The weight in kg of the vehicle. This is used to calculate how quickly the motor can accelerate for a given torque.
Wheel Radius - The rolling radius of the vehicle wheels. Again used to calculate how quickly the motor can accelerate for a given torque.
Gear Ratio - The total gear ratio (gearbox + diff if separate). Again used to calculate how quickly the motor can accelerate for a given torque.
Vdc - This is the HV bus voltage that supplies the inverter. It is used to converts from the OI PWM values to the effective voltage applied to the motor.
Lq - This is the quadrature inductance of the motor (inductance with the rotor at 90degress to the PM field). It determines how the motor current changes in response to applied voltage.
Ld - This is the direct inductance of the motor (inductance with the rotor aligned to the PM field). It determines how the motor current changes in response to applied voltage.
Rs - This is the series resistance of the motor windings. It determines how the motor voltage changes in response to current.
λ - This is the Flux Linkage of the motor. It determines how effectively the magnetic flux links to the rotor and affects the torque and back EMF of the motor. NOTE - this value is the exception in that it is pulled from the param_prj.h file and used in both the motor model and OI firmware (see comments below for details on the param_prj file).
SyncDel - This is compensation for the difference in time between the motor position and motor current measurement within the OI firmware. It should be left at 16.
Loop Frequency - This is the frequency of the main motor control loop. It is always 8800 for OI.
Sampling Point - This compensates for the OI current sampling point relative to the control loop interrupt/run point. Leave at 50% for current OI versions.
Extra Cycle Delay - This enables the addition of a clock cycle delay to accurately represent the PWM Timer reload in OI firmware and should be left ticked. (Note - unticking will appear to increase the stability of control loops in the simulator but this is not representative of the real world).
Add Noise - This adds artificial noise to the motor current measurements and can be used to asses the effect of real world noise on control loop stability.
Road Gradient - This adds a road gradient, positive is uphill, negative is downhill, Used to introduce acceleration/deceleration into the coasting/zero torque test case (a downhill coast is quite a severe test for the FW and throttle limit control loops).
Use Throt Ramps - This adds throttle ramps to limit how quickly throttle changes are applied to the control loop. Ticking reflects the ramps present within typical OI configurations. Unticked gives the worst case transient for when testing control loops stability.


Next is the OpenInverter Parameters section. These are all fields from within the param_prj.h file which are made available here to allow them to be adjusted easily. Any changes to their values are NOT persisted across program runs but are instead re-initialised from the param_prj.h file on each program start up. It is suggested that the param_prj.h file is modified to reflect any changes that you would like to make permanent. Please note that some parameters in the files that you may expect to have an effect are ignored (syncofs, pinswap and respolepairs). All parameters that affect the higher level vehicle control functions of OI are also not used.
NOTE - the param_prj.h file used in simulator builds is the one on the simulator directory, NOT the one in the OI build tree that is used for firmware builds. It is up to the user to keep these files synced if required.
NOTE - the simulator must be rebuilt following any changes to the param_prj.h before the simulator will use the new values.

These are all standard OI parameters so I'm not going to go into each. A few fields here are worth mentioning though:
Motor Poles - This needs to match the real motor otherwise torque calculations will be wrong.
Lq - Ld - This is completely separate to the Lq and Ld settings in the Vehicle Parameters pane. It is done this way to allow the effect of mismatches to be assessed but for normal operation they should match!
SyncAdv - This is different to the syncadv pre OI 5.24 and should normally be left as set. Very high or very low inductance motors may benefit from a slight change in the value.
FMax doesn't do anything, this is implemented the higher vehicle control levels of OI and these are not included in the simulator. It has been left in as an additional speed limiter in the low level OI code has been talked about and may get included in the future.

Next Run Controls
These are fairly self explanatory and just control the running of the simulation and run for a set time or restart the simulation. Slightly less obvious ones are:
Numeric field - The time the simulation will run for when using the 'Run For (s)', 'Transient' or 'Accel/Coast' buttons.
Step - This is primarily used when debugging code using the Qt debugger. It allows the OI control loop to be run a single time only.
Transient - This runs for a period at zero torque, a period at 'Torque Demand' torque, a period at zero torque and finally a period at 'Torque Demand' torque. The period is set from the numeric field. This can be useful when testing control loop transient response and overshoot.
Accel/Coast - This runs for a period at 'Torque Demand' torque and then a period at zero torque. It can be useful when testing field weakening.

And finally Window Visibility. This doesn't affect the simulation results in any way but reducing the numbers of displayed windows, or the number of displayed traces, does significantly increase the display update speed. Window visibility settings are persisted across program runs, as are window sizes and screen positions. The radio buttons for the Power/Torque window allow selection of the horizontal axis, plotting against speed is useful for generating traditional power/torque plots, time is useful when trying to correlate against the other plots. Similarly the radio buttons for the Operating Point window allow the display of either Amp or Volts. The checkboxes allow the three phase values to be shown or not on each of the corresponding plots (disabling speeds up redrawing by about 30%)

The windows are:
Operating Point
opPoint.png
opPoint.png (17.48 KiB) Viewed 3691 times
This is probably only useful if you are looking at developing MTPA or MTPV control algorithms. The Id and Iq currents, or Vd and Vq voltages, are shown on the two axis, the green circle shows the maximum current or voltage circle and the blue trace shows the operating point of the motor. Please note that the voltage circle includes the space vector allowance so can be higher than may be expected based on Vdc. In the plot above you can see the operating has moved along the MTPA line as the motor accelerates until it hits the current limit and then dropped down as FW comes in. The plot would look different for low inductance motors.

Simulation
Sim.png
Basic simulation data, motor electrical speed, motor rotor angle, and controller (motor electrical) position. To speed up rendering the position traces can be disabled.

Controller Voltages
cVolt.png
This plot provides the motor voltages imposed on the motor by the controller PWM output value. This is not the true motor voltage, as the output is a PWM value, but is the equivalent non-PWM voltage that would produce the same motor currents. NOTE - these voltages are referred to an imaginary ground and so the space vector modulation is visible. The voltages actually seen by the motor would not have the space vector ripple on them (it cancels out across the three phases). If you don't like seeing the space vector ripple then comment out the three lines at line 413 of mainwindow.cpp and uncomment the three lines at line 445. The equivalent direct and quadrature voltages are also shown and are usually more useful than the phase voltages. To speed up rendering the phase voltage traces can be disabled.

Controller Currents
cCur.png
This plot provides the motor currents as seen by the controller. NOTE - the controller view is only correct if the current sampling point, rotor position sampling point, and sampling time offsets are all correct. If they are then this plot will match the Motor Currents plot, if not the values of Id and Iq will drift apart with frequency. Once setup correctly (and the settings above will do that) and the two plots agree there is little point in having both current windows up. Also shown is field weakening current and throttle reduction (Ud/Uq limiting).

Motor Voltages
mVolt.png
This plot shows the components of the motor voltages as calculated from the motor equations. Each term of the equations are plotted on a separate trace. This plot is only really of value if you want to understand the interaction of the equation terms and would normally not be enabled.

Motor Currents
mCur.png
This plot shows the motor currents. Note that these are the actual and correct motor currents, if the controller currents and motor currents disagree then these are the correct ones and the sampling parameters (probably SyncAdv unless you have changed SyncDel or Sampling Point from their defaults) needs adjusting. It is worth noting that these should always be sinusoidal as the motor does not 'see' the space vector modulation at all, just a 15% bigger sine wave than would otherwise be possible. If over-modulation is used then some waveform distortion is to be expected. To speed up rendering the phase voltage traces can be disabled.

Power/Torque
p_t.png
This plot is fairly self explanatory. Use a time x-axis if trying to correlate against other plots and a speed axis if you would like a traditional power/torque plot. The plot is calculated from the shaft power of the motor, the electrical power going into the motor is not calculated but will be slightly higher (resistive winding losses). Magnetic and mechanical losses are not allowed for.

Zooming and scrolling on the plots is possible but not very sophisticated and currently there is no way to automatically synchronise the x-axis of the plots. To zoom use the + or - keys or draw a rectangle to zoom in on. To pan use the arrow keys. The easiest way to reset the zoom is to Step the simulation. The plotting is one area of the simulator that could probably do with a bit of work (it was quickly cobbled together from Qt examples) but realistically I can't see it happening any time soon. If anyone else want to have a look at it though feel free :)

Few other tricks are worth mentioning. Simulations can get a bit slow if trying to be true to life. If you want to simulate things quickly try dropping the weight of the car to allow it to change speed faster (I typically use 100-500kg for initial runs and only revert to actual weight when almost there).

It's worth simulating both with pack full and pack empty voltages as it can make a significant different to where FW comes in.

Finally if you are interested in the OI code the Qt debugger is fully integrated into the environment and works well with the simulator. For example:
debug.png
This is with a breakpoint set in the middle of the main control loop (the red dot by the line numbers), the values of frqFiltered, ud and uq are shown on the right, you can single step through the code (while watching how the values change), push down into subroutines, set more breakpoints etc. Hovering over variables also shows their values. For debugging, or just understanding how code works, I find it invaluable. With the simulator it also has the advantage that it's safe, hitting a breakpoint in firmware controlling a real running motor can be problematic to say the least! With the simulator when you hit a breakpoint everything stops, including the motor model, allowing you to continue as if the breakpoint hadn't happened. Without the debugger I very much doubt that any of the fixed point overflow bugs would have been found and I definitely wouldn't have developed the understanding of the way the code works. If you are used programming without a debugger then it is worth having a play with it just to see what you are missing!

Edit - Jan23 Updated to reflect code changes
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: IPM Motor Simulation and FOC Software

Post by johu »

That's great!

Copied to wiki, so far without images: https://openinverter.org/wiki/IPM_Motor_Simulator
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 »

johu wrote: Sat Jan 07, 2023 2:07 pm That's great!

Copied to wiki, so far without images: https://openinverter.org/wiki/IPM_Motor_Simulator
Ta, might need updating now though.

Must say I definitely don't miss the documentation stage of project work!
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 »

Probably worth adding a link to some of bexander's results here:
MGR plots - viewtopic.php?p=50872#p50872
How to calculate Ld and Lq from plots - viewtopic.php?p=50942#p50942
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 »

Important note - when changing the param_prj.h file in the IPMMotorSim directory of the simulator only change the parameters that are also present in the gui. Changing other parameters, such as pinswaps and syncoffs values can seriously affect performance of the simulator (in a bad way).

Thanks to bexander for finding this bug :)

Edit - and apologies to Ev8, I think this may have been the cause of your problem, sorry I didn't figure it out sooner :(

Edit2 - in the next simulator release I'll change it so that any parameters that could disrupt the simulation are overridden on program start. Doing that would allow the standard car param file to be used unchanged. Until then just make sure syncoffs is set to zero in the param_prj.h file
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 - above bug now fixed and the new code is on github (https://github.com/Pete9008/IPMMotorSim).

Changes are:
  • Should be able to change any parameters in the param_prj.h file now without breaking the simulator (let me know if not)
  • The resolver pole pairs is now not used and the motor pole pairs is used for everything.
  • Bug on motor pole pairs fixed, van now change at any time.
  • Operating point plot can now be selected to show either Volts or Amps
  • Can now choose whether to display the phase currents and voltages on the plots (turning them off makes rendering the plots around 30% faster)
  • Edit - And cleared around 2/3 of the build warnings (rest are due to OI firmware fixed point macros so have been left)
Going to update the instructions above now and then if I don't run out of time have a go at copying them on to the wiki. - Done
User avatar
mjc506
Posts: 343
Joined: Wed Sep 09, 2020 9:36 pm
Location: Wales, United Kingdom
Has thanked: 30 times
Been thanked: 28 times

Re: IPM Motor Simulation and FOC Software

Post by mjc506 »

Just a note to mention that you may need to delete saved preferences if updating/unbreaking/starting fresh - ~/.config/OpenInverter/IPMMotorSim.conf on Linux
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, meant to mention that but forgot!

Not quite so easy on windows though, on that it's saved in the registry under OpenInverter.

Edit - I'm curious now, what broke and caused you to go looking for that?
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: IPM Motor Simulation and FOC Software

Post by bexander »

Nice upgrades to the sim!
Post Reply