# Confused about PID controller for current control with PMW

jim hardy
Gold Member
Dearly Missed
well you're certainly beyond my experience base here.

This link is a quick introduction to the FOC method
http://www.ti.com/lit/an/bpra073/bpra073.pdf
and is my first exposure to it
but it helps.

Let me talk completely through my hat here and be honest about it.

--------------- Start thinking out loud------------------

Now - i noticed those terms wLqIq and wLdId in eq's 3.1 and 3.2, near this statement
Eqs.3.1-3.2 also
indicates that two current-loop are coupled together.

d(Iq)/dt = (1/Lq)[ -Rs Iq - ω Ld Id - ω λm + Vq ] (3.1)
d(Id)/dt = (1/Ld)[ -Rs Id + ω Lq Iq + Vd ] (3.2)

Now why on earth is Ld Id in the Iq formula 3.1, and and vice versa?

let's rearrange 3.1 and 3.2

(3.1) Lq * d(Iq)/dt = [ -Rs Iq - ω Ld Id - ω λm + Vq ]

(3.2) Ld *d(Id)/dt = [ -Rs Id + ω Lq Iq + Vd ]

well now , Ldi/dt is a voltage
and w L I is a voltage
so we have in the quadrature axis voltage formula a direct axis voltage term wLdId
and we have in the direct axis voltage formula a quadrature axis voltage term wLqIq
looks to be criss-crossed, but in sinewaves physical displacement and phase are equivalent

can it be this simple:
direct and quadrature axes are 90 physical degrees apart
and there's only one current, sum of direct and quadrature
so direct axis current Iq through direct axis inductance Lq makes a voltage 90 deg out of phase with Iq but in phase with Id ? And in phase with Vd, if Vd is direct component of counter-emf Vs i think ??
observe signs are swapped in 3.1 and 3.2 and on fig 4.2 as well, inferring a physical displacement on the rotatin frame

guys that's in the spirit of a question from a struggling student not an assertion of fact.
I sure dont have my brain around FOC yet

So do I understand correctly that the two terms ωLdId and ωLqIq together result in a angle adjustment/change?
seems to me it'd affect amplitude of both d and q current components according to machine constants Lq and Ld, so probably tweaks phase and amplitude both.

As best i recall there's not a lot of crosstalk between direct and quadrature fluxes in an ordinary machine so maybe that's why author says on page 8 it's an optional performance enhancement

For better dynamic performance, crosscoupling
terms (ωLdId and ωLqIq) may also be compensated as in Fig. 4.2.

----------------------end thinking out loud--------------

Thanks for indulging me - i feel better about FOC now.

If i keep hanging out with you guys i may not be so intimidated by wife's new washing machine!

Wow!
I wish I could 'think out loud' this way. I'm not really a math person. Although I understand some. I have to study your 'thinking' more closely.
I always want to understand what I'm doing in a practical way. When I tweak parameters or change algorithms I want to be able to predict the result. I want to be able to explain what is going on in a none mathematical manner. Than I can work and play with it.

The way I see FOC is that it is a nice transformation such that the motor can be controlled more like a DC brushed motor. The big advantage is that the PID controllers operate on a DC level (for a steady state). They do not have to track the sinusodial phase voltages. The rotor position is needed to transfer to and from the rotating coordinate system.

But I do not understand yet what these ωLdId and ωLqIq terms do. But I will study your 'thinking' more closely.

My conclusion so far (please correct me if I'm wrong):

I think my question equally applies to a brushed DC motor as a FOC controlled brushless motor (and others).

Suppose I want to control a (brushed) DC motor. I can use a PID for speed control like in figure A below. This works because the motor voltage is more or less proportional to the motor speed. This is mainly because of the back-emk. Higher speed means higher back-emk, thus the voltage need to be higher.

But I could also implement torque control by sensing the current like in figure B above. This works because the motor is not a pure inductor. The resistor part is also strongly present.
But the voltage still has to overcome the back-emk. Am I correctly when saying that the Integrator part of the PID controller will take care of this? It will change the motor voltage (integrating the error) until the bacl-emk is compensated?

To improve the control loop you could compensate for this back-emk like in figure C above.
Will this make the PID faster because we do not have to wait for the integration to compensate the back-emk (and the integrator is only used to make the torque error smaller)?

I hope my conclusions are correct so far.

There's no problem with not using decoupling - in fact, it is far more common to not use it and just throw in a couple of PI's to control the d and q current components, respectively, which you can easily tune (lock the rotor, back-emf terms are zero, tune one loop and apply the same gains to the other).

Now, let's say you want to design the controllers instead so you can make them adhere to some performance specifications. Using classical linear control theory, you'll quickly realize that the d and q systems are simply just a couple of low pass filters - but only if you use decoupling!

By using decoupling you are effectively linearizing the systems you're trying to control, by which you can make linear controllers (like PI/PID's) more effective, i.e. get a better dynamic response.

But the voltage still has to overcome the back-emk. Am I correctly when saying that the Integrator part of the PID controller will take care of this? It will change the motor voltage (integrating the error) until the bacl-emk is compensated?

Yes, this is correct. Look at the back-emf term though, notice the only time-varying part of it is the angular velocity of the motor. This velocity changes veeeery slowly compared to the current. The PID effectively sees the back-emf as a disturbance which is constant in time over the period in which the current changes. Even a poorly tuned PID will be very effective at rejecting this, so you shouldn't expect much of a gain in performance when adding compensation for it.

On the other hand, notice how the d and q components of the back-emf in the case of the PMS motor depend on more than just the angular velocity of the motor - specifically, notice they include current components. You're trying to control currents and you have disturbances that change as fast as what you're trying to control, which is usually bad. Adding compensation here is a much more viable option than in the DC case.

jim hardy
Gold Member
Dearly Missed
i think i'd best defer to someone better versed . This is my first foray into FOC

Wasn't it Mark Twain quipped "Tis better to remain quiet and be thought a fool than to speak out and remove all doubt." ?
i already missed one chance to remain quiet. From here on i'll learn FOC from you fellows.

old jim

I feel I should try to offer a bit of intuition with regards to those voltage terms I labeled as 'back-emf terms'.

I'll just restate the PMSM voltage equations for reference purposes:
Vq = R Iq + Lq d(Iq)/dt + ω Ld Id + ω λm
Vd = R Id + Ld d(Id)/dt - ω Lq Iq

- Left hand side of these equations should be clear, they're the dq-components of the stator terminal voltages.
- First terms on the right hand side are the resistive drops.
- Second terms are transient drops - zero in steady state.

Now, these third terms represent dq-components of an inductive voltage drop. The Id current will produce a voltage drop leading the d-axis by 90 deg. It will thus be on the q-axis, which is what the q-component equation reflects.

Same thing goes for the d-component equation. The Iq current will produce a voltage drop leading the q-axis by 90 deg, which will place it in the negative direction on the d-axis, which is what the minus sign reflects in the d-component equation.

- The fourth term in the q-component equation is the true back-emf term - it leads the d-axis by 90 deg, as it must.

The third and fourth terms on the right hand side are commonly known collectively as the speed voltages.

I hope this helps, I think it's is as much as I can explain without going mathy.

Edit:
Ok so I have a bit more as to the origin of the third terms. Me calling them back-emf terms is really very misleading, I just want to make that clear - they have nothing to do with the back-emf (the rotor flux should influence them if they did, but the rotor flux is only part of the fourth term).

If you consider the steady state case where the dq current components and the angular velocity of the rotor is constant, then the stator current must be producing a rotating magnetic field. The motor has inductance so this changing stator current must produce an inductive voltage drop. Where is this reflected in the dq-component equations? It's the third terms.

Last edited:
I feel I should try to offer a bit of intuition with regards to those voltage terms I labeled as 'back-emf terms'.

I'll just restate the PMSM voltage equations for reference purposes:
Vq = R Iq + Lq d(Iq)/dt + ω Ld Id + ω λm
Vd = R Id + Ld d(Id)/dt - ω Lq Iq

- Left hand side of these equations should be clear, they're the dq-components of the stator terminal voltages.
- First terms on the right hand side are the resistive drops.
- Second terms are transient drops - zero in steady state.

Now, these third terms represent dq-components of an inductive voltage drop. The Id current will produce a voltage drop leading the d-axis by 90 deg. It will thus be on the q-axis, which is what the q-component equation reflects.

Same thing goes for the d-component equation. The Iq current will produce a voltage drop leading the q-axis by 90 deg, which will place it in the negative direction on the d-axis, which is what the minus sign reflects in the d-component equation.

- The fourth term in the q-component equation is the true back-emf term - it leads the d-axis by 90 deg, as it must.

The third and fourth terms on the right hand side are commonly known collectively as the speed voltages.

I hope this helps, I think it's is as much as I can explain without going mathy.

Thank you very much for trying! It I learn a lot from these kind of explanations.

So all three components (ω.Ld.Id, ω.Lq.Iq and ω.λm) are neede for a correct back-emk compensation. I was thinking the ω.λm was the only one needed for back-emk compensation and the other two are for another improvement.

What is not clear to me is why there is an inductive voltage drop because of the rotor speed. Does the back-emk consist of 2 components? One depending only on rotor speed and one depending on motor speed and phase current?
If so, then a quick calculation gives me a much higher value for the ω.λm component compared to the ω.Ld.Id and ω.Lq.Iq components. I quess the last two are still (more) important because of the higher frequency component (currents change faster then speed).

Look up my edit in my previous post, I think that clears some of it up.

There is only one back-emf term, the fourth term on the right hand side in the q-component equation. The third terms must be there regardless of the back-emf.

When adding decoupling, you add compensation for both the back-emf and the coupling terms. This is different from the DC case.

Ok Thanks

I see now you explain it in the last sentence. Sorry I overlooked it.

Is it correct that these third terms are usually much smaller then the back-emk (fourth term of Vq) term? And did I understand correctly that these third terms are still important because they change faster then the back-emk (current changes faster than speed)?

The coupling terms can be considerable in magnitude compared to the back-emf but it's difficult to say in general as it depends on the parameters of the machine you're working with.
And did I understand correctly that these third terms are still important because they change faster then the back-emk (current changes faster than speed)?

You don't really care about the back-emf term since it changes so slowly compared to the current component - any controller with integral action will reject it (same as in the DC case). As you say, due to the high frequency content of the third terms, these are the important terms to compensate for.

But really, if you use decoupling, you're mostly doing it to simplify the design procedure using linear control theory. The performance without decoupling can be very good.

Thanks for all the time spend in this thread.
I learned a lot and will learn more reading it over a few times more.

Thanks all.

jim hardy
Gold Member
Dearly Missed
thank you indeed, miles.

The motor has inductance so this changing stator current must produce an inductive voltage drop.

i'm a picture thinker not a math thinker.

Is this similar to "Armature Reaction" i learned fifty years ago? Which relates to Synchronous impedance ?

if so, it'll help me get fluent with this new(to me) FOC technique. I see it's been around since eighties at least....

curmudgeon that i am, i must admit that controlling a motor in this fashion is one of the most interesting things for a computer to do that i've ever seen .

just think what one could do with an H-bridge and an old car alternator.....

thanks again

old jim

I only know of 'armature reaction' in the context of synchronous generators. It had something to do with how the armature and field flux interact when you hook up a load - the armature "reacts" with its own flux distribution in the air gap due to a load current.

Field oriented control (often also called vector control) is basically just an idea of how you can convert 3 phase machine quantities to meaningful vector representations and apply control to these vectors. Let me give an example of how to do torque control of a PMS machine using vector control:

Let's say you have a 2 pole machine so you can view the rotor as a bar magnet. The stator consists of three phase windings 120 deg apart, call these phase a, b and c.

I run current through phase a only. This produces a magnetic field with its magnetic axis aligned with the winding and the rotor will then align itself to this axis (if the field is strong enough to overcome friction). I could do the same for phase b and c and in both cases the rotor will align itself to whatever winding is energized.

Now, if I run current of equal magnitude through phase a and b, the rotor will align itself in between these windings. If I increase the current through phase a while keeping the phase b current constant, the rotor will begin to turn towards phase a. I'm in effect rotating the resulting magnetic field created by the phase currents and the rotor magnetic field is aligning itself with the stator field.

I could now define some vectors that are aligned with the phase windings that have magnitudes equal to the corresponding phase currents. You can show that the vector sum of these space vectors, call it I_sum, is aligned with the resulting magnetic field produced by the phase currents.

If the magnetic axis of the rotor is aligned with the magnetic axis of the stator, no torque is produced. If, on the other hand, the magnetic axis of the stator is at a right angle to the magnetic axis of the rotor, maximum torque is produced. The objective is then to always keep I_sum at a right angle to the magnetic axis of the rotor (for a non-salient rotor).

This is exactly the purpose of using the dq-transformation. The d-axis component tells you how much of I_sum is aligned with the magnetic axis of the rotor. The q-axis component tells you how much of I_sum is at a right angle to the magnetic axis of the rotor.

Anyway, you really need some diagrams to go with all this. I can recommend:
Master course Power Electronics Exercise: Space Vector
Field Orientated Control of 3-Phase AC-Motors

for a quick introduction.

Edit:
There are plenty of other control topologies in field oriented control. Controlling the stator current space vector for maximum torque per amp of current is just one of these. Others include controlling the stator current space vector in such a way as to always draw current at unity power factor (you'd make some friends at your local utility company), or maybe you'd like to control the stator flux vector to make sure you're not damaging your permanent magnets. There are many variants.

Last edited:
thank you indeed, miles.

i'm a picture thinker not a math thinker.

Is this similar to "Armature Reaction" i learned fifty years ago? Which relates to Synchronous impedance ?

if so, it'll help me get fluent with this new(to me) FOC technique. I see it's been around since eighties at least....

curmudgeon that i am, i must admit that controlling a motor in this fashion is one of the most interesting things for a computer to do that i've ever seen .

just think what one could do with an H-bridge and an old car alternator.....

thanks again

old jim

Hi jim,

The compensation with the ω.Ld.Id, ω.Lq.Iq and ω.λm terms we talked about have nothing to do with the basics of FOC. They are improvements. Miles: please correct me if I'm wrong.

This compensation may be confusing when studying FOC.

jim hardy
Gold Member
Dearly Missed
Thank you for that whole post.

This is the pragraph that cleared it up.
If, on the other hand, the magnetic axis of the stator is at a right angle to the magnetic axis of the rotor, maximum torque is produced. The objective is then to always keep I_sum at a right angle to the magnetic axis of the rotor (for a non-salient rotor).

Please appreciate that in my power plant world, if you let a generator get to 90deg you are on the cusp of a pole slip which is violent on a big machine,

i had wondered how close to that point you could run with this FOC

now i've accepted you actually CAN do that it opens a path of thought i'd kept shut.

Thanks !

and yes, re armature reaction: reactive component of armature current produces MMF that directly aids or opposes field MMF because it's aligned. Real component of course is perpendicular, so total MMF (and flux) is vector sum of the three.

over and out !