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 »

It seems to me that this is the root of the current spike problem. If the rotor is spinning, there will be back EMF, and if the inverter AC output voltage is too low, this back EMF will be boosted into the DC bus, probably collapsing the field in the process, hence why it happens in a loop. It feels like this is a case where reducing the voltage will NOT reduce the current. I suspect that the current firmware just never creates this situation, because if it's creating negative slip, it's always setting a fixed V/Hz 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 »

Ahh OK, that all makes sense then. Remenant rotor flux creates a back emf that your controller then needs to match to maintain zero current, as you said!

Still keep thinking that there is something that gets reversed during regen that makes the controller have to work harder. When accelerating and the current is low you add volts which increases the current, the increasing speed also tends to increase the back emf which also needs increasing volts so the two are working in the same direction. When decelerating and the current is low again you add volts but because the speed is reducing (and possibly rotor induced current) so is the back emf which needs the voltage to reduce to maintain the same current. It kind of feels like they are fighting each other. If the control loop stability is slightly marginal then this is probably where it would lose it.

Edit - I think we may be saying the same thing in slightly different ways?
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 11:28 pm Ahh OK, that all makes sense then. Remenant rotor flux creates a back emf that your controller then needs to match to maintain zero current, as you said!

Still keep thinking that there is something that gets reversed during regen that makes the controller have to work harder. When accelerating and the current is low you add volts which increases the current, the increasing speed also tends to increase the back emf which also needs increasing volts so the two are working in the same direction. When decelerating and the current is low again you add volts but because the speed is reducing (and possibly rotor induced current) so is the back emf which needs the voltage to reduce to maintain the same current. It kind of feels like they are fighting each other. If the control loop stability is slightly marginal then this is probably where it would lose it.

Edit - I think we may be saying the same thing in slightly different ways?
Yes I think this is precisely the problem, but the other way around. Specifically, the problem seems to be that when decelerating and the current is too high, the algorithm wants to reduce voltage, but doing to actually increases the current, because there's no enough voltage to oppose the back EMF.

During acceleration, this problem is self-solving. If you take away voltage, the excess back EMF just gets used up by the motor, but during regen, if you take away voltage, the back EMF doesn't self-dissipate in the same way.

Unfortunately, this means that during "motoring" ie positive slip/torque, more voltage always means more current, and the PID loop works. But during regen, the relationship isn't linear. Too much voltage OR too little has the potential to cause excess current, so the algorithm can't reliably guess which direction of change is needed.
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 »

Not sure I agree with the too much or too little. Have you considered taking account of the phase of the current? When it goes negative (flowing out of the motor) the control loop doesn't see it, it just gets the absolute value. It appears to work fine till the reversal then breaks.

I'm wondering whether keeping the sign by looking at the amplitude of the current component that is in phase with the voltage would fix the regen. In the example above where the regen current is too big, once the negative sign is included the control loop would then see it as too small so increase the voltage which would oppose the back emf more and actually lead to a reduction in the current?

I could be completely wrong though!
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: Fri Jan 20, 2023 12:37 am Not sure I agree with the too much or too little. Have you considered taking account of the phase of the current? When it goes negative (flowing out of the motor) the control loop doesn't see it, it just gets the absolute value. It appears to work fine till the reversal then breaks.

I'm wondering whether keeping the sign by looking at the amplitude of the current component that is in phase with the voltage would fix the regen. In the example above where the regen current is too big, once the negative sign is included the control loop would then see it as too small so increase the voltage which would oppose the back emf more and actually lead to a reduction in the current?

I could be completely wrong though!
I think you might be 100% correct. Perhaps if I look at the in phase / out of phase current or real / reactive power, a useful signed metric will emerge.
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 »

Real power is fairly quick to calculate form the three phase voltages and currents and gives a signed result. If you then divide by absolute voltage amplitude you get back to a signed current. The alternative is the park and clarke transforms but they are probably more work than is required for 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: Fri Jan 20, 2023 12:59 am Real power is fairly quick to calculate form the three phase voltages and currents and gives a signed result. If you then divide by absolute voltage amplitude you get back to a signed current. The alternative is the park and clarke transforms but they are probably more work than is required for this.
I agree, I'll try this first!
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 »

As discussed, I will attempt to get "real current" using the following code:

Code: Select all

s32fp PwmGeneration::GetIlReal(s32fp il1, s32fp il2)
{
   // Calculate real current by first calculating real power then dividing by voltage.
   // The SVPWM offset has no impact on this calclation so we can use the raw PWM values.
   int32_t v1 = SineCore::DutyCycles[0] - SineCore::ZERO_OFFSET;
   int32_t v2 = SineCore::DutyCycles[1] - SineCore::ZERO_OFFSET;
   int32_t v3 = SineCore::DutyCycles[2] - SineCore::ZERO_OFFSET;
   s32fp il3 = -il1 - il2;
   s32fp pMax = il1 * v1 + il2 * v2 + il3 * v3; // Real power
   s32fp ilReal = FP_DIV(pMax, SineCore::GetAmp()); // Real current
   // Scale by 2/3 to get single phase peak
   ilReal = FP_MUL(ilReal, FP_FROMFLT(0.666666666666f));

   return ilReal;
}
There is of course now a question of whether we should *always* be setting "real current" rather then actual current. I'll do some testing shortly.

Once I'm done with this, I'll inevitably have to have another go at implementing real FOC. Not this week though! It's hard and I already tried and failed once before to get this working! http://smd.hu/Data/Analog/DSP/Motorcont ... NTROL/FLUX
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 »

That looks like it should work, interested to hear how you get on. The more I think about it the more I'm sure that the discontinuity in the current when the sign changed can't have been helping at all. I'd be inclined to use the real power as the input to the control loop all the time; real power is what makes torque, imaginary power just warms up the wires!

Had a quick skim through that paper. If I understand it right the idea is to use the back emf to calculate the phase and amplitude of the rotor currents with respect to the stator and then feed that into the foc algorithms to calculate the voltages required to keep the torque at the correct level? There's a lot to go wrong there! It occurs to me that once you have a motor running it should be possible to run the rotor flux calculation in parallel with whatever algorithm is running the motor. It would then be possible to debug the flux calculations isolated from motor operation. Once that bit looks like it is working it is a much smaller step to add the rest of the foc algorithms.
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: Fri Jan 20, 2023 12:15 pm That looks like it should work, interested to hear how you get on. The more I think about it the more I'm sure that the discontinuity in the current when the sign changed can't have been helping at all. I'd be inclined to use the real power as the input to the control loop all the time; real power is what makes torque, imaginary power just warms up the wires!
There is one question stuck in my head. What on earth should this look like when the car is rolling backwards, we apply positive torque, and the car slows to a stop and then starts moving forwards? Ideally current and torque will remain constant, but real power will have to pass through zero at some point! :( :?: :?: :?: :?
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 assume you mean like on a hill start?

As long as you are doing work the real power has to be positive (battery driving motor) so it shouldn't change polarity while transitioning through zero speed. Surely the only time it changes polarity is when torque changes direction and you transition from driving the load to 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 »

Pete9008 wrote: Fri Jan 20, 2023 12:38 pm As long as you are doing work the real power has to be positive (battery driving motor) so it shouldn't change polarity while transitioning through zero speed. Surely the only time it changes polarity is when torque changes direction and you transition from driving the load to regen?
The situation I just described *does* transition from regen to driving. Not because the torque changes direction, but because the rotor does. Imagine you're going 10mph backwards, and you put the car into D and request +50% torque. That's exactly the same situation as if you were traveling forwards at 10mph and requested -50% torque, it's a regen request. But then once the car stops, and the rotor switches direction, the torque request is now in the same direction as the motor, hence the power switches direction.

Also, bear in mind that at the moment the car is stationary, you are *not* doing work. At 0RPM, the motor's output power is by definition 0W.
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'm wondering if there's a better way to look at this. Instead of assuming voltage is always positive, and frequency becomes negative, it may be better to turn it on its head. Make slip always positive, but make the voltage negative. I believe the output waveform will be the same, but it gives another direction to attack the maths from, where the current can be constant, but the voltage reverses.

Edit: the more I look at induction motors, the more I realise there's a secret DC motor hiding inside!

Edit edit: With this new maths, current can remain positive, and voltage (back EMF is what passes though zero). This probably also means the sign of the output will always match the sign of the current error. Voltage can be a continuous scale from -300V to +300V.
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: Fri Jan 20, 2023 12:45 pm I'm wondering if there's a better way to look at this. Instead of assuming voltage is always positive, and slip becomes negative, it may be better to turn it on its head. Make slip always positive, but make the voltage negative. I believe the output waveform will be the same, but it gives another direction to attack the maths from, where the current can be constant, but the voltage reverses.
I think all these approaches are fairly equivalent, just different ways of dealing with the sign change. Must admit I'm still struggling to see the problem here.
catphish wrote: Fri Jan 20, 2023 12:45 pm Edit: the more I look at induction motors, the more I realise there's a secret DC motor hiding inside!
That looks to be exactly what that paper is doing, calculating what is happening inside the rotor from the back emf and then from that point you can treat it just like a PM motor.
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: Fri Jan 20, 2023 12:50 pm Must admit I'm still struggling to see the problem here.
I will try to explain my concern again:
1) The car is traveling backwards and the user requests forward torque. This should cause regen to occur. The real power should flow from motor to battery.
2) The car slows until it reaches a stop, At no point does the torque request change.
3) The car continues to accelerate forwards, but now direction of travel is the same as direction of torque, so we are no longer requesting regen. The flow of power has changed and is now from battery to motor.
4) At no time has the driver changed their request. At all times, they were requesting the same forwards torque. We want that torque to continue uninterrupted throughout the process.
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 get all that OK. I still don't see why it is a problem though. The current starts off as negative and then transitions to positive as the speed passes through zero (assuming level ground ;) ). Why is that a problem, what am I missing?

Edit - just clicked, you want positive torque to equal positive current! Now see why treating voltage as the thing that changes sign makes 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 »

Pete9008 wrote: Fri Jan 20, 2023 1:05 pm I get all that OK. I still don't see why it is a problem though. The current starts off as negative and then transitions to positive as the speed passes through zero (assuming level ground ;) ). Why is that a problem, what am I missing?
The problem is that to maintain constant torque, we need to maintain constant current. That's what the PID does. It can't keep current constant if the current it's tracking is expected to go to zero. And indeed, in this scenario, current should *not* go to zero. Real power should dip to zero, but actual current should remain constant. I think this ruins my concept of using "real" current for this purpose.

PS. Thanks for helping me think this all through!
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 »

No problem, it's interesting but also procrastination from the job I'm supposed to be doing!

Sorry, real power was my suggestion, hadn't considered/understood all the implications :( Still think the sign change is the problem but wondering if there is a simple test that could be done to confirm it (basically just to test the theory) before spending time looking for a solution that will cover all cases?
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 »

Isn't it as simple as slip direction = travel direction = accelerating = pulling energy from battery. slip direction != travel direction = regen = putting energy into the battery?
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 Jan 20, 2023 1:18 pm Isn't it as simple as slip direction = travel direction = accelerating = pulling energy from battery. slip direction != travel direction = regen = putting energy into the battery?
Yes, that's exactly right!

The confusion arises because slip can continue to be in the same direction, while the travel (rotor) direction changes. In that case, the user wants torque to remain constant, but DC battery current and hence the "real power" changes direction.

And this is why I can't use real power for my PID, it's not consistent with requested torque.

I still believe what I want to control is what I already control (simple AC current). And this works great going forwards.

I just need to get my head around the maths to adjust voltage when slip goes against rotor direction. My real world testing has shown that the old way (more voltage = more current) doesn't work correctly, though I'll admit have no idea why it does seem to work in the existing codebase!
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: Fri Jan 20, 2023 1:16 pm Sorry, real power was my suggestion, hadn't considered/understood all the implications :( Still think the sign change is the problem but wondering if there is a simple test that could be done to confirm it (basically just to test the theory) before spending time looking for a solution that will cover all cases?
I just went out and graphed real power. The results are (at least to me) very interesting, and it seems your suggestion is a good one!
regen-real.png
This graph shows the following pattern of oscillation:
* Voltage rises, there is some positive real power. I assume this is the rotor being magnetized.
* There is a brief period of stability, during which real current flips into reverse.
* Current rises and the PID reduces voltage
* Current rises rapidly
* The inverter reduces the voltage to zero and the rotor field collapses

As we hoped / expected, every time real power goes negative, the PID loses control of current (in fact it looks a lot like it's operating in reverse!)

In terms of theory, this now seems somewhat obvious. Thinking about one leg of the inverter, if current is in the opposite direction to voltage, then obviously increasing the voltage on that leg will oppose that current, and if current is in the same direction as voltage, then reducing the voltage will push less current. This seems stupidly obvious after almost 24 hours of trying to understand how electricity works. :!:

At this point, I could convert real power to a current and feed it into my PID, however, for three reasons I'm inclined not to for now:
1) The current implementation is simple and it appears to work well in terms of regulating current.
2) Part of the goal of this implementation is to allow people to have control over how much current is actually flowing through their motor and inverter. By using real power, we'd be allowing unknown amounts of reactive power, which could easily cause damage or trip overcurrent limits.
3) I believe the user should be manually tuning their current vs slip ratio to optimize power factor. However, I also believe that this new calculation will allow logging real current and apparent current, allowing for much easier tuning (the user can now easily adjust slip to maximize the power factor!).

With all that in mind, I absolutely now believe that I can use the *sign* of real power to set the direction of the PID error. Any time current appears to oppose voltage, the PID can increase the voltage to reduce current. I will try this in the next couple of days and see if it resolves the problem.

I will also make all this data available as parameters for logging / tuning, and possibly include a precalculated power factor. Right now I'm sure my power factor is probably quite bad because I previously tuned my car to 500A RMS vs 3Hz, whereas (for safety) I'm currently limiting myself to 500A PEAK at 3Hz (the new algorithm limits AC current based on peak current per phase).

Another example from today's test:
regen-real2.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 »

That all looks to make sense :)

Wondering about the imaginary and real current. Could one way of thinking about it be the imaginary current is mainly responsible for inducing current into the rotor while the real current mainly generates the torque?
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 »

Here is a quote out of Power Electronics and Variable Frequency Drives B Bose:

From this:

Current as the controlled variable is same for DC or AC machines, it eliminates stator dynamics (stator resistance, stator inductance induced EMF).

Current regulators for AC are more complex than for DC drives, for AC regulator, must control amplitude and phase.

PI control as applied in DC drives is not so good for AC drives. Needs widest bandwidth in the system and must have zero or nearly zero steady-state error.

From this chapter they explored:

hysteresis and bang-bang current regulators
PI current control with ramp comparison constant frequency PWM
Predictive (Optimal) current controllers



Below, please see quote from a paper in Research Gate:
In AC servo systems ripple-less high torque can be reached by appropriate current vector control method. The current control loop in voltage source inverters offers substantial advantages in improving drive system dynamics. Such inverters can realize high dynamic current control with excellent transient response as a result of direct comparison of the inverter output current with the current reference signal.

Another quote
The current-regulated VSI with pulse-width modulation meets an additional requirement: low level of harmonic content in the output voltage. In AC servo drive systems high dynamic torque without ripples is required. This condition can be reached by appropriate current vector control method.

https://www.researchgate.net/publicatio ... ol_methods
Bit of maths here...

Hope all this helps some how

Kind regards.
Attachments
Current Regulators For Motion Control with FO-IM by B. Bose.jpg
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 »

A few ideas:

The curve for an induction motor flipping from motor to generator is almost the same, just rotated by 180:
image.png
You cannot change rotor speed, it is attached to car, you can change stator rotation rate >> change slip by changing 3 phase frequency going to Induction Motor...
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: Sat Jan 21, 2023 2:03 am You cannot change rotor speed, it is attached to car, you can change stator rotation rate >> change slip by changing 3 phase frequency going to Induction Motor...
You're absolutely correct, and that is exactly how it works. :idea:

The code sets the slip frequency according to the torque requested by the pedal. Full throttle gives positive slip, and when regen is enabled, off-throttle goes into negative slip.

Code: Select all

void PwmGeneration::SetTorquePercent(float torque)
{
   float fslipmax = Param::GetFloat(Param::fslipmax);

   ampnom = FP_FROMFLT(ABS(torque));
   fslip = FP_FROMFLT(torque / 100.f * fslipmax);

   Param::Set(Param::ampnom, ampnom);
   Param::Set(Param::fslipspnt, fslip);

   slipIncr = FRQ_TO_ANGLE(fslip);
}
Post Reply