Current control of induction motors

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

Current control of induction motors

Post by catphish »

I know I've brought this up before, but now that I have a bench setup, I'm able to experiment a bit more, so I've started investigating the possibility of using a current PID to control induction motors.

The concept is very simple.
1) Based on direction selection and throttle position we choose a torque output between -100 and +100.
2) Choose a value of slip proportional to desired torque (for example -3Hz to +3Hz)
3) Choose a value of current proportional to desired torque (for example -200A to +200A).
4) Output a sine wave with the selected slip.
5) Feed current feedback (ilMax) and requested current into a PID and use the output to control sine wave voltage.

By controlling voltage in this way, we can maintain a consistent current without worrying about the V/Hz curve (ie boost / fweak) at all, as well as simplify current limiting and derating.

As with field oriented control, we need to make sure the field angle is correct. This is unfortunately still a matter of trial and error in configuration, however it is my belief that the correct angle can probably be maintained by maintaining a value of slip proportional to torque. For example in the SDU, a value of 1Hz slip per 150A seems optimal.

I'm still at an extremely early stage in implementing this, but a very basic proof of concept can be found here: https://github.com/catphish/stm32-sine/ ... d6c832bfdb

This code produces good results in a low power bench test but probably needs more thought before it goes anywhere near a car. I'd be very interested if anyone else with a strong understanding of induction motors would be willing to collaborate on this. :ugeek:
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 »

Here's a couple of graphs of the algorithm in action. The bottom graph shows acceleration. I find it very interesting how this clearly demonstrates the expected V/Hz curve with automatically determined boost. The other shows steady state.
Attachments
Screenshot at 2023-01-15 15-54-35.png
Screenshot at 2023-01-15 15-52-40.png
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 »

Looking good, very interested to see how you get on with this but afraid I can't help as I know nothing about induction motors (except what I've learnt from your posts :) )
User avatar
johu
Site Admin
Posts: 5682
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 »

I tried something similar (thus the existance of ilmax) couldn't get it to work, decided V/Hz was good enough and gave up. So glad to see you picking this up again :)
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: Sun Jan 15, 2023 5:54 pm I tried something similar (thus the existance of ilmax) couldn't get it to work, decided V/Hz was good enough and gave up. So glad to see you picking this up again :)
Thank you! I'd be interested to know if you ran into any specific problems.
I've elaborated on my implementation. So far it seems "too simple" so I'm very interested to do some testing with it.

https://github.com/catphish/stm32-sine/ ... fa1c7740b5

The basics work at least.
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 »

Here's another example of what this code does. This is ilmax following potnom. Throtcur is set to 1A per 1%.
I think I'm now at the stage where I'm ready to test this with a bigger motor.

Latest code, fully annotated: https://github.com/catphish/stm32-sine/ ... d93364c11b

As the graphs show, regen current seems to overshoot its target a bit. I suspect this is because the rotor speed is dropping so quickly. Hopefully in a real vehicle and with careful tuning of the loop, this effect won't be too noticeable.
Attachments
potnom.png
potnom2.png
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 »

Looks good :)

Couple of questions - Is the motor changing direction in that second plot but not in the first plot? Also is there a max current limit set that stops it following the higher potnom values?
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: Tue Jan 17, 2023 4:31 pm Looks good :)

Couple of questions - Is the motor changing direction in that second plot but not in the first plot? Also is there a max current limit set that stops it following the higher potnom values?
In these plots, the motor is always spinning in the same direction. When potnom is less than zero it is doing regen. Currently it has no concept of "negative" current, so it just matches positive current with (negative) requested regen.

The reason the current sometimes couldn't reach the target is because the motor was spinning too fast and the voltage was already maxed out. Later, I will add code to increase slip above its normal target once there's no more voltage to give. (ie field weakening).

Right now with no load on the motor it can do 0 to 100% speed and back to 0 in a fraction of a second if I request full torque.
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 »

Thanks, it's obvious now you say it! Saw the phase reversal on the current, jumped to the wrong conclusion and then couldn't understand why the plot didn't make sense.

Re the field weakening it's surprising how many parallels there are between PM and induction motors when you put it like that. Same problem to solve but on PM you add a opposing fields to do it on an induction motor you induce less current into the rotor.

Are you still planning on adding a load?
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: Tue Jan 17, 2023 5:53 pm Thanks, it's obvious now you say it! Saw the phase reversal on the current, jumped to the wrong conclusion and then couldn't understand why the plot didn't make sense.
I was about to say there is no phase reversal on this graph because the motor is always spinning in the same direction (it should always be green, red, blank). However, at the end of regen cycle just before the rotor stops, there may be a very brief period where the negative slip is more than the positive rotor speed, so the output frequency will actually reverse.
Pete9008 wrote: Tue Jan 17, 2023 5:53 pm Re the field weakening it's surprising how many parallels there are between PM and induction motors when you put it like that. Same problem to solve but on PM you add a opposing fields to do it on an induction motor you induce less current into the rotor.
I don't actually understand field weakening in fixed magnet motors at all! I just about understand the concept that if you change slip you can put less energy into magnetizing the rotor and I guess reduce back EMF.
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: Tue Jan 17, 2023 5:53 pm Are you still planning on adding a load?
I didn't come up with a way to add a load. I definitely think it would be useful to do so, but I haven't worked out a good way. I wonder if the best option might just be to buy something that already has a load, like a water pump. Originally I really wanted a flywheel to test regen "load" too, but I just never found a practical way to do it.
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 decided to go ahead and test this code in my car. The initial results are extremely positive. When positive torque is requested, AC current is controlled perfectly. I was able to set a current of 500A per 100% throttle and it was followed precisely.

With regard to "feel", I would say this is a lot smoother than the old code during low speed maneuvers like hill hold and accelerating forwards from a slow roll backwards. The torque during general driving is also very consistent and predictable.

I will definitely be preferring this firmware for my daily driving while I continue to work on it.

Attached are charts of:
* Full throttle 0-60 with a gentle start
* Various driving
* Instant throttle press followed by instant throttle release

Unfortunately, regen braking is not working correctly. More on that in in the next post.
Attachments
drive-500-0-60.png
drive-500-variety.png
max-slew-2.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 »

Now we get on to regen. This has turned out not to be so simple. The key problem is that I see large unexplained current spikes, usually as soon as regen is activated.
regen-fail-1.png
regen-weirdness-2.png
After staring at these charts for a few hours, the conclusion I seem to be reaching is that during regen, the inverter must be operating as a boost converter (converting low voltage 3 phase AC to higher voltage DC). This means that lower AC output voltages will actually *increase* current through the motor and inverter.

This seems to be backed by the fact that when current rises above the target, "amp" is reduced, and suddenly the current spirals until amp hits zero and the inverter stops switching.

However, this is not sitting well in my mind, because I can clearly see that the existing firmware increases regen by increasing AC voltage, and decreases regen by reducing DC voltage!
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 »

The inverter has to boost during regen in order to puch current onto the DC bus, is that what you mean?

Not sure I understand induction motors so the following questions could be rubbish.

Does the slip change direction when you move from drive to regen?

What happens to the current in the rotor when you switch from drive to regen, does it change sign? If so do you need to allow time for the current to decay before changing the slip?
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: Thu Jan 19, 2023 7:31 pm The inverter has to boost during regen in order to puch current onto the DC bus, is that what you mean?
Yes, since the AC motor voltage is (often) lower than the battery voltage, the inverter must be boosting to push current into the DC bus.
Pete9008 wrote: Thu Jan 19, 2023 7:31 pm Not sure I understand induction motors so the following questions could be rubbish.

Does the slip change direction when you move from drive to regen?
Yes, the slip changes direction. That means that when positive torque is requested, the stator field spins faster than the rotor, then when regen is requested, the stator field slows and spins slower than the rotor.
Pete9008 wrote: Thu Jan 19, 2023 7:31 pm What happens to the current in the rotor when you switch from drive to regen, does it change sign? If so do you need to allow time for the current to decay before changing the slip?
That's a good question! I don't actually know the nature of the current in the rotor at all. It sounds plausible that it may need time to change direction, however I'm not convinced this is responsible for the problem, as one of the charts above shows the problem happening repeatedly while remaining in regen mode. The rotor current magnitude could certainly be changing, but this doesn't seem to cause trouble with changes to positive slip magnitude.
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 »

Could it be pole slipping due to too much slip requested? It might explain the repeating?

Edit - ignore that, with slip it's pole slipping all the time!

Edit2 - coming back to pole slipping - or whatever the correct term is, stalling? Wondering if the slip value that you are setting in regen isn't enough. As the amps ramp up they get to a point where the slip isn't enough to induce enough current into the rotor and it slips/stalls/whatever the term is for can't sustain the torque. You can see an oscillation building up in the current control loop just before it happens too. Could there be any bias in the position/speed measurement that effectively reduced the slip frequency for regen?
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've made a chart that identifies some oddities in the new algorithm.
regen-problem.png
The first issue is not necessarily a problem, but a substantial oddity. The black line on the chart (amp) represents the AC voltage. This *should* roughly track speed, to form the usual V/Hz ratio, but in the above chart, it can be seen that the voltage is substantially reduces when the requested torque is reduced, even though speed persists. I don't know why, but I'm of the opinion that as long as the requested slip and current are being achieved, there is no problem here. The most likely explanation is that I have not correctly matched current and slip (there is a correct ratio for these, and i am currently testing at reduced current).

The second problem is the current spike in regen. This chart shows the leadup to the problem more clearly. We switch into regen and the current plot (blue) bounces off zero in a nice triangle that mirrors potnom (yay) and lands at just over 50A as it should (again mirroring potnom's -50). However what happens next is definitely problematic. Because the current is slightly higher than 50A, the PID tries to compensate by lowering the voltage. We see the black line fall, but instead of compensating, exactly the opposite happens. Current rises, amp falls faster, current rises faster, until eventually the process is blocked by amp reaching zero (which shuts down the PWM). What happens next is equally interesting. amp hovers between 0 and some very low number close to zero. My guess is that any time it's non-zero, there is a huge amount of boost happening and the current rises again, so we see a sharp oscillation until eventually amp managed to rise far enough to stabilize things. It certainly seems that low AC voltage (amp) values increase current. I'm unclear how to fix this, except perhaps to revert to V/Hz during regen, but that will really take away from the magic of this.
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: Thu Jan 19, 2023 8:04 pm Edit2 - coming back to pole slipping - or whatever the correct term is, stalling? Wondering if the slip value that you are setting in regen isn't enough. As the amps ramp up they get to a point where the slip isn't enough to induce enough current into the rotor and it slips/stalls/whatever the term is for can't sustain the torque. You can see an oscillation building up in the current control loop just before it happens too. Could there be any bias in the position/speed measurement that effectively reduced the slip frequency for regen?
The slip value I'm using for regen is very small. The previous implementation maintains a minimum value of slip (I had mine set to 2Hz) but this implementation has no minimum, and simply scales slip all the way down to zero. This means that if the maximum slip is 3Hz, and regen is set to 20% (as it is in my examples), the slip value used is only 0.6Hz. Maybe this isn't enough to be stable and we need to push slip higher during regen. Definitely worth testing.

The rotor field collapsing does seem very possible. However I don't see anything like this happening at similarly low positive torque requests, so I'm not sure why it would only occur in regen.
User avatar
johu
Site Admin
Posts: 5682
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 »

First of all huge props for getting that far so quickly!

In "V/Hz" mode the V/Hz curve is also scaled between ampmin-100% to obtain different currents. So don't think it's unusual to see large variation there.

Regen, despite being somewhat symmetrical to acceleration has always been more susceptible to oscillation. It's almost 10 years ago but I remember I had to pull a few tricks to speed up frequency calculation to keep regen in check.

If I've understood the structure of your controller correctly it is a pure I-controller (because it iteratively adds an error term to amp) which is a bit slow. Maybe consider using the PiController class and bring the kp/ki to the web frontend for tuning.

Otherwise it's like you assume, more amplitude, more rotor field, more torque producing current, more regen.
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: Current control of induction motors

Post by Pete9008 »

catphish wrote: Thu Jan 19, 2023 9:51 pm The rotor field collapsing does seem very possible. However I don't see anything like this happening at similarly low positive torque requests, so I'm not sure why it would only occur in regen.
That's why I was wondering whether there could be any bias, lag, offset, rounding on any of the position or speed measurement that could affect them differently.

Interesting problem this because you are trying to control both the rotor position/torque and the induced rotor currents (which effects how the stator fields affect the positions/torque) using the same stator fields, not easy!

I'm guessing the volts (amp trace) may drop when you come off the power because the induced current in the rotor is dropping which is then reducing the back emf. Wondering if it this change in rotor current that is also causing the instability, could its effect be out phase for positive torque but in phase for neg torque?
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 have a list of ideas to try in the next couple of days to see if they fix the problem.
1) More aggressive proportional gain. It's possible that my controller simply isn't responding fast enough to changes and requires a higher gain.
2) Log ampnom and fslip. Right now I'm not logging the target current or the slip, I'm just making assumptions about what these are based on throttle position.
3) More slip during regen. Maybe regen is different to forward torque and just isn't stable with low values of slip. Using higher values of slip always hides issues caused by inaccurate or laggy rotor speed measurement, at the expense of a little efficiency.

There's one additional issue with the implementation that needs thought. When requested torque is zero, slip is zero, target current is zero, and actual current is near zero, the amp value just floats around because there's no error to correct (actually it reduces gradually to zero). Its value essentially doesn't matter and in practice it seems to quickly snap back to where it should be as soon as any torque is requested, but it feels odd that when idling we apply an essentially random voltage. I feel I should add something to naturally pull amp down when it's not actively required.

This can be seen here:
hang.png
hang2.png
Interestingly when amp eventually does fall to zero, it causes a little current spike.
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 »

I'd guess it's remenant magnetic flux in the rotor causing a back emf, if so not sure there is a lot you can do about it other than wait for it to subside?

Edit - ignore me, the rotor is stationary, think I'll stick to PM motors and leave you to the inductions ones - they're too difficult!
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: Thu Jan 19, 2023 10:37 pm I'd guess it's remenant magnetic flux in the rotor causing a back emf, if so not sure there is a lot you can do about it other than wait for it to subside?

Edit - ignore me, the rotor is stationary, think I'll stick to PM motors and leave you to the inductions ones - they're too difficult!
The rotor is actually spinning. But because the slip is zero, current is zero.

I just realised, the fact that voltage gradually falls to zero like this is probably not random or accidental, this is probably a correct reaction to the decaying rotor field and we're matching voltage to back EMF to keep the current zero.
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 »

Which bit of the plot are you referring to? I was looking at the last bit of the second plot where speed was 0 but the amp trace was still high and dropping.

If the rotor is still spinning then remenant flux will cause a back emf.
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: Thu Jan 19, 2023 10:57 pm Which bit of the plot are you referring to? I was looking at the last bit of the second plot where speed was 0 but the amp trace was still high and dropping.

If the rotor is still spinning then remenant flux will cause a back emf.
Sorry, I think this is just my poor choice of chart colours. In this chart, the visible line that goes to zero is IVT current. Speed is off the top somewhere.
hang2.png
Post Reply