 1 - 20 of 22 Posts

#### fasset

·
##### Registered
Joined
·
3 Posts
Discussion Starter
Hello.
I'm trying to write my own soft for Field Oriented Control of induction motor. I have finished 3ph 3kW inverter, controled by STM32F4, and V/F open loop algorithm to control ACIM - it works. Now I'm trying to implement FOC algorithm.
As we know we need to do Clark&Park transformation.
To calculate Park transformation it's necessary to know rotor angle flux position. Here some details:
ftp://ftp.ti.com/pub/dml/DMLrequest.../HVACI_Sensored/~Docs/Sensored FOC of ACI.pdf
Another note propose to use speed integration to do this:
http://tinyurl.com/y9lrb4cr
Could anyone expalin how to do this exactly?
I'm measuring currents (5kHz sampling), calculate Clark and measure speed, slip also.
Thanks for any response.

#### Ivansgarage

·
##### Registered
Joined
·
389 Posts
I was reading through some of the docs did not see much on slip.
Slip has a tremendous effect on torque.

Here is more reading on AC 3 phase motors for electric vehicles.
Here is the numbers after the locked rotor test. The motor optimized at 7.00 on slip.

slip -- torque -- amps
7.00 - 142 - 260
6.00 - 160 - 270
5.00 - 180 - 280
4.00 - 220 - 270
3.50 - 225 - 254

Looks like 3.50 is the best on slip gain. Had to turn brake pressure up all the way to hold it.

http://ivanbennett.com/forum/index.php?topic=17.msg1482#msg1482

-

#### fasset

·
##### Registered
Joined
·
3 Posts
Discussion Starter
Thanks it's helpful, but actually I'm trying to use float variables (all more clearly to read). I suppose there is no floats due to no FPU in CPU used in this project.
Here is part of my code:

Code:
``````void ClarkPark(float L1_curr, float L2_curr)
{
vector.Ialpha = L1_curr;
vector.Ibeta = (L1_curr + 2.0*L2_curr) / 1.732;
//Id =  Ialpha*cos(Angle) + Ibeta*sin(Angle)
vector.Id = vector.Ialpha*cos(vector.AngleFluxDeg) + vector.Ibeta*sin(vector.AngleFluxDeg);
// Iq = -Ialpha*sin(Angle) + Ibeta*cos(Angle)
vector.Iq = (-1.0)*vector.Ialpha*sin(vector.AngleFluxDeg) + vector.Ibeta*cos(vector.AngleFluxDeg);
}

//qdImag = qdImag + qKcur * (qId - qdImag)      ;; magnetizing current
void curModel(void)
{
//qdImag = qdImag + qKcur * (qId - qdImag)      ;; magnetizing current
vector.Imag = vector.Imag + (LOOP_PERIOD / ROTOR_TIME_CONST) * (vector.Id - vector.Imag);
if(vector.Imag == 0) {
return;
}
// VelSlipRPS = (1/fRotorTmConst) * Iq/Imag / (2.0*pi)
vector.VelSlipsRPS  = (1 / ROTOR_TIME_CONST ) * (vector.Iq / vector.Imag) / (2.0*PI);
//VelFluxRPS = iPoles * VelMechRPS + VelSlipRPS
vector.VelFluxRPS = 2.0 * speed.perSec + vector.VelSlipsRPS;
//AngFlux = AngFlux + fLoopPeriod * 2.0 * pi * VelFluxRPS
[B]    vector.AngleFluxDeg = vector.AngleFluxRad * (180.0 / PI);[/B]
}``````
Please tell me If I'm wrong:
I have to keep an eye on vector.AngleFluxDeg variable to be value between 0 - 360 degree? (back to 0 if 360 overflowed).
It will be correct?

#### dcb

·
##### Registered
Joined
·
2,170 Posts
yah induction motors is a bit trickier, pm motors the rotor flux angle is basically the rotor angle, and why they use a position resolver vs a speed encoder.

If you look at mpaulholmes example (proven, as in it is in use) he has a switch statement by motor type, and induction is the biggest case. Seriously, take a look at it, a real nice piece of work, lookup tables for everything, auto parameter identification, uart interface, still fairly easy to follow and well packaged, nice work. He's been at it a while. http://ecomodder.com/forum/showthre...eap-3-phase-inverter-ac-controller-10839.html and IIRC is at least loosely based on http://ww1.microchip.com/downloads/en/AppNotes/00908B.pdf

re:floats, just scale it up or down as you need, this is the performance approach even with a fpu.

So for me the problem conceptually with integrating speed to rotor flux angle is where do you start, and how do you account for drift. I mean you can inject dc at 0 rpm to establish rotor flux angle, and the Rr/Lr time constants (inverse of slip gain) can be estimated, but I need to look more closely at how that is implemented.

#### gunnarhs

·
##### Registered
Joined
·
296 Posts
Thanks it's helpful, but actually I'm trying to use float variables ]Please tell me If I'm wrong:
I have to keep an eye on vector.AngleFluxDeg variable to be value between 0 - 360 degree? (back to 0 if 360 overflowed).
It will be correct?

Hi, I will leave the float stuff out of the question... As the guys here have pointed out for an induction motor you need to find the "real" angle.
One member pointed me to this excellent lecture series by TI
(Teaching old motors new tricks, part4 tackles the induction motor FOC) https://www.youtube.com/watch?v=bZwLFpXhFbI
Your specific part of interest starts at 5:30 and ends at 8:00.
This part explains in detail how the angle is corrected in regard to slip.

PS: I myself did NOT use this for my application related to electric car as this still leaves a lot of problems regarding to temperature variant time-"constant", field weakening and trusting your encoder .which you must use to give you exact position/speed info.
(I do not recommend sensorless FOC for electric vehicle)

#### fasset

·
##### Registered
Joined
·
3 Posts
Discussion Starter
So for me the problem conceptually with integrating speed to rotor flux angle is where do you start, and how do you account for drift. I mean you can inject dc at 0 rpm to establish rotor flux angle, and the Rr/Lr time constants (inverse of slip gain) can be estimated, but I need to look more closely at how that is implemented.
1. I'm starting use CurModel() Clarkpark() functions when speed is more than 100 RPM. I measure speed by optic sensor - 1 pulse per 1 revolution.
2. I have calculated Rr and Lr values by locked shaft and no-load motor test so I don't need to estimate it.

#### dcb

·
##### Registered
Joined
·
2,170 Posts
1 pulse per 1 revolution.
fyi, that doesn't sound like nearly enough pulses to even bother with an encoder. Or is that a separate index pulse? You might want to spell out your project in a bit more detail (i.e. source code repository, equipment and part numbers, schematics, etc) if you need help with it, otherwise it is a big, unfun, guessing game for anyone trying to help.

I'd also be curious what values you came up with for Rr Lr etc for that 3kw motor.

#### gunnarhs

·
##### Registered
Joined
·
296 Posts
1. I'm starting use CurModel() Clarkpark() functions when speed is more than 100 RPM. I measure speed by optic sensor - 1 pulse per 1 revolution.
2. I have calculated Rr and Lr values by locked shaft and no-load motor test so I don't need to estimate it.
Ok, you need to do some work before starting with FOC

1) You must get your speed sensor (encoder?) to give you at least correct rotor speed (minimum 25 pulses per revolution, preferable 60 + if you need to identify quick speed changes). Even the shitty variable reluctance sensors which are used together with rusty ABS-rings can do that.
For control of Electric motors you need at least Hall effect sensor with decent sprocket wheel (usually at least 50 + teeth).
Note: Regardless of sensor the basic idea is to feed the pulses to a counter mechanism in the microprocessor, there are different ways to do that.
Here is some literature on that, see link below and attachment
https://www.electronicproducts.com/...s_VR_Which_speed_sensor_is_wrong_for_you.aspx

2) When you think you have correct speed you should verifiy it with a closed loop V/f where you use the feedback of the speed sensor to control the slip. You can work from nominal parameters you already know. This gives you an idea how quick the reaction is.

3) Parallel and independent to 1) and 2) you can develop a FOC-schema based ONLY on current measured. If you are confident with your V/f control and you are driving your motor in a steady state, you can calculate the Id and Iq currents from the measured phase currents with the transformation. You can store these values and use them later to control the motor in FOC (without speed measurement) and compare it to the (open loop for example ) V/f under same steady(!) load/frequency/voltage. It should be quite identical, meaning giving similar slip.
Note: This is "sensorless" FOC, meaning you have a slip estimator based on only current measurement. This will work well for smaller motors with constant load / tourque/ speed. The slip will be relative to (Iq/Id)(1/Time-constant).

4) When you are confident with 1-3) you add the speed feedback to your FOC-model and calculate the "real" angle of the electric flux from calculated slip as mentioned in before comments.
You still have not the fastest control most responsive but you are getting there.
You still have indirect FOC, meaning you are reacting to changes.
You have though the possibilities to pre-act by setting Voltage and slip or by setting known Id/Iq from known values.

5) Now you want to do better and not only calculate slip but also get the exact rotor position. One method to get it from the encoder is to use some index marker on the sprocket. In the most primitive way it can be a tooth missing With the rotor position and speed you can refine your model even better and now you are in position of direct FOC (or direct torque control DTC if you have a good Space-Vector-Map).

Note: for a synchronous permanent magnet motor you only would need position from encoder (better than only speed because of starting condition). For an asynchronous induction machine under variable load/speed you need both.

6) Now we want to abandon the universal model and optimize it for our motor. We will add parmeters like inertia and calculate the rotor "constants" from measured heat values to get the complete motor model.

PS: I have been playing around with this stuff for a few years , I am still in step 4 Best regards, and wishes for your project, you will have a lot of fun and learning... #### Attachments

• 99.6 KB Views: 29

#### Tony Bogs

·
##### Registered
Joined
·
730 Posts
Yah, 1 pulse per rev is not enough.
For determining the rotor flux angle, the rotor time constant must be known.
It not only is part of the the equation for the rotor angle speed, but it also affects the Id transfer function of the motor (source video in gunnahrs post).

Here are my conclusions with regard to FOC, EV and ACIM with speed sensor.

1. PWM ripple in the phase current signals can destabilize PI control, so FOC needs a high PWM frequency and filters. Source (for instance): wikipedia.
A low PWM frequency means heavy filtering, hitting the dynamic performance of FOC, and rendering it useless.

2. A bit of temperature drift and the initial fault in the rotor flux angle are additional error signals that are compensated by the PI controller.
Source: basic control systems theory, working FOC implementations and mathematical models.

3. The rotor time constant has to be adjusted. This is very important. The name suggests a constant value under all circumstances, but in fact
the rotor constant not only varies with temperature but it also
satifies a a polynomial equation
whose coefficients are functions of the stator currents, the
stator voltages, and their derivatives. A zero of this polynomial
is the value of the rotor constant.
Quote from: http://web.eecs.utk.edu/~tolbert/publications/ipemc2006_im.pdf.
So what does this mean?. Under steady state conditions the PI controller keeps the rotor constant close to zero. Source: video in gunnarhs post.
But this is not the case under dynamic conditions, for instance when a sudden load change occurs. This makes FOC in an ACIM tricky.

4. The encoder must generate a lot of pulses per revolution for smooth control at low RPM.

So I guess I'm sticking to my earlier conclusion: who really needs the dynamic performance of FOC in an everyday EV with a ACIM?

The conclusions change for an EV with an IPM. Tesla model III?

#### kennybobby

·
##### Registered
Joined
·
1,476 Posts
...
3. The rotor time constant has to be adjusted. This is very important. The name suggests a constant value under all circumstances, but in fact
the rotor constant not only varies with temperature but it also ...

So what does this mean?.
Under steady state conditions the PI controller keeps the rotor constant close to zero.
i think "zero" here is a maths term meaning it is a root or solution to the polynomial equation, not that the value is zero.

The time constant is a function of frequency since inductive reactance varies with frequency.

#### Tony Bogs

·
##### Registered
Joined
·
730 Posts
You're absolutely right. I forgot to add "in the equivalent circuit". I was about to edit my post when I saw your post. Thanks.
The inductance in the rotor part of the equivalent circuit (Video in gunnarhs post) is kept zero by the PI controller under steady state.
So it is the time constant of the rotor part of the equivalent circuit that is zero under steady state.

Edit: I'd like to add, from what I have seen so far in working FOC implementations, "tricky" means:
adaptive control, dynamic adjustment of Kp and Ki of the PI controller.

#### dcb

·
##### Registered
Joined
·
2,170 Posts
fwiw, I am always missing some basic understanding in these sorts of discussions (probably because the papers all dive in on the deep end). so here is something that challenged one of my assumptions, and who knows if it is right or not: http://www.vias.org/matsch_capmag/matsch_caps_magnetics_chap5_02.html

it is implying (not looking at mutual inductance here, just a single iron core inductor) that the current waveform for sinusoidal flux isn't sinusoidal, but that the voltage is. Is this right?!? I think I need to do some more basics/experiments. And of course what happens in reverse (conductor moving in a field) matters for induction motors.

#### gunnarhs

·
##### Registered
Joined
·
296 Posts
fwiw, I am always missing some basic understanding in these sorts of discussions (probably because the papers all dive in on the deep end). so here is something that challenged one of my assumptions, and who knows if it is right or not: http://www.vias.org/matsch_capmag/matsch_caps_magnetics_chap5_02.html

it is implying (not looking at mutual inductance here, just a single iron core inductor) that the current waveform for sinusoidal flux isn't sinusoidal, but that the voltage is. Is this right?!? I think I need to do some more basics/experiments. And of course what happens in reverse (conductor moving in a field) matters for induction motors.
Hi you are addressing here an issue which I had a discussion with one member in another thread one ore two years ago about the T(rafo)-model of an induction machine. The basic assumption is that an induction machine behaves like a trafo which is mostly true in ideal state (steady state, nominal voltage, nominal frequence, nominal load). However even in a Trafo where the inductor and reactor are symmetrical, there are inertial effects in material which become a problem when frequency is increased much about nominal. In an induction motor with a squirrel cage this effects will be more evident as the inductor and reactor are totally different (thin copper wire windings in stator, thick metal bars in rotor). So the ideal linear sinus-model and the sinus based transformations become a bit distorted.
The question here which you are implying is how does it affect the FOC?
The basic underlying theory will hold as the distorted induced rotor current will follow the stator current by 90% and we will be able to correct the the flux angle. However if we only use the current-model and not speed-position-feedback we will have a poorer control under very low or very high frequencies / Voltages than we have in nominal state. This is due to the fact that estimated currents are not exactly sinusodial as in the calculation (Note: Park-transformation assumes sinus currents)
The feedback and knowledge of the real rotor speed/position will help us to correct that.
An exact motor model and temperature measurement will improve that further.

In fact we will not realize this distortion effects (except a slightly worse efficiency) until we try to do something like a fast direct torque control where we either switch directly the inverter transistors according to known states or set a voltage/slip combo which is far away from the ideal curve. The most obvious effect is a bad sounding motor.

#### dcb

·
##### Registered
Joined
·
2,170 Posts
ok, so aside from the fact that I need a coloring book to get that, what is the effect if you force sinusoidal current in the stator (via hysterisis band or peak pwm termination or whatev) and vary stator current frequency and amplitude? My gross assumption was that sinusoidal current was always preferrable, and that the bulk of VSI complications are in achieving that (without adding additional reactors to make it a CSI).

#### Tony Bogs

·
##### Registered
Joined
·
730 Posts
Ever seen the flux distribution in a motor as simulated by for instance FEM?
There are moving images online of an ACIM.
Nowhere close to homogenous as assumed by the commonly used models.
I have done some FEM simulations for a pancake PM motor.
Exact model? Forget it.

dcb said:
Basic hysteresis effect.
The hysteresis effect is there, but thank goodness it isn't as strong as suggested by the image in dcbs post.
Especially in a magnetic circuit with an airgap (as for instance an ACIM) the effect is substantially reduced with regard to the effect on the V/I (inductance) relationship.

#### gunnarhs

·
##### Registered
Joined
·
296 Posts
ok, so aside from the fact that I need a coloring book to get that, what is the effect if you force sinusoidal current in the stator (via hysterisis band or peak pwm termination or whatev) and vary stator current frequency and amplitude? My gross assumption was that sinusoidal current was always preferrable, and that the bulk of VSI complications are in achieving that (without adding additional reactors to make it a CSI).
Yes sinusodial excitation and induction is preferable as it induces a smooth circular movement. Under normal conditions (nominal frequency / voltage) the (variable) waveform stator side induces a similar waveform rotor side. There are 3 main components which influence the transfer-function
1)The airgap + the induced magnetic field ensure the 90 degree shift between stator and rotor. this will not change unless the motor shape /winding changes drastically

2) The rotor electrical resistance/inductance (R/L) influences the heat and the harmonics of the system. As the frequency gets higher , the harmonics component (2*pi*f*L) becomes more resistive so the rotor current changes from being the harmonic sinus swinging 90 degrees related with the stator sinus to a more linear current ( first trapez shaped then more triangle ). That means increasing the stator voltage will have less and less effect and increasing the frequency will reduce the torque producing current part.

3) The motor load has an extra effect on the system, mechanical inertia ( a big rotor has a lot of inertia without a load) and back emf (acts as generator when slowed down or reversed).

#### Tony Bogs

·
##### Registered
Joined
·
730 Posts
dcb said:
My gross assumption was that sinusoidal current was always preferrable, and that the bulk of VSI complications are in achieving that (without adding additional reactors to make it a CSI)
You're right: an ACIM is made for low frequency sinus. Long list of unwanted effects from VSI: eddy currents, core losses, EMI, wear on materials and the list goes on ....

But an FOC calculation is the topic of this thread, so I'll leave it at that.

#### dcb

·
##### Registered
Joined
·
2,170 Posts
1 - 20 of 22 Posts