Testing FOC for synchronous motor

kiwifiat
Posts: 99
Joined: Sat Dec 22, 2018 9:39 pm
Location: Vancouver, Canada
Been thanked: 10 times

Re: Testing FOC for synchronous motor

Post by kiwifiat »

johu wrote: Fri Jul 12, 2019 4:14 pm Now I'm starting to wonder if there is some kind of asymmetry built into the leaf motor. In one direction I can spin up to almost any speed (off the scale of the 8krpm rev counter). Now if I only change the sign of the desired iq it does spin in the other direction as expected but it doesn't spin as fast and has a tendency to trip out. It could be the motor spins in the other direction when in the Leaf.

So, anyone ever experienced a preferred spinning direction with the Leaf motor?
There is no asymmetry, if there was you would see a different BEMFF wave form when you rotated the rotor clockwise versus anti-clockwise. What you are observing is likely due to your offset being not quite right. Consider the case of a brushed motor, neutral timing is achieved when the speed of the motor is the same in both directions and that is achieved by adjusting the brush position. You may be able to use a variation of this to tune your offset.
User avatar
johu
Site Admin
Posts: 5789
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1023 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

kiwifiat wrote: Fri Jul 12, 2019 6:12 pm There is no asymmetry, if there was you would see a different BEMFF wave form when you rotated the rotor clockwise versus anti-clockwise. What you are observing is likely due to your offset being not quite right. Consider the case of a brushed motor, neutral timing is achieved when the speed of the motor is the same in both directions and that is achieved by adjusting the brush position. You may be able to use a variation of this to tune your offset.
arber333 wrote: Fri Jul 12, 2019 5:01 pm Yes i had the same experience with Pauls controler, but at 100Vdc. Can you try changing the resolver wires and phases and then spin it in another direction with positive Iq? Maybe it is asymetrical only when progressing not reversing. I remember someone said IPM motors effect is similar to ACIM slip in one direction.
Ok, contradiction :)
kiwifiat: do you KNOW that there is no asymmetry or do you not deem it possible? Have you run the motor at full speed&power in both directions with another controller?

arber: what exactly did you oberserve?

I can software-swap sin/cos, phase 1/2 and i1/i2. And I can rotate syncoffset by 180°. It seems none of the combinations change the fact that the motor spins better in one direction than in the other. Will keep trying.

EDIT: asymmetric rotors have been investigated: https://www.researchgate.net/publicatio ... b/download
It doesn't state a preferred spinning direction (I only skimmed the document) but looking at the rotor structure I could imagine there is one
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Rogue_Ant
Posts: 3
Joined: Thu Jan 03, 2019 6:27 pm

Re: Testing FOC for synchronous motor

Post by Rogue_Ant »

The Leaf's bEMF is the "Benchmark IPM":
Nissan_Leaf_bEMF.JPG
It is a little difficult to see, but there is no obvious asymmetry - and I would be very surprised if there was any intentional asymmetry.

(Sorry if this is known/obvious)
The resolver rotor/stator must be aligned with the emag rotor/stator. This can be done by having a resolver rotor fixed to the emag rotor, and the resolver stator has adjustment. Then on motor assembly, the resolver stator is adjusted to get the correct position vs the bEMF waveform, usually at the bEMF zero-crossing - such as this:
Resolver_Setting.JPG
Alternatively, the resolver stator can have no adjustment, and instead an 'offset' is applied in software to account for any variation due to stack-up tolerance.
If you cannot adjust the resolver mechanically, then the offset must bet done in software. If it is not done, then Id & Iq calculations will be incorrect.
User avatar
johu
Site Admin
Posts: 5789
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1023 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Ok, I finally found a combination of swapped signs and inputs that allows spinning up to high speed in forward. I'm still not quite there, but did a nice test drive doing 80km/h and very fine controllable regen. Will attach software & params later.

Now motor asymmetry after all.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
johu
Site Admin
Posts: 5789
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1023 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Ok, some more details now:
  • Tweaked signal acquisition (faster ADC sampling, filtering over 3 instead of 12 values, sample resolver every time)
  • Changed signs:
    • il1/il2 gain now positive
    • Messed with Clarke transformation: textbook ib = i1/sqrt(3) + 2 * i2 / sqrt(3). Mine ib = -i1/sqrt(3) - 2 * i2 / sqrt(3)
  • Changed inputs
    • resolver sin/cos back to original order, now angle counts UP when going forward
    • Swapped phase 1/2 PWM output and current
So the result is that angle now counts up when going Touran-forward. I can spin up to about 5000rpm weirdly with iq setpoint negative. It seems the id set point doesn't really have an effect right now.

I'd really like to understand what I'm doing but I guess I'll just keep on swapping stuff around until I get the expected results and then try to understand what I did. I'm not really sure if I have the current sensors and PWM outputs in the right order in hardware. Maybe that's part of the problem.

Anyway I'm glad I got this far today, the car is really very drivable now.
Attachments
Leaf 2019-07-13.json
(1.25 KiB) Downloaded 83 times
stm32_sine.zip
(61.12 KiB) Downloaded 89 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
johu
Site Admin
Posts: 5789
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1023 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

So I have finally found a combination that lets me spin up to 8000rpm (possibly more) in forward, produces good torque, doesn't trip out and actually follows the iq and id commands that I give pretty much.

I did swap signs in the reverse Park transformation (until I got the desired result) and then wondered WHY it now works. Well, I did get a chance to look at Paul Holmes board (for the Gen 1 Leaf) and it very much looks like I've swapped phases 1 and 3 on the adapter board.

I will verify this later but for now here is a software and parameters that work rather well.
I also figured that "field weakening" adds torque in the low rev range also (actually this was expected from an IPM motor). So we don't need to start commanding more id only above certain rpm but can constantly command the same id (scaled by throttle pedal, obviously)

As regen in forward means accelerating in reverse the car currently accelerates when you roll backward in a forward gear. So I'm aware of that glitch and will fix it.

Video coming.
Attachments
stm32_sine.zip
(61.12 KiB) Downloaded 77 times
Leaf 2019-07-14.json
(1.26 KiB) Downloaded 88 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
kiwifiat
Posts: 99
Joined: Sat Dec 22, 2018 9:39 pm
Location: Vancouver, Canada
Been thanked: 10 times

Re: Testing FOC for synchronous motor

Post by kiwifiat »

johu wrote: Sat Jul 13, 2019 9:20 am
Ok, contradiction :)
kiwifiat: do you KNOW that there is no asymmetry or do you not deem it possible? Have you run the motor at full speed&power in both directions with another controller?

arber: what exactly did you oberserve?

I can software-swap sin/cos, phase 1/2 and i1/i2. And I can rotate syncoffset by 180°. It seems none of the combinations change the fact that the motor spins better in one direction than in the other. Will keep trying.

EDIT: asymmetric rotors have been investigated: https://www.researchgate.net/publicatio ... b/download
It doesn't state a preferred spinning direction (I only skimmed the document) but looking at the rotor structure I could imagine there is one
I have run a gen2 Leaf motor in both directions using a Lebowski controller and in either direction the no load rpm was the same which leads me to the conclusion that there is no asymmetry in Kv or Kt. Certainly the photos I have of the Leaf rotor show no asymmetry in its construction but it is possible to introduce asymmetry into the magnets and I believe that adds expense to the magnet manufacturing process.
kiwifiat
Posts: 99
Joined: Sat Dec 22, 2018 9:39 pm
Location: Vancouver, Canada
Been thanked: 10 times

Re: Testing FOC for synchronous motor

Post by kiwifiat »

johu wrote: Sun Jul 14, 2019 11:31 am So I have finally found a combination that lets me spin up to 8000rpm (possibly more) in forward, produces good torque, doesn't trip out and actually follows the iq and id commands that I give pretty much.

I did swap signs in the reverse Park transformation (until I got the desired result) and then wondered WHY it now works. Well, I did get a chance to look at Paul Holmes board (for the Gen 1 Leaf) and it very much looks like I've swapped phases 1 and 3 on the adapter board.

I will verify this later but for now here is a software and parameters that work rather well.
I also figured that "field weakening" adds torque in the low rev range also (actually this was expected from an IPM motor). So we don't need to start commanding more id only above certain rpm but can constantly command the same id (scaled by throttle pedal, obviously)

As regen in forward means accelerating in reverse the car currently accelerates when you roll backward in a forward gear. So I'm aware of that glitch and will fix it.

Video coming.
That is more great progress in the right direction.

I recall Paul Holmes commenting about the fact that Nissan had changed the polarity of the current sensor outputs between Gen1 and Gen2 inverters , that is to say current flowing into or out of each phase, and I strongly suspect this is the root cause of your issues around the sign of Iq and Id as it undoubtedly affects the clark/park transforms.

Field weakening increases Kv and hence reduces Kt so introducing field weakening at any point below the base operating rpm is counter productive to torque generation. What it does do is increase the useful operating range of the motor.

Edit: In this video Paul explains how the polarity changed for the current sensors between gen1 and gen2:

User avatar
johu
Site Admin
Posts: 5789
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1023 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Thanks, will check that out.

So almost perfect test drive today.
I found that the current sensors are mounted in the "correct" direction. When I inject current INTO the IGBT module I get a negative reading. I also checked that I did NOT swap the current sensors on the adapter board
I now swapped phases 1-3 on the PWM output and everything falls into place:
  • FOC signs as in the various reference implementation
  • No swapping of current sensors needed
  • No negative gain on current sensors needed
  • with the correct syncofs positive iq spins forward, negative backward.
  • Motor spins up smoothly to 8000rpm (no more tested) with very little current draw
The only weirdness is left as soon as the ud/uq voltages are capped. Then torque suddenly drops out. Up until about 5000rpm full torque is available.

I very much recommend this "release" for all sync motor users.
Attachments
Leaf 2019-07-23.json
(1.25 KiB) Downloaded 81 times
stm32_sine.zip
(61.2 KiB) Downloaded 72 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
purplespark
Posts: 52
Joined: Fri Feb 15, 2019 10:22 am
Location: United Kingdom

Re: Testing FOC for synchronous motor

Post by purplespark »

Well done , Johannes !
Just to be clear , do I swap PWM phases 1 and 3 , top and bottom , on the adapter board ?
Almost ready to try spinning the motor .
User avatar
langoo
Posts: 65
Joined: Thu May 09, 2019 6:27 pm
Location: Varberg, Sweden

Re: Testing FOC for synchronous motor

Post by langoo »

johu wrote: Tue Jul 23, 2019 11:20 am Thanks, will check that out.

So almost perfect test drive today.
I found that the current sensors are mounted in the "correct" direction. When I inject current INTO the IGBT module I get a negative reading. I also checked that I did NOT swap the current sensors on the adapter board
I now swapped phases 1-3 on the PWM output and everything falls into place:
  • FOC signs as in the various reference implementation
  • No swapping of current sensors needed
  • No negative gain on current sensors needed
  • with the correct syncofs positive iq spins forward, negative backward.
  • Motor spins up smoothly to 8000rpm (no more tested) with very little current draw
The only weirdness is left as soon as the ud/uq voltages are capped. Then torque suddenly drops out. Up until about 5000rpm full torque is available.

I very much recommend this "release" for all sync motor users.
Isn't it above 5000 rpm, variations regarding system voltage, that you would need to use field weakening to over come that problem with tourque drops? Or is it something else causing the problem?
purplespark wrote: Tue Jul 23, 2019 12:52 pm Well done , Johannes !
Just to be clear , do I swap PWM phases 1 and 3 , top and bottom , on the adapter board ?
Almost ready to try spinning the motor .
I think Johannes have swaped them in the code, think he wrote that earlier but I can be wrong.
Robin Hellström
MR Electronics AB
User avatar
johu
Site Admin
Posts: 5789
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1023 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Oh sorry, don't touch the hardware. The FOC software has a "pinswap" parameter that will swap pins in software. pinswap=4 will swap PWM. pinswap=2 swaps resolver sin/cos and pinswap=1 swaps il1, il2 (for FOC only). Combinations work as well. So for the Gen2 Leaf adapter board pinswap=4 is correct.

EDIT: Robin just saw your post. I think I found the culprit, it is LimitVoltages(). The maximum amplitude for id is off. Have done some simulations and will test drive tomorrow.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
langoo
Posts: 65
Joined: Thu May 09, 2019 6:27 pm
Location: Varberg, Sweden

Re: Testing FOC for synchronous motor

Post by langoo »

johu wrote: Tue Jul 23, 2019 6:42 pm Oh sorry, don't touch the hardware. The FOC software has a "pinswap" parameter that will swap pins in software. pinswap=4 will swap PWM. pinswap=2 swaps resolver sin/cos and pinswap=1 swaps il1, il2 (for FOC only). Combinations work as well. So for the Gen2 Leaf adapter board pinswap=4 is correct.

EDIT: Robin just saw your post. I think I found the culprit, it is LimitVoltages(). The maximum amplitude for id is off. Have done some simulations and will test drive tomorrow.
Look forward for some new results then ;)
Robin Hellström
MR Electronics AB
User avatar
johu
Site Admin
Posts: 5789
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1023 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

So, test drive very successful :) torque is now even from 0-6500rpm. iq=300A, id=-200A.Maybe it stays even above that, but I couldn't test. At about 7000rpm I got a sudden shock in the drive train. I could see Uq (the voltage the creates iq) suddenly started oscillating. Over current shutdown, of course. When I restarted the inverter was in a bad mood and the motor was jumpy. Power-cycling solved this, so something must have been in a weird state. Will check what it could possibly be.

Other tests: When iq=0 I can still spin up to 7000rpm in idle. Thats surprising. I can say for certain now that ADDING id INCREASES torque. It makes total sense because the loss in "magnetic" torque is over-compensated by reluctance torque. A ratio iq/id of 3/2 generates most torque, increasing further doesn't seem to help.

In the attached software "throtramp" is for both ramping up and down. Just so the motor isn't thrown into regen too suddenly. The PI regulator is not amused. Also throtramp can be <1 for even slower ramping
Attachments
stm32_sine.zip
(61.1 KiB) Downloaded 61 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
johu
Site Admin
Posts: 5789
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1023 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

just read up on anti-windup. It seems you don't only need to limit the error sum but also stop integrating once your output saturates.
Also one thing is wrong in general: id is ALWAYS proportional to throttle input. So if you've spun up to 10000rpm and go off throttle -> 0 id -> full back EMF. So above a given frequency I have to constantly maintain id, somehow
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
langoo
Posts: 65
Joined: Thu May 09, 2019 6:27 pm
Location: Varberg, Sweden

Re: Testing FOC for synchronous motor

Post by langoo »

johu wrote: Wed Jul 24, 2019 7:01 pm At about 7000rpm I got a sudden shock in the drive train. I could see Uq (the voltage the creates iq) suddenly started oscillating. Over current shutdown, of course. When I restarted the inverter was in a bad mood and the motor was jumpy. Power-cycling solved this, so something must have been in a weird state. Will check what it could possibly be.
This sounds like the problem I've had with my inverter with Paul's board, at a system voltage of 300Vdc. This is the problem I suppose that field weakening would solve in favor of horsepower.

Keep resting and let us know! You've come a good chunk closer to a great product :)
Robin Hellström
MR Electronics AB
User avatar
johu
Site Admin
Posts: 5789
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1023 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

So one step closer to full control!
I have changed the current controllers again to stop integrating once the maximum output is hit. This caused the shocks earlier on. I also put DC current calculation back into place so now the DC current limit can be used.
Most of all I'm now adding constant id current as soon as a certain frequency is passed. This should stop unwanted regen from back EMF. When correctly tuned, that is. The parameter "fweak" is reused to set when this id current injection starts and a new parameter idweak specifies how much current is injected in A/Hz.

The car has some serious performance now but still occasionally trips out when regenning at high speed (7000rpm). Video coming

EDIT: Video
Attachments
Leaf 2019-07-25.json
(1.22 KiB) Downloaded 85 times
stm32_sine.zip
(61.13 KiB) Downloaded 71 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Berdi
Posts: 18
Joined: Fri Jul 19, 2019 11:42 am
Location: Georgia

Re: Testing FOC for synchronous motor

Post by Berdi »

Спасибо вам за вашу работу !!
User avatar
johu
Site Admin
Posts: 5789
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1023 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

С удовольствием :)

I hope google translate doesn't make me look a fool ;)
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: Testing FOC for synchronous motor

Post by dima »

:) I think there is a joke somewhere in here ....
ussr-soviet-wolf.jpeg
ussr-soviet-wolf.jpeg (31.24 KiB) Viewed 3507 times
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Testing FOC for synchronous motor

Post by doobedoobedo »

Could you give an example of how you'd calculate fweak and idweak?

ie. my motor will spin up to around 1000 rpm on 60V whilst drawing about .4 ish DC amps, no load. In order to increase the speed my starting points would be?
User avatar
johu
Site Admin
Posts: 5789
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1023 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

So you would set throtid=0 and see how fast the motor spins. That is base speed and thereby fweak. idweak I'm not sure about myself. It needs to be a value where the field is sufficiently weakened to generate no back EMF at 0 throttle.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Testing FOC for synchronous motor

Post by doobedoobedo »

Thanks I'll check that out tonight.
From my experiments yesterday setting fweak just below max rpm/60 then the more -ve idweak the faster it spins.
What does throtid do?
User avatar
johu
Site Admin
Posts: 5789
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1023 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

throtid sets the amount of magnetizing current per % of potnom. Since you want to demagnetize (i.e. field weaken) it must be negative. Since the Leaf motor is an IPM type it needs some demagnetizing current for most torque per ampere. A first rough tuning found a ratio of -3/2 (e.g. throtiq=3, throtid=-2) to work quite well.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Testing FOC for synchronous motor

Post by doobedoobedo »

Ah OK cool, I was playing with fweak and idweak. No load to test under yet, but the better I understand...

To be honest apart from the stupid hardware fault I created for myself, it's been pretty simple to get a working configuration.
Post Reply