Current control of induction motors
- johu
- Site Admin
- Posts: 6618
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 342 times
- Been thanked: 1485 times
- Contact:
Re: Current control of induction motors
Please don't change to lookup table
the Sin() and Cos() function need it to be plain sine and they are used by FOC

Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
- catphish
- Posts: 959
- Joined: Fri Oct 08, 2021 11:02 pm
- Location: Dorset, UK
- Has thanked: 96 times
- Been thanked: 188 times
Re: Current control of induction motors
Oh, I see. I think there are a LOT of ways to approach this. Ultimately though, in most cases the output is just an angle and a magnitude. As long as that's the case, the angle can be looked up in a precomputed table and multiplied by the amplitude. I'm not sure if the FOC implementation does something different though.
- catphish
- Posts: 959
- Joined: Fri Oct 08, 2021 11:02 pm
- Location: Dorset, UK
- Has thanked: 96 times
- Been thanked: 188 times
Re: Current control of induction motors
Don't worry, I think it's better to use plain sine wave output at lower amplitudes anyway

-
- Posts: 1801
- Joined: Sun Apr 03, 2022 1:57 pm
- Has thanked: 102 times
- Been thanked: 350 times
Re: Current control of induction motors
I think you could be right with your suspicions about deadtime. At small pulsewidths deadtime will have a much larger impact and will cause the current to be slow to move away from 0 which is pretty much what you are seeing. Will be interesting to see your results with svpwm disabled but my guess is that the distortion around the zero crossing will still be there.catphish wrote: ↑Sat Jan 28, 2023 5:54 pm I'll test tomorrow without the space vector offset. I'm also wondering if the space vector is a red herring and we jump it because it happens to have a similar shape. Another potential cause is deadtime.
As far as I know, shifting all three waveforms by the same amount is the (or at least one of several) correct ways to do SVPWM, however I wonder if rather than doing it all the time, we'd be better off outputting plain sine waves until we actually run out of voltage, and only shift the waveforms at that point. This would have the benefit of using more of the DC bus voltage, hence giving better PWM resolution, and less impact of deadtime.
Edit - actually is this right with centre aligned PWM??
-
- Posts: 1801
- Joined: Sun Apr 03, 2022 1:57 pm
- Has thanked: 102 times
- Been thanked: 350 times
Re: Current control of induction motors
Also just noticed that there was a word missing in yesterday's post, it was supposed to read "A SVPWM table wouldn't work for FOC". Sorry for the confusion!
- johu
- Site Admin
- Posts: 6618
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 342 times
- Been thanked: 1485 times
- Contact:
Re: Current control of induction motors
It's never right as 0 voltage is commanded with roughly 50/50. Small pulse width only occur at high amplitudes.Pete9008 wrote: ↑Sun Jan 29, 2023 8:34 am I think you could be right with your suspicions about deadtime. At small pulsewidths deadtime will have a much larger impact and will cause the current to be slow to move away from 0 which is pretty much what you are seeing. Will be interesting to see your results with svpwm disabled but my guess is that the distortion around the zero crossing will still be there.
Edit - actually is this right with centre aligned PWM??
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
-
- Posts: 1801
- Joined: Sun Apr 03, 2022 1:57 pm
- Has thanked: 102 times
- Been thanked: 350 times
Re: Current control of induction motors
Not sure, the way deadtime is calculated and the offsets it produces can have some unexpected side effects in full bridges and three phase systems. Be interesting to see the results 

- catphish
- Posts: 959
- Joined: Fri Oct 08, 2021 11:02 pm
- Location: Dorset, UK
- Has thanked: 96 times
- Been thanked: 188 times
Re: Current control of induction motors
Pete9008 wrote: ↑Sun Jan 29, 2023 8:34 am I think you could be right with your suspicions about deadtime. At small pulsewidths deadtime will have a much larger impact and will cause the current to be slow to move away from 0 which is pretty much what you are seeing. Will be interesting to see your results with svpwm disabled but my guess is that the distortion around the zero crossing will still be there.
Edit - actually is this right with centre aligned PWM??
Johannes is correct. At zero sine wave amplitude, the inverter output is 50/50, so i think the deadtime should be negligible.
I redid the test with SVPWM offset disabled. It's still broken. I can't comprehend what's going on here

There seem to be multiple oddities to see here, but the standout problem is the odd current shape.
NB. This is running at 0Hz shaft speed plus 0.5Hz slip. The period is about 2.5 seconds. The top values are the actual hardware PWM outputs (shifted down, originaly centered at +1024 to fit nicely on the chart)
-
- Posts: 1801
- Joined: Sun Apr 03, 2022 1:57 pm
- Has thanked: 102 times
- Been thanked: 350 times
Re: Current control of induction motors
What's the voltage scale there, any idea what the actual pwm register values are? Very suspicious about the zero crossing, if its not deadtime then quantisation?
Edit - I think the zero crossing distortion on one phase may be responsible for the peak dip on another.
Edit2 - pretty good sin waves though
Edit3! - do the SDU gate drivers have any deadtime functionality built into them?
Edit4!! - do you have any way of plotting the phase to phase voltage values rather than the phase values. I think that small waveform distortions may be leading to phase to phase errors that would become apparent if they are plotted.
Edit - I think the zero crossing distortion on one phase may be responsible for the peak dip on another.
Edit2 - pretty good sin waves though

Edit3! - do the SDU gate drivers have any deadtime functionality built into them?
Edit4!! - do you have any way of plotting the phase to phase voltage values rather than the phase values. I think that small waveform distortions may be leading to phase to phase errors that would become apparent if they are plotted.
- catphish
- Posts: 959
- Joined: Fri Oct 08, 2021 11:02 pm
- Location: Dorset, UK
- Has thanked: 96 times
- Been thanked: 188 times
Re: Current control of induction motors
1) The PWM scale is 0..2047, centered at 1024. Attached is a chart with the raw values (I just removed the offset).Pete9008 wrote: ↑Sun Jan 29, 2023 9:56 am What's the voltage scale there, any idea what the actual pwm register values are? Very suspicious about the zero crossing, if its not deadtime then quantisation?
Edit - I think the zero crossing distortion on one phase may be responsible for the peak dip on another.
Edit2 - pretty good sin waves though
Edit3! - do the SDU gate drivers have any deadtime functionality built into them?
2) The sine wave looks pretty good, though I need to work out why it occasionally appears to skip backwards a step.
3) I don't know if there's any hardware deadtime. I assume (hope) the value of deadtime=63 came from somewhere. I'm scared to attempt to reduce it, as my only power source is my battery.
The PWM resolution isn't great, but it really should be good enough to create something that looks like a sine wave.
Edit: looking closely at this waveform it looks like its missing its peaks. Perhaps the resolution isn't good enough?
-
- Posts: 1801
- Joined: Sun Apr 03, 2022 1:57 pm
- Has thanked: 102 times
- Been thanked: 350 times
Re: Current control of induction motors
Did you notice edit4 above? It's relevant to your comment on the peak too.
Re deadtime I was wondering whether Tesla the hardware might have a deadtime function built in too, if it was larger than the firmware deadtime it could produce some interesting effects (unlikely but worth a thought).
Re deadtime I was wondering whether Tesla the hardware might have a deadtime function built in too, if it was larger than the firmware deadtime it could produce some interesting effects (unlikely but worth a thought).
- catphish
- Posts: 959
- Joined: Fri Oct 08, 2021 11:02 pm
- Location: Dorset, UK
- Has thanked: 96 times
- Been thanked: 188 times
Re: Current control of induction motors
I'll see if I can export the data into a spreadsheet and do a calculation of the phase to phase voltage.
- johu
- Site Admin
- Posts: 6618
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 342 times
- Been thanked: 1485 times
- Contact:
Re: Current control of induction motors
That is surprising but also good to know it's not a flaw in the svpwm implementation. I wonder what values actually make it to the IGBTs? It wouldn't be short pulse suppression as you're far away from extreme duty cycles.
Actually, what are we looking at? Is that from a Prius inverter or Tesla?
Actually, what are we looking at? Is that from a Prius inverter or Tesla?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
- catphish
- Posts: 959
- Joined: Fri Oct 08, 2021 11:02 pm
- Location: Dorset, UK
- Has thanked: 96 times
- Been thanked: 188 times
Re: Current control of induction motors
I've plotted the phase-to-phase voltages (based on the PWM output values). It looks clean.
- catphish
- Posts: 959
- Joined: Fri Oct 08, 2021 11:02 pm
- Location: Dorset, UK
- Has thanked: 96 times
- Been thanked: 188 times
Re: Current control of induction motors
This is the tesla, and with my new code. I definitely don't think this is going anywhere near the deadtime or short pulse suppression. My guess would be that the PWM value vs phase to phase voltage relationship isn't linear in the way we assume?johu wrote: ↑Sun Jan 29, 2023 10:38 am That is surprising but also good to know it's not a flaw in the svpwm implementation. I wonder what values actually make it to the IGBTs? It wouldn't be short pulse suppression as you're far away from extreme duty cycles.
Actually, what are we looking at? Is that from a Prius inverter or Tesla?
-
- Posts: 1801
- Joined: Sun Apr 03, 2022 1:57 pm
- Has thanked: 102 times
- Been thanked: 350 times
Re: Current control of induction motors
I'm pretty much out of ideas then 
Only other question is does it still do it with the rotor locked, or is this with the rotor locked?
Edit - I know it's an induction motor but could it be cogging? See https://www.electrical4u.com/craw ... 0cogging.

Only other question is does it still do it with the rotor locked, or is this with the rotor locked?
Edit - I know it's an induction motor but could it be cogging? See https://www.electrical4u.com/craw ... 0cogging.
- catphish
- Posts: 959
- Joined: Fri Oct 08, 2021 11:02 pm
- Location: Dorset, UK
- Has thanked: 96 times
- Been thanked: 188 times
Re: Current control of induction motors
This is with the rotor locked (specifically, this is in my car, with the brake on, and i'm deliberately pushing slightly too little current to create substantial torque).Pete9008 wrote: ↑Sun Jan 29, 2023 12:01 pm I'm pretty much out of ideas then
Only other question is does it still do it with the rotor locked, or is this with the rotor locked?
Edit - I know it's an induction motor but could it be cogging? See https://www.electrical4u.com/craw ... 0cogging.
It's definitely possible that the stator windings are creating this harmonic.
-
- Posts: 1801
- Joined: Sun Apr 03, 2022 1:57 pm
- Has thanked: 102 times
- Been thanked: 350 times
Re: Current control of induction motors
Bit heavy on the math but worth a look on the harmonics (5th looks a possibility)? https://www.analog.com/media/en/tra ... ter3.pdf
- catphish
- Posts: 959
- Joined: Fri Oct 08, 2021 11:02 pm
- Location: Dorset, UK
- Has thanked: 96 times
- Been thanked: 188 times
Re: Current control of induction motors
So it turns out the relationship between output voltage and rotor speed is almost completely linear (who knew?!).
This gives me a crazy idea. What if instead of measuring current, I just set the output voltage according to measured rotor frequency?
Yes, I know... but I'm tempted to try something a little different - using the V/Hz curve, but with fully dynamic slip. With the correct motor parameters, I wonder if I can disconnect both voltage and current from the throttle, and instead allow current to fluctuate dynamically while controlling only slip.
I have no idea what the results will be, but I sure want to find out. I guess this is just what you get if you (carefully) set fslipmin=0 and ampmin=100 on the V/Hz firmware, and I'm intrigued.
It's worth noting that I've now proven we can effectively do cycle by cycle current limiting, so after getting fed up with current sensors, I think I will play with the V/Hz firmware for a while and see if I can bring across what I've learned here.
Edit: 30 seconds of testing has put an end to this idea. The idea above doesn't work at all. I'll have another stab at tacking the current sensing issue.
This gives me a crazy idea. What if instead of measuring current, I just set the output voltage according to measured rotor frequency?
Yes, I know... but I'm tempted to try something a little different - using the V/Hz curve, but with fully dynamic slip. With the correct motor parameters, I wonder if I can disconnect both voltage and current from the throttle, and instead allow current to fluctuate dynamically while controlling only slip.
I have no idea what the results will be, but I sure want to find out. I guess this is just what you get if you (carefully) set fslipmin=0 and ampmin=100 on the V/Hz firmware, and I'm intrigued.
It's worth noting that I've now proven we can effectively do cycle by cycle current limiting, so after getting fed up with current sensors, I think I will play with the V/Hz firmware for a while and see if I can bring across what I've learned here.
Edit: 30 seconds of testing has put an end to this idea. The idea above doesn't work at all. I'll have another stab at tacking the current sensing issue.
- catphish
- Posts: 959
- Joined: Fri Oct 08, 2021 11:02 pm
- Location: Dorset, UK
- Has thanked: 96 times
- Been thanked: 188 times
Re: Current control of induction motors
Just to note, the behaviour is exactly the same in the V/f firmware. It obviously doesn't matter as much here, but interesting that it still doesn't look like a clean sine wave.
- catphish
- Posts: 959
- Joined: Fri Oct 08, 2021 11:02 pm
- Location: Dorset, UK
- Has thanked: 96 times
- Been thanked: 188 times
Re: Current control of induction motors
Just did a bit of reading. It seems very likely that this waveform is the result of oversaturating the stator magnetic field at this very low frequency. It may be that the magnetizing current needs to vary with frequency (or more likely, I'm just not setting it correctly).
This paper has some similar looking waveforms. https://www.sciencedirect.com/science/a ... 2316300177
I feel like it would be easier if I had a hard figure for the correct magnetizing current for an SDU, even just a ballpark.
Edit: I'll go read my book again!
This paper has some similar looking waveforms. https://www.sciencedirect.com/science/a ... 2316300177
I feel like it would be easier if I had a hard figure for the correct magnetizing current for an SDU, even just a ballpark.
Edit: I'll go read my book again!
-
- Posts: 1801
- Joined: Sun Apr 03, 2022 1:57 pm
- Has thanked: 102 times
- Been thanked: 350 times
Re: Current control of induction motors
I think the voltage and speed will only be proportional for a fixed rotor current, the moment the rotor current changes so does the flux linkage and so the back emf.
Find it a little hard to believe that you are saturating the stator at those currents, I could easily believe it is saturating the rotor though (that would also give very odd current waveforms).
I like all the approaches that you are are trying here but still think you need a better handle on the rotor current/flux to make them work well.
Find it a little hard to believe that you are saturating the stator at those currents, I could easily believe it is saturating the rotor though (that would also give very odd current waveforms).
I like all the approaches that you are are trying here but still think you need a better handle on the rotor current/flux to make them work well.
- catphish
- Posts: 959
- Joined: Fri Oct 08, 2021 11:02 pm
- Location: Dorset, UK
- Has thanked: 96 times
- Been thanked: 188 times
Re: Current control of induction motors
That certainly seems to be the case. Using raw V/Hz directly doesn't work correctly at all. I'll ignore that idea and get back to learning about current and flux linkage.
I believe you're correct on both counts. I've certainly been flailing a little while learning and experimenting with simple approaches that almost work.Pete9008 wrote: ↑Sun Jan 29, 2023 7:31 pm Find it a little hard to believe that you are saturating the stator at those currents, I could easily believe it is saturating the rotor though (that would also give very odd current waveforms).
I like all the approaches that you are are trying here but still think you need a better handle on the rotor current/flux to make them work well.
Here is what I do know so far:
* Current delivered to the stator windings is divided into an active portion that delivers torque and a reactive portion.
* By adjusting slip, we can change the proportion of D and Q currents.
* At full torque in steady state (at least as far as I've pushed it), each winding carries 500A RMS, the optimal slip is around 3Hz, and the power factor is around 0.6.
* Something is interfering with my current, creating unusual waveforms.
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.
I think next I should capture compare the current waveforms with a few different frequencies and currents with the rotor locked. I should also try to find some information about how the rotor gets magnetized.
Thank you for the pointers so far. I realise you understand the physics better than I do!
- catphish
- Posts: 959
- Joined: Fri Oct 08, 2021 11:02 pm
- Location: Dorset, UK
- Has thanked: 96 times
- Been thanked: 188 times
Re: Current control of induction motors
Here's a dump of the current state of affairs (the good and bad).
Also a savvycan dump of a couple of miles of driving with gentle and hard acceleration if anyone else can be bothered to dig into the data.
The main outstanding problem seems to be the voltage/current oscillations during very slow/gentle driving (ie small slip, usually low rotor speed), possibly caused by unusual current waveforms. Otherwise response is excellent.
Also a savvycan dump of a couple of miles of driving with gentle and hard acceleration if anyone else can be bothered to dig into the data.
The main outstanding problem seems to be the voltage/current oscillations during very slow/gentle driving (ie small slip, usually low rotor speed), possibly caused by unusual current waveforms. Otherwise response is excellent.
- Attachments
-
- drive-savvycan.tar.gz
- (3.16 MiB) Downloaded 446 times