IPM Motor - Auto-setup

Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor - Auto-setup

Post by Pete9008 »

Romale wrote: Mon May 15, 2023 5:00 pm I have repeatedly noticed that the traditional method has become inaccurate. For example, by changing the syncofs with a rotating motor, I get to the situation that the motor stops rotating at 5000 at any large manual current. I add 32768 to this number and register it in the syncofs. however, it is worth adding a FW later and stable work is obtained forward but uncontrolled rotation backwards! and only after reaching from 37768 to 42000, I get really stable work in both directions with any FW and the same rotation speed in any of the directions.

therefore, I am very much waiting for your firmware version to try to configure it with it.
Agree, a few people seem to have had issues identifying the right null and that was one of the things that started me thinking about this approach. Sounds like your issue may be slightly different though so will be interesting to see if this approach helps and how the results compare.
User avatar
Ev8
Posts: 801
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 41 times
Been thanked: 149 times

Re: IPM Motor - Auto-setup

Post by Ev8 »

I’m wondering what’s the best way to make this work with 2 motors on one shaft, I’m guessing probably with one motor in run mode with no torque or regen demands, whilst running the tests on the other motor, I always found it very hard find the centre of the deadband doing traditional foc tuning due to the additional torque required to overcome the cogging of the second motor.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor - Auto-setup

Post by Pete9008 »

Ev8 wrote: Mon May 15, 2023 7:30 pm I’m wondering what’s the best way to make this work with 2 motors on one shaft, I’m guessing probably with one motor in run mode with no torque or regen demands, whilst running the tests on the other motor, I always found it very hard find the centre of the deadband doing traditional foc tuning due to the additional torque required to overcome the cogging of the second motor.
Not too sure, whatever generates least torque resistance on the second motor. Either stopped (the speeds are so low in test mode that back emf on the second motor shouldn't be an issue) or run mode as you describe.

You have the advantage that you can use much higher currents on the tested motor which will reduce the errors significantly. I'd guess that if you went up to a hundred amps or two for the test motor then the errors should be pretty small.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor - Auto-setup

Post by Pete9008 »

The code is now on my github in the auto-setup branch.

Please note that it is currently COMPLETELY UNTESTED! There have been a lot of changes porting it back from the floating point version so bugs are likely to be present!

I have no way to test it on real hardware but at some point I'll put together a version of the simulator that supports it and give it a try in there.

If anyone is feeling brave (or possibly foolhardy!) feel free to try it.
User avatar
Romale
Posts: 441
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 204 times
Been thanked: 45 times

Re: IPM Motor - Auto-setup

Post by Romale »

Pete9008 wrote: Tue May 23, 2023 3:44 pm The code is now on my github in the auto-setup branch.

If anyone is feeling brave (or possibly foolhardy!) feel free to try it.
and how to get to the download location? there is the firmware bin file or do you need to create it yourself from the program code?
evil neodymium :twisted:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor - Auto-setup

Post by Pete9008 »

Files are here https://github.com/Pete9008/stm32-sine/tree/auto-setup, afraid you need to build the bin yourself though.

Edit - Just to be clear I'm expecting there to be a few bugs in the code given the number of edits!
User avatar
Romale
Posts: 441
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 204 times
Been thanked: 45 times

Re: IPM Motor - Auto-setup

Post by Romale »

it's not about my abilities))) I'll wait until someone smarter in this case builds the firmware. I am strong enough to solder, cut, weld, rewind, but not to program)
evil neodymium :twisted:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor - Auto-setup

Post by Pete9008 »

Fair enough.

TBH I'd want a current limited power supply when trying it for the first time too, just in case!

When I get round to testing it in the simulator I'll let you know.

Edit - I forgot to mention that this code is branched of Johannes at commit 707ccfb. This is essentially 5.24R plus all the more recent mods up to and including the overmodulation control via a parameter.
User avatar
Romale
Posts: 441
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 204 times
Been thanked: 45 times

Re: IPM Motor - Auto-setup

Post by Romale »

Pete9008 wrote: Tue May 23, 2023 4:05 pm TBH I'd want a current limited power supply when trying it for the first time too, just in case!
I don't know how other users do it, but I always check the new firmware at home on a motor with a controller connected to a small 36 volt battery via a BMS that has overcurrent protection above 120 amps.
evil neodymium :twisted:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor - Auto-setup

Post by Pete9008 »

Code has now been tested in the simulator and a couple of tweaks made.

Binary and Hex files are also now on git. Please note that this version is still completely untested on real hardware - I strongly recommend the use of caution and a current limited supply!

As mentioned before this code uses udc to estimate the initial PWM levels and so udc should be calibrated before using test mode. If using the test spin modes the curkp and curki parameters need to be set to sensible values too.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor - Auto-setup

Post by Pete9008 »

Just realised that the bit of code already in the above that sets up the PWM levels for the test is effectively measuring the motor inductance! It's not a precise measurement (as it will depend on the rotor position whether Lq or Ld is measured) but good enough to determine whether it is low or high inductance motor and so allow sensible values for curkp and curki to be set prior to doing a test spin!

Next time the PC is on I'll add the code to calculate the value and add it to the result message.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor - Auto-setup

Post by Pete9008 »

Just tried the inductance measurement in the simulator and it seems to work :)

When the phase check test is now run in addition to giving the string detailed above it also gives the approximate inductance.

When run in the simulator with Lq=0.3mH and Ld=0.15mH this is the result:
0.15_0.3mH.png
0.15_0.3mH.png (5.04 KiB) Viewed 945 times
And with Lq=2mH and Ld=1mH this is the result:
1_2mH.png
1_2mH.png (5 KiB) Viewed 945 times
The actual result should vary between Lq and Ld for the motor and depend on the exact position of the rotor relative to the poles. Will be interesting to see what the real world results are like.

Updated files are on github.

Edit - Worth noting that the equation used is purely based on the theory, it hasn't needed any 'adjusting' to get the right answer!

Edit2 - Just to be clear the idea of this is that with a new motor where you have no idea what the inductance is this should give enough information to get curkp and curki near enough to get going. For example if the inductance was 0.1mH you'd set curkp=100 and curki=2000 to start with, or if the inductance was 1mH then curkp=1000 and curki=20000, before doing the test spin.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor - Auto-setup

Post by Pete9008 »

Not directly relevant here but just so anyone using the github auto-setup branch listed above is aware it has now been updated to add a corrected temperature sensor for the Prius Gen3 heatsink temperature. More details here viewtopic.php?p=56968#p56968.

It shouldn't affect anything else but thought worth mentioning (have only used this branch because it's the only F103 one I have that is relatively up to date!)
User avatar
Romale
Posts: 441
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 204 times
Been thanked: 45 times

Re: IPM Motor - Auto-setup

Post by Romale »

has anyone already tried to compile this in .bin file?
evil neodymium :twisted:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor - Auto-setup

Post by Pete9008 »

I've complied it and the resulting bin file is on github. Is that what you mean?

As far as I'm aware no-one has tried using the auto-setup bin though

(I have tested the exact same temperature code mentioned in the above post on a F405 build though and it works fine there).
User avatar
Ev8
Posts: 801
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 41 times
Been thanked: 149 times

Re: IPM Motor - Auto-setup

Post by Ev8 »

I will test one evening this week, is the auto setup an additional mode to the firmware or a standalone software for this one purpose that’ll need changing back again once figures have been found?
User avatar
Romale
Posts: 441
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 204 times
Been thanked: 45 times

Re: IPM Motor - Auto-setup

Post by Romale »

thank you very much.
I downloaded the file and today or tomorrow I will test it on a home motor with a sine/cosine chip (kmz60)
evil neodymium :twisted:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor - Auto-setup

Post by Pete9008 »

Ev8 wrote: Sun May 28, 2023 4:01 pm I will test one evening this week, is the auto setup an additional mode to the firmware or a standalone software for this one purpose that’ll need changing back again once figures have been found?
It's additional code - it should behave exactly the same as the normal code when in run mode and only behave differently when in manual mode. It's based on 5.24r plus the more recent mods up to and including overmodulation.
Romale wrote: Sun May 28, 2023 6:09 pm thank you very much.
I downloaded the file and today or tomorrow I will test it on a home motor with a sine/cosine chip (kmz60)
Fingers crossed!

Keen to hear how you both get on with it!
User avatar
Romale
Posts: 441
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 204 times
Been thanked: 45 times

Re: IPM Motor - Auto-setup

Post by Romale »

Screenshot_20230531-152058.png
Screenshot_20230531-152201.png
Screenshot_20230531-152527.png
from the throttle handle, the motor is controlled as usual. it was not possible to get the motor rotation in manual start mode and attempt settings. a quiet squeak was like a normal start or angle search in the standard way, but there was no real rotation.

the last screenshot is the rotation of the motor in a normal start from the throttle stick (1000+ rpm from a 40 volt battery)
evil neodymium :twisted:
User avatar
Romale
Posts: 441
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 204 times
Been thanked: 45 times

Re: IPM Motor - Auto-setup

Post by Romale »

only I use the sine/cosine chip. not a resolver. could the problem be in this place? or maybe increase the manualid current?
evil neodymium :twisted:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor - Auto-setup

Post by Pete9008 »

Depends on the motor, the HSG runs fine on 10A but better on 20A (I couldn't go higher due to the limits on the PSU).

What result did phasecheck give?
User avatar
Romale
Posts: 441
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 204 times
Been thanked: 45 times

Re: IPM Motor - Auto-setup

Post by Romale »

params.json
(1.53 KiB) Downloaded 40 times
forgot. the parameters I did it with.
evil neodymium :twisted:
User avatar
Romale
Posts: 441
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 204 times
Been thanked: 45 times

Re: IPM Motor - Auto-setup

Post by Romale »

Pete9008 wrote: Wed May 31, 2023 12:38 pm
What result did phasecheck give?
in none of the tests did the motor start spinning. a little later I will check with an increased current of 20 amperes.

MGR10 alphard motor
IMG_20230531_153353_1.jpg
evil neodymium :twisted:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: IPM Motor - Auto-setup

Post by Pete9008 »

The phasecheck shouldn't spin the motor, it just returns a result to the Messages section of the web interface.

What motor are you using?

The tests should work with any type of angle sensor.
User avatar
Romale
Posts: 441
Joined: Fri May 20, 2022 4:16 pm
Location: Romania
Has thanked: 204 times
Been thanked: 45 times

Re: IPM Motor - Auto-setup

Post by Romale »

Then maybe I didn't do everything right? I was expecting the motor to turn and didn't watch the messages above))

rear engine from toyota alphard 10 generation (mgr)
evil neodymium :twisted:
Post Reply