Current control of induction motors

User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

Taking a fresh look at the data, here are a couple of observations:

Looking at the charts, every time the throttle is released at slip returns to zero, the current immediately drops to 40A. No matter how much current was commanded before, it always falls to around 40A. I have a parameter imag designed for precisely this purpose. It sets the minimum current (applied at zero slip), and it seems clear from my drive today that this parameter is set too low at 10A. I don't know exactly what this means, but it seems to me that there is something in the motor (rotor field?) that is slow to react, and we're better off following it rather than trying to force it to change.
falloff.png
Second, why does current sometimes instantly rise to meet throttle (slip) demand?
instant.png
But other times fails to do so?
slow.png
It would seem to me that we want to try to operate as much as possible in a region where voltage does not need to change in order to meet instantaneous torque/current demand.

And of course the big problem I keep coming back to. What is the root cause of the oscillation?
oscillation2.png
And the weird waveform that probably causes it:
oscillation-cause.png
Putting aside this oscillation, the direction reversal in this chart is very cool. This is me using the throttle to come from a reverse to forward movement completely smoothly.

Apologies for thinking out loud excessively. I find documenting all my findings and ideas here helps a lot. :ugeek:
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Current control of induction motors

Post by Pete9008 »

catphish wrote: Sun Jan 29, 2023 9:28 pm What I absolutely don't understand right now is how and when the rotor is magnetized, and how that interacts with the stator field and current.
Not sure how much help the following will be but please feel free to igore, modify, correct etc.

Now I don’t have a much understanding of the maths or control techniques for induction motors but do have a reasonable understanding of the underlying physics so will try to explain the rotor currents. I'm no expert so may be wrong but hopefully if I am someone will correct it :)

If you image applying a DC 3-phase voltage to a stationary motor all you will see is a current due to DC resistance of the windings. If the 3-phase voltage starts to rotate so will the current it induces in the windings (at low frequencies the DC resistance will continue to dominate and the voltage and current will be in phase, as the frequency increases the stator inductance will start to contribute and the current will start to lag the voltage – not that important but included for completeness).

Now this rotating current in the stator will induce magnetic flux into the air gap between the stator and the rotor and into the rotor itself. Now the rotor contains a cage of wires, the changing magnetic flux will induce a current into the wires. Since the flux varies around the circumference of the stator (3-phase) the current in the individual wires in the cage will be of different magnitudes and different signs; the cage end caps allow them to circulate between wires to produce complete current loops. The distribution of currents within the rotor will be an image of the 3-phase currents in the stator (you can almost think of it as a transformer while things are stationary).

The currents flowing in the rotor will interact with the flux produced by the stator and the rotor and this will produce a rotational force, the force is in a direction that opposes the change that caused it, i.e. the rotor will start to follow the stator.

Now the rotor can never catch up with the stator as if it does, and the rotor speed matches the speed of the stator’s rotating field, it will see a stationary magnetic field (stationary from the reference frame of the rotor) and the induced currents will drop to zero, if the induced currents drop the force drops and the rotor slows. This means that the rotor will find an equilibrium where the induced currents are just enough to balance the torque demand. This balance point is normally referred to as slip or the difference between the rotational field of the stator and the speed of the rotor. At this slip speed there will therefore be a 3-phase current flowing around the rotor cage at the slip frequency (this frequency is the frequency at which the peak of one phase would be seen to march round the individual cage wires).

The field in the rotor can be considered in the same way as would the field produced by the magnets in a PM motor. The rotating field produced by the spinning rotor will induce back EMF voltages into the stator, again these will be in a direction that opposes the change that produced them, i.e. will oppose the stator voltage and reduce the available voltage that can be used to produce current in the stator. This has the effect of reducing the current in the stator for a given voltage (and so stator field, stator flux, induced rotor flux and induced rotor current and so torque). So to maintain current, and so torque, as speed increased more stator volts are needed. In V/f control I think it is just this bit that is being controlled.

Edit - It's worth noting that the big difference from a PM motor is that the magnitude of the back EMF will be proportional to the flux generated by the rotor which is proportional to the magnitude of the rotor currents. The angle and magnitude of the back EMF can therefore be used to measure the amplitude and angle of the rotor flux.

Now at any point if you ask for more torque than the fields can support you will get pole slipping, this is different to normal slip and is effectively stalling. The rotor will lose sync with the filed and drop back by one pole. If that is enough to drop the torque demand to below the limit it will start to follow again, if not another pole slip will occur. This would generate some odd torque pulsations and some odd current waveforms (no idea whether this could be what you have noticed).

What the control loops are trying to do is optimise the slip, and so rotor current, and voltage in the stator to maximise efficiency and power factor while satisfying the torque demand.

Edit - This might be worth a look too, bit of detail on FOC control for PM motors which may be of use?? viewtopic.php?p=45449#p45449

Edit2 - corrected position of above edit!
Also worth mentioning that the rotor also has a fair bit of soft iron around the cage to increase flux. This also has the effect of adding inductance to the rotor windings meaning they can store energy and so current can be slow to build and decay.
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

Pete9008 wrote: Mon Jan 30, 2023 11:01 am Not sure how much help the following will be but please feel free to igore, modify, correct etc.
Thank you very much for the explanation. I will read this a couple of times and try to equate everything to the data I'm seeing.

I'm also going to drop this link here as it looks relevant: https://build-its-inprogress.blogspot.c ... onics.html
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Current control of induction motors

Post by Pete9008 »

catphish wrote: Mon Jan 30, 2023 12:47 pm I'm also going to drop this link here as it looks relevant: https://build-its-inprogress.blogspot.c ... onics.html
Nice find, now that guy knows his stuff!

What's even more interesting is that his discussion is about a PM motor, this makes me wonder whether what you are seeing is also causing some of the cogging that bexander has commented on when using the MGR at low speeds?

Edit - Ignore me on that last bit, it's doesn't explain the low speed cogging on PM motors. At low speed the Ud and Uq control loops would easily be able to compensate.
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

Before I go back to the textbooks, I decided to stop worrying about the small oscillation for long enough to go for a proper drive. It really is a joy to drive with this new code. The main change is that the throttle response is completely instant and the torque is totally consistent.

Attached is the current firmware (with only a couple of minor fixes), and I've pushed the SDU parameters a bit harder.
fslipmax=3, fslipmin=0, imag=25, throtcur=7, curkp=1, ocurlim=950, idcmax=1000
Edit: set imag=0 for now as it could risk inverter damage if contactors are opened when car is stationary but in gear.
fslipmax=3, fslipmin=0, imag=0, throtcur=7, curkp=1, ocurlim=950, idcmax=1000

The values of fslipmax and throtcur can be tweaked to adjust torque and maximize efficiency, but these are the that give me the best performance for now. This pushes 700A peak (500A RMS) through each phase at full throttle. That's a lot of current and it does heat up the inverter a fair bit. Not a big problem at the moment, but may need scaling back in summer.

These are now essentially the same parameters I was using with the V/Hz firmware (though they draw a bit more DC current because there's no limiting there yet).

And the TODO list:
* Add field weakening. The motor currently loses torque rapidly above 5800RPM with the slip limited to 3.0
* Integrate idcmax into the current limiting PID
* Attempt to reduce oscillation at very low speed, possibly related to deformed current waveforms
* Look again at regen. Maybe I can get this working now i know a bit more about it

Thanks again Pete for the information. I will read it properly this evening.

Edit: Removed binary. New version below.
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

I'd prefer to be working on more exciting things like field weakening, but I can't get my mind off this weird current waveform problem. Specifically I am now quite sure this is a negative 5th harmonic at around 20% of the main signal. But where's it coming from?

I did some tests today with higher resolution logging. Here is a test supplying 8V to the motor at current sweeping from 0.75Hz up to 3Hz with a stationary rotor. About 40A current
40a-frequency-sweep.png
Here's an example with more current (around 100A at 6Hz, only 0.4Hz slip):
more-5th-harmonic.png
Interestingly this happens pretty much all the way down to DC. Here's 30A at 0.15Hz:
30A-150mHz.png
By reducing current to 15A the problem, while still visible, it much less pronounced:
15A.png
What on earth is this? I suppose the next obvious step with this is to see if it happens on my bench motor with the same code. If so, I will be able to get a scope on it and better diagnose.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Current control of induction motors

Post by Pete9008 »

catphish wrote: Wed Feb 01, 2023 1:41 pm What on earth is this? I suppose the next obvious step with this is to see if it happens on my bench motor with the same code. If so, I will be able to get a scope on it and better diagnose.
Could it be this ;)
catphish wrote: Wed Feb 01, 2023 1:41 pm Specifically I am now quite sure this is a negative 5th harmonic at around 20% of the main signal. But where's it coming from?
Seriously though, harmonics generation is inherent in the way the magnetic flux moves between segments of the stator/rotor and non-linearities in the B/H curve of the cores. Most of the maths is for an ideal motor and ignores this (and assumes that the fields are all nicely homogeneous without individual segments) but unfortunately ideal motors don't exist! That web page you linked above explains it pretty well, and in particular the way closed loop FOC is able to compensate for it at low speeds. Your control is open loop so can't do anything about it so whatever harmonics the motor produces is what you see in the waveforms.

Also suspicious that something is getting close to saturation (best guess would be the rotor) which is going to move away from the linear region of the B/H curve which heavily increases their non-linear behaviour and so increases the amount of harmonic content generated. That would explain why the effect is reduced in your 15A plots.
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

Pete9008 wrote: Wed Feb 01, 2023 3:10 pm Seriously though, harmonics generation is inherent in the way the magnetic flux moves between segments of the stator/rotor and non-linearities in the B/H curve of the cores. Most of the maths is for an ideal motor and ignores this (and assumes that the fields are all nicely homogeneous without individual segments) but unfortunately ideal motors don't exist!
Thanks. I was hoping for easy answers :cry:
Pete9008 wrote: Wed Feb 01, 2023 3:10 pm Also suspicious that something is getting close to saturation (best guess would be the rotor) which is going to move away from the linear region of the B/H curve which heavily increases their non-linear behaviour and so increases the amount of harmonic content generated. That would explain why the effect is reduced in your 15A plots.
I'm going to stop guessing and properly read the paper I linked on Adaptive Feedforward Cancellation and see if it will help me. Bear in mind my algorithm *is* closed loop (at least in terms of overall amplitude, on which these oscillations show up very clearly) but my adjustment gains are far too small to squash them in time. Note that I've been intentionally disabling my current feedback and outputting a fixed AC voltage in order to make these charts, as the algorithm compensates enough to make it less clear what's going on.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Current control of induction motors

Post by Pete9008 »

catphish wrote: Wed Feb 01, 2023 4:40 pm Thanks. I was hoping for easy answers :cry:
I could do with some of those too!
catphish wrote: Wed Feb 01, 2023 4:40 pm I'm going to stop guessing and properly read the paper I linked on Adaptive Feedforward Cancellation and see if it will help me. Bear in mind my algorithm *is* closed loop (at least in terms of overall amplitude, on which these oscillations show up very clearly) but my adjustment gains are far too small to squash them in time. Note that I've been intentionally disabling my current feedback and outputting a fixed AC voltage in order to make these charts, as the algorithm compensates enough to make it less clear what's going on.
Yours is only closed loop for overall currents magnitude, FOC is closed loop for the amplitude of both the Iq and Id components so it can servo them to whatever is needed (so the current trace will be clean but the voltage trace will then show the harmonics instead - but that doesn't cause as much torque ripple).
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

Pete9008 wrote: Wed Feb 01, 2023 4:49 pm Yours is only closed loop for overall currents magnitude, FOC is closed loop for the amplitude of both the Iq and Id components so it can servo them to whatever is needed (so the current trace will be clean but the voltage trace will then show the harmonics instead - but that doesn't cause as much torque ripple).
Your're right, looking at the paper, the disturbance on the D and Q phases are not in phase, so by correcting on the overall current, I will leave an oscillation in ratio between D and Q, but perhaps this is better than nothing.
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

Pete9008 wrote: Wed Feb 01, 2023 3:10 pm That web page you linked above explains it pretty well, and in particular the way closed loop FOC is able to compensate for it at low speeds.
I think I understand this AFC algorithm, but looking at the pseudocode, I don't understand what "thetadot" is.

Edit: never mind, I clearly missed a paragraph that explains it very clearly.
The simple fix for this is to divide the error by angular velocity before integrating, and then multiply by angular velocity at the end of the AFC calculations.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Current control of induction motors

Post by Pete9008 »

Thetadot is shorthand for the derivative (rate of change) of theta, so yes angular velocity would make sense!
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

Warning: It occurred to me last night that while the "imag" parameter has the potential to damage the inverter if the ignition is turned off while the car is in gear. It causes current to flow in the motor even when the car is stationary, which can cause damage if the main contactors are opened. I recommend setting this parameter to zero for now.
:!:
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

Attached build "5.25.T-sine". This version removes imag for the reason mentioned above.

I didn't have any success today implementing Feedforward Cancellation, so I will try not to worry about it for now. In any case I'm pretty happy with how this drives, feel free to judge whether it provides any benefit over the V/Hz implementation.

I am using the following settings with SDU:
fslipmax=3, fslipmin=0, imag=0, throtcur=6.5, curkp=1, ocurlim=950, idcmax=950

You can comfortably also run the following, but I don't because it spins my wheels too much:
fslipmax=3, fslipmin=0, imag=0, throtcur=7, curkp=1, ocurlim=950, idcmax=1000

There will most likely be one further release of this to implement field weakening.

Edit: removed attachment. Final version in later post.
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

Today I added automatic field weakening. Essentially all this does is when voltage runs out and there is still a demand for additional torque, it increases maximum slip up to a defined limit When current no demand no longer exceeds current, it steps it back down again. Here's a 0-60 with fslipmax=3 and fslipweak=4:
feb3-fweak.png
I'd say that's a pretty big success, though the gain is clearly a bit too high.
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

DC current limiting now incorporated into the main current limiting loop:
feb3-idcmax.png
User avatar
johu
Site Admin
Posts: 5683
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Current control of induction motors

Post by johu »

Wow, that looks very smooth! Does it drive as nice as it looks?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

So here the final (hopefully) release (5.26.Z) and SDU config. We now have:
* AC current control and limiting
* DC current limiting
* Dynamic field weakening

Here's a chart demonstrating a 0-60 run in which initially the AC current it limited to 700A peak and then as DC current rises, the AC current limit is reduced to keep the DC current within its limit of 500A. Field weakening is also increases as needed from 3Hz to 4Hz.
feb3-final.png
Here's a more dynamic part of the same test drive showing throttle response (note the throttle is unfiltered so the current target is also the realtime throttle position).
feb3-final-dynamic.png
Parameters used:

Code: Select all

fslipweak=4
fslipmax=3
fslipmin=0
throtcur=7  -  I usually run 6.5 (650A) but 7.0 (700A) gives a decent extra amount of torque
curkp=1
ocurlim=1000
idcmax=650
Note that idcmax doesn't actually match real DC current, but it doesn't really matter. A value of 650 gives a limit of about 500A.

Using this configuration, the SDU is absolutely lovely to drive and sends my car to 60mph in 5.0 seconds with very consistent torque and throttle response.

Source code available as always at https://github.com/catphish/stm32-sine/tree/amp

Regen is abandoned for the foreseeable future to preserve my sanity.
Attachments
sdu.json
(1.09 KiB) Downloaded 54 times
stm32_sine.bin
(47.32 KiB) Downloaded 46 times
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

johu wrote: Fri Feb 03, 2023 4:30 pm Wow, that looks very smooth! Does it drive as nice as it looks?
Yes :)

At high current levels, the current sensor looks pretty noisy, but this isn't reflected in the amplitude output or the driving experience. Maybe the gain is a little high on the field weakening, but you can't feel it.
User avatar
johu
Site Admin
Posts: 5683
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Current control of induction motors

Post by johu »

Nice.
I wonder how well it works on the LDU as it has just a 1 digit/A sensor ratio. Could only be improved by modifying the hardware which just swings from 0.8 to 2.3V
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

johu wrote: Fri Feb 03, 2023 5:12 pm Nice.
I wonder how well it works on the LDU as it has just a 1 digit/A sensor ratio. Could only be improved by modifying the hardware which just swings from 0.8 to 2.3V
My suspicion would be that this will still work. There's quite a lot of noise during real driving, and consequently, the gains on my controller are very low, so the resolution is not critical. I believe there's only one way to find out though. :twisted:
yaroslav
Posts: 176
Joined: Tue Aug 13, 2019 4:32 pm
Location: Russia, Stavropol
Has thanked: 14 times
Been thanked: 5 times

Re: Current control of induction motors

Post by yaroslav »

Thank you for developing the source code. I have been raising a topic on the forum related to asynchronous motor current control for a long time. This year I plan to build several projects and test your firmware. The bad news is that my car was at an intersection, and the transistors broke through, although before that I drove more than 1000km for I don't know for what reason, but the failures started with a cold snap, so I don't have anything to test the firmware yet. I didn't have time to download your firmware.
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

johu wrote: Fri Feb 03, 2023 5:12 pm Nice.
I wonder how well it works on the LDU as it has just a 1 digit/A sensor ratio. Could only be improved by modifying the hardware which just swings from 0.8 to 2.3V
On the subject of current sensors, I'm having doubts about the accuracy of the current sensors in my SDU.

I am using a gain of il1gain=1.5 (1.5 digits per amp?) which comes from the recommended config, but has this value been calculated / confirmed? In many ways it doesn't matter, but I'd like to know if it's accurate.

According to my calculations, at full load, I'm getting a power factor of 0.6, which seems extremely poor. Hard to know if this is the current sensors, my calculations, my tuning, or just whether that's the best the SDU can do.

I suppose the only way to know for sure is to find a way to pass a known current through the phases, but I don't have a convenient way to do that.
johnspark
Posts: 264
Joined: Fri Apr 12, 2019 10:42 pm
Location: Adelaide, South Australia
Has thanked: 59 times
Been thanked: 48 times

Re: Current control of induction motors

Post by johnspark »

I am a bit slow with these messages, but here is a fifth harmonic of the fundamental:
image.png
image.png (68.46 KiB) Viewed 3560 times
Depending upon the polarity of the fifth harmonic we get either very peaky overall waveform or a flattened crest, which is what we see in this post.

Just to add some cats to the pigeon cage from here: https://www.electrical4u.com/fundamenta ... harmonics/
image.png
On the other hand, with overmodulation and inverters, we get this: VA0 (OverModulation)(t).
{With no overmodulation we just get VA0(t)}


Here the carrier of the waveform is swamped by a positive DC or a negative DC between Beta and Pi-Beta of the first half of the waveform and I know Toyota use this for part of their driving their MG1s and MG2s more strongly I suppose during acceleration. In this case, the harmonics are helpful (For the last picture, they happen to show a 3rd harmonic not 5th). This overmodulation is helpful to get a bit more out of the motor, otherwise Toyota would not do it.

Probably everyone knows all this already?
Attachments
image.png
image.png
User avatar
catphish
Posts: 954
Joined: Fri Oct 08, 2021 11:02 pm
Location: Dorset, UK
Has thanked: 93 times
Been thanked: 179 times

Re: Current control of induction motors

Post by catphish »

johnspark wrote: Sun Feb 05, 2023 10:45 am I am a bit slow with these messages, but here is a fifth harmonic of the fundamental:
Depending upon the polarity of the fifth harmonic we get either very peaky overall waveform or a flattened crest, which is what we see in this post.
Thank you. I think this confirms what I already suspected. I should clarify, the reason this is a problem is that at low frequencies (anything below about 2Hz), this effect is quite noticeable as a torque ripple at 3x the motor frequency.

The effect can be masked by using a large minimum slip (in my V/Hz setup I sometimes end up running fslipmin=3), and essentially avoiding driving the motor at low frequencies at all, but this isn't ideal.

In theory we could overcome it by injecting an opposing harmonic, but I didn't get very far experimenting with this as the effect isn't nearly as easy to reproduce on the bench.
Post Reply