## confused about PID controller for current control with PMW

Hi,
I'm looking into the control of a PMSM (permanent magnetics synchronous motor) motors using H-briges and PWM (puls width modulation).

I'v seen motor controllers that use a PID controller for speed regulation. The output of the PID controls the PMW. This makes sense to me because the PMW controls the voltage of the motor phases and this is proportional to the speed. The speed is measured and feed back into the PID.

But now I want to regulate the torque, thus the current. I have seen implementations that use a PID controller with current inputs (reference and sensed phase current) and again the output of the PID controlling the PMW. So essentially the same setup as for speed control.
I do not understand this. The output of the PID should control the motor current. But it controls the voltage. The current will increase or decrease because of the voltage and inductance. So there is an extra integration going on. How is it possible such a PID loop works?

 PhysOrg.com engineering news on PhysOrg.com >> Researchers use light projector and single-pixel detectors to create 3-D images>> GPS solution provides 3-minute tsunami alerts>> Single-pixel power: Scientists make 3-D images without a camera
 You can regulate either speed or torque but not both at the same time. The motor controllers I have worked with, control the speed, increasing the torque as needed until the torque limit is exceeded. At that point the speed is reduced to keep the torque (or current) from exceeding its set limit. Sometimes the torque is limited on startup to keep the motor from accelerating too rapidly. If on the other hand you need constant torque, then the speed must be free to change in order to deliver that torque.
 I understand that I can not control both torque and speed at the same time. The point is that I do not understand how the torque regulation is done using the described PID controller with PMW. The PID has current value inputs but controls the voltage of the motor. And the voltage of the motor is not proportional to the current because of the indictance. So how does this work?

## confused about PID controller for current control with PMW

I'm sorry, I didn't notice before you mentioned that it is a synchronous motor. I believe the speed of a synchronous motor is controlled by the frequency, not the voltage. Why would you want to use a PID controller with a synchronous motor?

 I agree that the speed can be controlled by the frequency of the sinusoidal waveforms. But in that implementation the motor position was used to generate the correct sinusoidal phases. And the PID output controlled the amplitude of the sinusoidal waveforms. So the speed is indeed controlled by the voltage. The frequency adapts automatically. My question still stands. How can a PID controller work when it compares current values as input and when it controls the PWM with its output. Because this PMW corresponds to voltage control. The current will increase or descrease because of the voltage. This is an extra integration. I want a PID because I want to control the torque.

 Quote by mechamania I agree that the speed can be controlled by the frequency of the sinusoidal waveforms. But in that implementation the motor position was used to generate the correct sinusoidal phases. And the PID output controlled the amplitude of the sinusoidal waveforms. So the speed is indeed controlled by the voltage. The frequency adapts automatically. My question still stands. How can a PID controller work when it compares current values as input and when it controls the PWM with its output. Because this PMW corresponds to voltage control. The current will increase or descrease because of the voltage. This is an extra integration. I want a PID because I want to control the torque.
Can you provide the model or block diagram of both (voltage control and current control) PID systems? Often times you can use conversion factors to derive one from the other. You have an electrical transfer function or model that describes the motor components, right?

Recognitions:
Gold Member
i saved a Powerpoint presentation from TI that's pretty exhaustive
you might see if it's still available
title is
TI_MotorControlCompendium_2010.ppt

from a post in February:
 See if you can open the powerpoint presentation here - ( you need Microsoft's free powerpoint reader ) i think you'll like it. http://focus.ti.com/docs/training/ca...?sku=OLT210201 http://focus.ti.com/download/trng/do...ndium_2010.ppt
hope it helps..

edit see around slide 165
i think it requires measuring rotor position and controlling "quadrature" current
which would to me mean phase, which becomes frequency...
so a pid on phase of stator voltage relative to shaft position ought to work,
isn't that power angle?

 @DragonPeter I have no models yet. I just want to understand how it works first. @jim hardy Thanks. Found it. Looks very interesting. Will take some time to study it ;-)

 Quote by mechamania @DragonPeter I have no models yet. I just want to understand how it works first.
In that case, forgive me if I am thinking too simply or ignorantly here, but if you apply a voltage to a motor's terminals with any load whatsoever, then you will also have a current. Much like in a circuit you will have a current and a voltage with a load. If I tell you the voltage and resistance of a resistor circuit, you will be able to tell me the current with Ohm's law, and if I told you to increase the current by 10%, you could simply increase the voltage by 10% if R is constant. So if you can sense and control voltage, you indirectly are controlling current and vice versa because you know the inductance and resistance of the windings and the Km and Kt constants. You simply use a conversion factor to switch between the two. In a control system block diagram, you can tap between blocks to get the specific output,input, or variable you want to consider, but the system is still a closed loop.

For example, if a motor normally runs 600 RPM from an applied voltage of 50V, you already know what the torque will be at for a known load at that operating point. If you apply 50V, and the motor is running slower than 600 RPM, you know that the current has increased because the back EMF has dropped. The RPM that you're measuring is related to voltage by the motor constant, but indirectly you still know that the current has increased through the known relationship. So, you can lower the voltage in that case til the motor speed drops to a lower value, and for that value to correspond to the desired current by the known relationship.

That is how you could control torque indirectly from a voltage PWM/RPM measurement, but you could also have a shunt resistor to measure current semi-directly (but you could still control it with voltage by the relationship). If I'm off here, please explain to me why, because I will have a misunderstanding myself.

@DragonPetter:

I agree for a pure resistor the voltage control is equal to current control.
But we have a lot of inductance here.
I also agree that I could calculate the needed voltage given the motor speed and motor
parameters (like back emf and inductance).
But the PID regulator does not use al this extra information.
That is why I do not understand that the PID controller works properly. The PID outputs a voltage only given the sensed current and wanted current. No speed sensing, no motor parameters are used.

I found a picture in the document jim pointed me to (see attached pdf file). It is from a FOC controller, but it shows that currents values are used as PID inputs and the output is a voltage. But a voltage to an inductor results in a current change, thus an extra integration. I do not understand this PID loop can work properly.

@ jim hardy:
I did read the document. Very interesting. Thanks again. I attached a page from it that shows my point. See above.
Attached Files
 p172.pdf (84.8 KB, 7 views)

 Recognitions: Gold Member Science Advisor dont forget the loop gets closed by rotor position.

 Quote by jim hardy dont forget the loop gets closed by rotor position.
I found a better picture of a FOC controller.
Here you see the inner PID loops, controlling current.
And the outer PID loop controlling speed.
The rotor position is needed for the transformations.

The output of the inner PIDs control the PMW, thus controls the voltage on the motor windings. The voltage is propotional to motor speed, not motor current.
So why is the current feedback and not the speed?
Attached Thumbnails

 I found a better (much simpler) controller diagram to explain my question. See attachment again. Here the torque (is current) is controlled by a PI controller. The output is a voltage. The PMW makes sure this voltage is applied to the motor. But the motor current is feedback to the PI controller! I do not understand this. The voltage on a motor is more or less proportional to the motor speed. So it makes more sense to me to feedback the speed. The voltage will increase or decrease the current because the motor is an inductor. So the voltage gets mathematically integated. How can a PI controller work with this (integrated) feedback? Attached Thumbnails
 Recognitions: Gold Member Science Advisor In your DC motor example, most recent post, ... why can't two integrators be cascaded? just their time constants need to be separated .. and - feeedback is measured current and is compared to desired so error will be forced to zero so far as the control system is concerned, output is measured current and motor's transfer function is just one more term motor coild be moved inside yellow block try thinking of the motor as a first order lag instead of an integration because it really does have an L/R time constant so will not integrate for very long. any help?
 @jim Thanks for you answer. I'm afraid the PID want work stable enough when cascading two integrators. So what you are saying is that you can control the motor current by controller the voltage in a more or less proportional way. And the integrattion will not disturb the PID controller?
 As you see in the example you provided, the PI controller block diagram has the conversion built into it.

 Quote by mechamania I do not understand this. The voltage on a motor is more or less proportional to the motor speed. So it makes more sense to me to feedback the speed. The voltage will increase or decrease the current because the motor is an inductor. So the voltage gets mathematically integated. How can a PI controller work with this (integrated) feedback?
Applied voltage is not directly related to motor speed. It is proportional, but the actual speed is dependent on other factors too - the current/mechanical load.

It is the back-EMF that you need to think about. And the back EMF is the parameter that is dependent on the angular velocity of the rotor. It fights with your applied voltage as an inherent negative feedback, and when the motor is producing higher torque, the back EMF has decreased for the same applied voltage. Your current relationship comes in to play here, as this back-emf reduction causes a larger voltage drop across the windings -> more current through them. The parameters are all related by equations, so it is not magic that you can control the current with the voltage.

Saying the motor is an inductor really does not have much importance with the current/voltage relationship other than the back EMF effect. The inductor aspect is more important for understanding electrical transient behavior of the motor, about just as relevant as the internal resistance of the motor as far as your original question goes.

The answer to your question really boils down to following the units conversions in the block diagram path. Like I said, it is a conversion factor that is built into the closed loop somewhere that translates an applied voltage to the motor's current.