0% found this document useful (0 votes)
4 views31 pages

PI Controller

Chapter 11 focuses on tuning PI controllers, detailing their historical background, design considerations for current and speed controllers, and methods for calculating PI gains. It emphasizes the importance of understanding the effects of Kp and Ki terms on system stability and performance, as well as challenges such as integrator windup. The chapter aims to provide a deterministic approach to designing and tuning PI control loops for various applications.

Uploaded by

019auttpc.eee
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views31 pages

PI Controller

Chapter 11 focuses on tuning PI controllers, detailing their historical background, design considerations for current and speed controllers, and methods for calculating PI gains. It emphasizes the importance of understanding the effects of Kp and Ki terms on system stability and performance, as well as challenges such as integrator windup. The chapter aims to provide a deterministic approach to designing and tuning PI control loops for various applications.

Uploaded by

019auttpc.eee
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 11

SPRUHJ1H – January 2013 – Revised June 2019

Tuning Regulators

Topic ........................................................................................................................... Page

11.1 PI Controllers Introduction ................................................................................ 391


11.2 PI Design for Current Controllers ....................................................................... 393
11.3 PI Design for Speed Controllers ......................................................................... 397
11.4 Calculating PI Gains Based On Stability and Bandwidth ....................................... 399
11.5 Calculating Speed and Current PI Gains Based on Damping Factor ....................... 401
11.6 Considerations When Adding Poles to the Speed Loop ........................................ 406
11.7 Speed PI Controller Considerations: Current Limits, Clamping and Inertia .............. 408
11.8 Considerations When Designing PI Controllers for FOC Systems .......................... 411
11.9 Sampling and Digital Systems Considerations ..................................................... 415

390 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] PI Controllers Introduction

11.1 PI Controllers Introduction


Looking back at some history, this is how the PI controller was invented in the 1920s. An engineer named
Nicolas Minorsky was designing automatic steering systems for the US Navy in the early 1920s by
observing how a helmsman steered a ship under different conditions. According to [Link], he
noticed that the actions of the helmsman could be approximated by a simple amplification of the error
signal under calm conditions, but this simple model was inadequate to describe the helmsman's response
during a steady disturbance like a stiff gale. This finally led to the addition of an integral term to correct for
continuous steady-state errors. Later, the derivative term was added to improve controllability even further.
Continuing with the [Link] narrative, test trials of his automatic steering system based on a PI
controller were carried out on the USS New Mexico. After some adjustments, he was able to control the
angular error to less than two degrees. When the D term was added, the error improved to within one
sixth of a degree, which was better than what most helmsmen could achieve manually. Minorsky
published his findings (also in the early 1920s). We know today that his discovery launched a new era in
the design of control systems.

Figure 11-1. USS New Mexico Around the Time it was Retrofitted with PID Control

A very common question we get in our seminars is, "How do you tune a PI controller?" We typically show
Bode plots or show some simulation data to show that the process is somewhat empirical, and very
subjective to the kind of response for which you are looking.
This section of InstaSPIN User's Guide is put together to help customers design and tune PI control loops
(regardless of whether they are speed loops or current loops) in a much more deterministic way. Granted,
there are still plenty of degrees of freedom depending on what kind of response users are looking for, as
well as an endless litany of subtle variations on the basic PI structure itself. But by following some basic
rules that will be explained later in this document, users should be able to tune a PI loop.
This analysis is limited to loads having only real poles. If the load under consideration has prominent
complex poles resulting from excessive torsional resonance between the motor and load, then the
controller will have to be more sophisticated than a simple PI structure anyway to cancel the resonance
effects. But in most cases, a stiff shaft coupler should tame the torsional resonance to the point where the
use of a standard PI control structure is acceptable. Also, it is assumed that the load has no viscous
damping. In most designs these assumptions are valid. However, if the tuning process described in this
section does not work for a given design, it is likely that complex poles or viscous damping exist
somewhere in the load which is affecting the results.

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 391


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
PI Controllers Introduction [Link]

Figure 11-2 shows a parallel path topology of a PI controller. The error signal is split into two separate
paths: one which is directly amplified and the other is amplified and then integrated. The integrator is
included to drive the steady-state error of the system to zero, since any non-zero steady-state error will
result in a boundless integrator output. These two signal paths are then combined at the output once
again via a simple addition operation.

Figure 11-2. Parallel Path Topology

But how do you set the values for Kp and Ki? This has been the subject for much debate, and it is rather
difficult to intuitively understand the effect that each term has on your motor control system. The Kp term
sets the high frequency gain of the control loop, as shown above. The Ki term sets the low frequency gain,
and theoretically has infinite gain at DC. The frequency which delineates the high frequencies from the low
frequencies is referred to as the "zero" of the controller and corresponds to the inflection point in the
frequency plot.
While the integrator plays a crucial role in the operation of the PI controller, it also brings a set of
challenges with it. For example, let's say that the error in your control loop is zero, which means the
controlled signal is equal to the commanded signal. Now add a small offset to the controlled signal and
watch what happens. Since the error signal is no longer zero, the integrator output will start growing, and
growing in an attempt to null the error signal again.
Now remove the offset and watch what happens. The controlled signal will eventually return to the
commanded value once again, but not right away. The integrator output is still very large, which causes
the controlled signal to wildly overshoot the commanded value while the integrator output is cleared.
During this time, the profile of the "controlled" signal is not controlled at all, and may even result in
damage to your system if not constrained. It is like winding up a spring tightly and then suddenly releasing
it. That is why this effect in PI controllers is called windup. There are many ways to mitigate the windup
effect, but most techniques involve some sort of limiting of the integrator's output. We will discuss this in
more detail later in this section.
Another popular form of the PI controller (and the one we will use for our analysis) is the "series" topology
which is shown in Figure 11-3.

392 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] PI Design for Current Controllers

Figure 11-3. Series Topology

From this diagram, we can see that:


K pseries = K p
Ki
K iseries =
Kp (27)
series series
But in this structure, K p sets the gain for ALL frequencies, and K i directly defines the inflection
point (zero) of the controller in rad/sec. Both forms are pretty much equal in terms of software complexity.
series series
However, many engineers prefer the series form over the parallel form since K p and K i directly
series
correlate to tangible system parameters. It's pretty easy to understand the effect that K p has on the
controller's performance, since it is simply a gain term in your open-loop transfer function. But what is the
system significance of the zero inflection point? This will be discussed next.

11.2 PI Design for Current Controllers


In the previous section, we briefly reviewed the history of the PI controller and presented two forms that
are commonly used today. Regardless of which form you use, the frequency responses look identical, as
shown in Figure 11-4. As can be seen from the graph, the gain of the PI controller has a pronounced
effect on system stability. But it turns out that the inflection point in the graph (the "zero" frequency) also
plays a significant but, perhaps, more subtle role in the performance of the system. To understand this, we
will need to dive into some math to derive the transfer function for the PI controller, and understand how
the controller's "zero" plays a role in the overall system response.

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 393


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
PI Design for Current Controllers [Link]

Figure 11-4. Frequency Response

Using the series form of the PI controller, we can define its "s-domain" transfer function from the error
signal to the controller output as:
æ s ö
K pseries ´ K iseries ç 1+ series ÷
K pseries ´ K iseries ç K
i
÷
PI (s ) = + K pseries = è ø
s s (28)

From this expression, we can clearly see the pole at s = 0, as well as the zero at s = sec. So, K iseries rad /
why is the value of this zero so important? To answer this question, let's drop the PI controller into a
current controller which is regulating the current of a motor, as shown in Figure 11-5.

Figure 11-5. PI Controller in a Current Controller

We will use a first-order approximation of the motor winding to be a simple series circuit containing a
resistor, an inductor, and a back-EMF voltage source. Assuming that the back-EMF voltage is a constant
for now (since it usually changes slowly with respect to the current), we can define the small-signal
transfer function from motor voltage to motor current as:
1
I (s ) R
=
V (s ) 1 + L s
(R ) (29)

394 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] PI Design for Current Controllers
series
If we also assume that the bus voltage and PWM gain scaling are included in the K p term, we can now
define the "loop gain" as the product of the PI controller transfer function and the V-to-I transfer function of
the RL circuit:
æ æ s öö
ç K pseries ´ K iseries ç 1 + ÷ ÷æ 1 ö
series
I (s ) ç è Ki
ç ÷÷
ø ç R ÷
Gloop (s) = PI (s )´ =ç ÷ç
V (s ) ç s L ÷
÷ ç 1+ R s
( )
÷
ç ÷è ø
è ø (30)
To find the total system response (closed-loop gain), we must use the following expression which you
probably remember from your college control systems class:
Gloop (s )
G (s ) = (Assumin g the feedback term H(s) = 1)
1 + Gloop (s ) (31)
Substituting Equation 30 into Equation 31 yields:
æ æ s öö
ç K pseries ´ K iseries ç 1 + ÷÷
series ÷ æ 1 ö
è Ki
ç ç
ø ÷ç R ÷
ç ÷ L
ç s ÷ çè 1 + R s ÷ø
( )
ç ÷
G (s ) = è ø
æ æ s öö
ç K pseries ´ K iseries ç 1 + ÷÷
ç K series ÷ ÷æ 1 ö
ç è i ø ç R
1+ ç ÷ ÷
s L
ç ÷ çè 1 + R s ÷ø
( )
ç ÷
è ø (32)
Notice that the expression is getting bigger and bigger, however with some algebra, we can reduce this
expression to the following:
æ s ö
ç 1 + series ÷
ç K ÷
è i ø
G (s ) =
æ L ö æ R 1 ö
ç ÷ s2 + ç + series ÷s +1
series
ç Kp ´ K iseries ÷ series
ç Kp series
´ Ki Ki ÷
è ø è ø (33)
The denominator is a second order expression in "s" which means there are two poles in the transfer
series series
function. If we are not careful with how we select K p and K i , we can easily end up with complex
poles. Depending on how close those complex poles are to the jω axis, our system could have some
series series
resonant peaks. So let's assume right away that we want to select K p and K i in such a way as to
avoid complex poles. In other words, we can factor the denominator into an expression as follows, where
C and D are real numbers:
æ L ö æ R 1 ö
ç ÷ s2 + ç + ÷ s + 1 = (1 + Cs )(1 + Ds )
ç K pseries ´ K iseries ÷ ç K pseries ´ K iseries K iseries ÷
è ø è ø (34)
If we multiply out the expression on the right side of the equation, and compare the results with the left
side of the equation, we see that in order to obtain real poles, the following conditions must be satisfied:
L
series
= C´D
Kp ´ K iseries (35)
And:

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 395


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
PI Design for Current Controllers [Link]

R 1
+ = C´D
K pseries ´ K iseries K iseries (36)
As a first attempt to solve Equation 35 and Equation 36, let's simply equate the terms on both sides of
Equation 36. In other words:
R 1
= C and =D
K pseries ´ K iseries K iseries (37)
The reason we recommended these substitutions will now become clear. If we replace the denominator of
Equation 33 with its factored equivalent expression as shown in Equation 34, and then make the
substitutions recommended in Equation 37, we get the following:
æ s ö
ç 1 + series ÷
ç K ÷
è i ø
G (s ) =
æ R öæ s ö
ç1 + s ÷ ç 1 + series ÷
ç Kp series series
´ K i
÷ ç K
i
÷
è øè ø (38)
Notice that the "D" substitution results in a pole which cancels out the zero in the closed-loop gain
expression. By choosing C and D correctly, we not only end up with real poles, but we can create a
closed-loop system response that has only one real pole and no zeros. No peaky frequency responses or
resonant conditions, just a simple single-pole low-pass response.
Additionally, by substituting the expressions for C and D recommended in Equation 37 back into
Equation 35, we get the following equality:
R
K iseries = ü
L (39)
series
Keep in mind that K i is the frequency at which the controller zero occurs. So in order to get the
series
response described in Equation 38, all we have to do is to set K i (the controller zero frequency) to be
equal to the pole of the plant.
series series
So, now we know how to set K i . But how do we set K p ? Let's rewrite the closed-loop system
response G(s), making all of the substitutions we have discussed up to now, and see what we get:
1
G (s ) = Þ K pseries = L ´ Bandwidth ü
L
s + 1
K pseries (40)
In summary, there are some simple rules you can use to help you design your PI controller for your
current loop:
K iseries sets the zero of the PI controller. When controlling a plant parameter with only one real pole in its
series
transfer function (e.g., the current in a motor), K i should be set to the value of this pole. Doing so will
result in pole/zero cancellation, and create a closed-loop response that also only has a single real pole. In
other words, very stable response with no resonant peaking.
K pseries sets the bandwidth of the closed-loop system response. As seen by Equation 40, the higher K pseries
is, the higher the current loop bandwidth will be. We will discuss how to select an appropriate bandwidth in
series
a later section. It happens that K p is equal to the inductive impedance for whatever bandwidth
frequency you select.
In the following section we will discuss how to design a cascaded PI speed loop which contains a PI
current controller as the inner loop.

396 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] PI Design for Speed Controllers

11.3 PI Design for Speed Controllers


series series
In the last section we explained how to calculate the P and I coefficients (actually the K p and K i
series
coefficients in a series structure) for a current loop controller for a motor. We saw that K i could be
used to eliminate the zero in the closed-loop system response, resulting in a system having only one real
series
pole (i.e., well behaved and stable). K p sets the bandwidth of the closed-loop system response.
In this section let's back out and take a look at the speed control loop, which contains another PI
controller. Can designing the speed loop be just as simple? Do the coefficient values perform the same
system functions they did with the current controller?
It turns out that closing the speed loop is a little more complicated than closing the current loop. Also, to
properly design the speed loop, we need to know more system parameters than we did for the current
loop. This can be seen in Figure 11-6 which shows all of the components that comprise a cascaded speed
control loop. By "cascaded," we mean a control system that consists of an outer loop with one or more
inner loops. It bears mentioning again that we are only considering the case of a load with a single lumped
sum inertia which is tightly coupled to the motor shaft and no viscous damping.

Figure 11-6. Cascaded Speed Control Loop

Let's start with the current control loop since this is where we left off in our last section. Assuming we
design the current loop as discussed in my previous section, the closed-loop transfer function is:
1
Gcurrent (s ) =
L
series
s +1
Kp (41)
series
Where K p is the error multiplier term in the current regulator's PI structure.
K iseries is not visible to the outside world since it is set to cause pole/zero cancellation within the current
controller's transfer function. To avoid confusing the coefficients of the speed controller with those of the
series series
current controller, we will call the speed controller's coefficients spdK p and spdK i as shown in
series series
Figure 11-6. In the series form of the PI controller, spdK p is the error multiplier term (spdK p ), and
spdK iseries is the integrator multiplier term (spdK iseries). We can use the same equation we did in the last
section to define the transfer function of the speed PI controller:
æ s ö
spdK pseries ´ spdK iseries ç 1 + ÷
spdK pseries ´ spdK iseries ç spdK iseries ÷
PIspeed (s ) = + spdK pseries = è ø
s s (42)
The transfer function from motor current to motor torque will vary as a function of what type of motor you
are using. For a Permanent Magnet Synchronous Motor under Field Oriented Control, the transfer function
between q-axis current and motor torque is:

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 397


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
PI Design for Speed Controllers [Link]

3 P 3
Mtr (s ) = l r = Pl r
2 2 4 (43)
Where:
P = the number of rotor poles
λr = the rotor flux (which is also equal to the back-EMF constant (Ke) in SI units)
For an AC Induction machine, the transfer function between q-axis current and motor torque would be:
3 Lm2
Mtr (s ) = P Id
4 Lr (44)
Where:
P = the number of stator poles
Lm = the magnetizing inductance
Lr = the rotor inductance
Id = the component of current that is lined up with the rotor flux
For now, let's assume we are using a Permanent Magnet Synchronous Motor.
Finally, the load transfer function from motor torque to load speed is:
11
Load (s ) =
Js (45)
Where:
J = the inertia of the motor plus the load
Multiplying all these terms together results in the composite open-loop transfer function:
æ æ s ö öæ
ç spdK pseries ´ spdK iseries ç 1 + ÷ ÷ç
ö
ç ç
è spdK iseries ÷÷
ø ç 1
÷
÷ æ 3 Pl ö æ 1 1 ö
GH(s) = ç ÷ç ç r ÷ç ÷
ç s ÷ ç L s + 1 ÷÷ è 4 øè J s ø
ç ÷ Kiseries
è øè ø
(46)
Let's combine all the motor and load parameters at the end of this equation into a single constant K:
3Plr
K=
4J (47)
Simplifying, we get:
æ s ö
K ´ spsK pseries ´ spdK iseries ç 1 + ÷
ç
è spdK iseries ÷
ø
GH(s) =
æ L ö
s2 ç 1 + series s ÷
ç Kp ÷
è ø (48)
From inspection of Equation 48, we can determine the following characteristics of the speed controller's
open-loop transfer function:
• Two poles at s = 0, resulting in an attenuation rate at low frequencies of 40 dB per decade of
frequency.
K pseries
s=
• An additional pole at L (the current controller's pole)
• A zero at s = spdK iseries

398 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] Calculating PI Gains Based On Stability and Bandwidth

K pseries
s=
In order for stable operation, the pole at L must be higher in frequency than the zero at
series series series
s = spdK i . Other than that, there is an infinite number of combinations of spdK p and spdK i
which could be used to yield different system responses, depending on whether you want higher
bandwidth or better stability. There is a procedure to define a single parameter which is proportional to
series
system stability and inversely proportional to bandwidth, which can be used to set both spdK p and
spdK iseries automatically to yield the maximum phase margin for the selected bandwidth. We will cover the
details of this procedure in the next section.

11.4 Calculating PI Gains Based On Stability and Bandwidth


At the end of last section, we discussed the possibility of using a single parameter that could help tune the
speed PI loop in a motor control system. To develop this parameter, let's review the open-loop transfer
function for the entire speed loop:
æ s ö
K ´ spsK pseries ´ spdK iseries ç 1 + ÷
ç
è spdK iseries ÷
ø
GH(s) =
æ L ö
s2 ç 1 + series s ÷
ç Kp ÷
è ø (49)
Where:
• K is the coefficient that contains several terms related to the motor and load

• spdK pseries and spdK iseries are the PI coefficients for the speed loop
• L is the motor inductance

• K pseries is one of the PI coefficients for the current loop


• s is the Laplace frequency variable
K pseries
s= series
Assuming that the pole at L occurs at a higher frequency than the zero at s = spdK i , and that
the unity gain frequency occurs somewhere in-between these two frequencies, we should end up with a
Bode plot that looks something like Figure 11-7.

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 399


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
Calculating PI Gains Based On Stability and Bandwidth [Link]

Figure 11-7. Bode Plot

The reason the shape of this curve is so important is because the phase shift at the 0 dB frequency
determines the stability of the system. In order to achieve maximum phase margin (phase shift: 180°) for a
given separation of the pole and zero frequencies, the 0 dB frequency should occur exactly half way in-
between these frequencies on a logarithmic scale. In other words,
w0 dB = d ´ wzero (50)
and,
wpole = d ´ w0 dB (51)
Combining Section [Link] and Equation 51 we can establish that:
wpole = d2 ´ wzero (52)
From Equation 49, we see that ωpole and ωzero are already defined in terms of the PI coefficients. Therefore,
K pseries
spdK iseries = ü
d2 L (53)
Where "δ" we will define as the damping factor. The larger δ is, the further apart the zero corner frequency
and the current loop pole will be. And the further apart they are, the phase margin is allowed to peak to a
higher value in-between these frequencies. This improves stability at the expense of speed loop
bandwidth. If δ = 1, then the zero corner frequency and the current loop pole are equal, which results in
pole/zero cancellation and the system will be unstable. Theoretically, any value of δ > 1 is stable since
phase margin > 0. However, values of δ close to 1 result in severely underdamped performance.
We will talk more about δ later, but for now, let's turn our attention towards finding the last remaining
series
coefficient: spdK p . From Section [Link] we see that the open-loop transfer function of the speed
loop from Equation 49 will be unity gain (0 dB) at a frequency equal to the zero inflection point frequency
multiplied by δ. In other words,

400 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] Calculating Speed and Current PI Gains Based on Damping Factor

æ s ö
K ´ spdK pseries ´ spdK iseries ç 1 + ÷
ç
è spdK iseries ÷
ø =1
æ s ö
s2 ç 1 + 2 ÷
series ÷
ç d ´ spdK i
è ø s = j´d´spdK iseries (54)
By performing the indicated substitution for "s" in Equation 54 and solving, we obtain:
d ´ K ´ spdK pseries
=1
æ K pseries ö
d2 ç 2 ÷
ç d ´L ÷
è ø (55)

Finally, we can solve for spdK pseries :


K pseries d ´ spdK iseries
spdK pseries = = ü
L ´ d´K K (56)
At this point, let's step back and try to see the forest for the trees. We have just designed a cascaded
speed controller for a motor which contains two separate PI controllers: one for the inner current loop and
series
one for the outer speed loop. In order to get pole/zero cancellation in the current loop, we chose K i as
follows:
R
K iseries =
L (57)

K pseries sets the bandwidth of the current controller:


K pseries
Bandwidth =
L (58)
Once we have defined the parameters for the inner loop current controller, we select a value for the
damping factor (δ) which allows you to precisely quantify the tradeoff between speed loop stability and
series series
bandwidth. Then it is a simple matter to calculate spdK p and spdK i :
K pseries
spdK iseries =
d2 ´ L (59)
d ´ spdK iseries
spdK pseries =
K (60)
The benefit of this approach is that instead of trying to empirically tune four PI coefficients which have
seemingly little correlation to system performance, you just need to define two meaningful system
parameters: the bandwidth of the current controller and the damping coefficient of the speed loop. Once
these are selected, the four PI coefficients are calculated automatically.
The current controller bandwidth is certainly a meaningful system parameter, but in speed controlled
systems, it is usually the bandwidth of the speed controller that we would like to specify first, and then set
the current controller bandwidth based on that. In the next section, let's take a closer look at the damping
factor, and we will come up with a way to set the current loop bandwidth based on the desired speed loop
bandwidth.

11.5 Calculating Speed and Current PI Gains Based on Damping Factor


So far in this series, we have discussed how to distill the design of a cascaded speed controller from four
PI coefficients down to two "system" parameters. One of those parameters is simply the bandwidth of the
current controller. The other is the damping factor (δ). The damping factor represents the tradeoff between
system stability and system bandwidth in a single number. Keep in mind that we are only considering
loads which contain only torque and inertial components (i.e., no torsional resonance or viscous damping).
Let's move forward by taking a closer look at the damping factor in both the time and frequency domains.

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 401


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
Calculating Speed and Current PI Gains Based on Damping Factor [Link]

Figure 11-8 illustrates the open-loop magnitude and phase response for a system where the current
controller bandwidth is arbitrarily set to 100 Hz. For our purposes, it really doesn't matter what the current
bandwidth is, as it only serves to provide a reference point on the frequency axis. However, the shape of
the curves won't change, regardless of what the current bandwidth is. The damping factor is swept from
1.5 to 70 in 8 discrete steps to show how it affects system response. A value of 1.0 corresponds to the
condition where the open-loop gain intercepts 0 dB right at the frequency of the current controller
bandwidth. This results in pole/zero cancellation at this frequency with a phase margin of zero. It goes
without saying that zero phase margin equals bad things for your system.

Figure 11-8. Speed Controller Open Loop Magnitude and Phase Response as a Function of δ

One of the goals with the damping factor equations is to achieve the maximum stability possible for a
given bandwidth. This is seen on the open-loop phase plots which indicate the phase margin peaks to its
maximum value right at the frequency where the open-loop gain plots cross 0 db. As the stability factor is
increased, you eventually reach a point of diminishing returns as the signal phase shift approaches -90
degrees. However, the gain margin continues to improve at the expense of a much slower system
response.
Figure 11-9 illustrates the closed loop magnitude response of the speed loop, again assuming a current
controller bandwidth of 100 Hz. Just like the open-loop response, the actual current controller bandwidth is
irrelevant in determining the shape of the curves and only serves to associate the curves with a specific
frequency reference point.

402 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] Calculating Speed and Current PI Gains Based on Damping Factor

Figure 11-9. Speed Controller Closed Loop Bandwidth as a Function of δ

The required frequency separation between the -3 dB cutoff point of the speed closed loop response and
the current controller pole is clearly seen along the bottom of the graph for various values of the damping
factor. As the damping factor approaches unity, the complex poles in the speed loop approach the
required frequency sepdamped ringing. This is perhaps better visualized in Figure 11-10, which shows the
normalized step response of the system for various values of the damping factor. Values below 2 are
usually unacceptable due to the large amount of overshoot. At the other end of the scale, values much
above 30 usually unacceptable due to the large amount of overshoot. At the other end of the scale, values
much above 30 usually don't work either because of the extremely long rise and settling times, as seen in
the step response curves. In-between these values is usually your design target window.

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 403


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
Calculating Speed and Current PI Gains Based on Damping Factor [Link]

Figure 11-10. Step Response of Speed Controller as a Function of δ

So what should you do if you picked the lowest value you can tolerate for the damping factor, but you still
aren't satisfied with the system response times? Your best recourse might be to increase the bandwidth of
your current loop. But the problem with this is that it appears to be an iterative approach since you need to
determine the current loop bandwidth first before you can determine what speed loop bandwidth is created
from a given damping factor. However, we can take advantage of the fact that the frequency curves
shown here can be normalized with respect to the current loop bandwidth irrespective of frequency. In
other words, if your motor control system has a form similar to the one discussed in this section,
irrespective of actual parameter values, you will get frequency curves (and transient step curves) that look
like this, with only the frequency scaling (and time scaling) being different. So let's exploit this fact to
develop a procedure which will minimize the iterative nature of the design process and allow us to set the
current loop bandwidth as a function of the speed loop bandwidth:
• Pick the frequency response (-3 dB cutoff frequency) you want for your speed loop (BWs).
• Using the shape of the curves in Figure 11-10, find the lowest value of damping factor that will produce
a satisfactory response for your speed loop. We have found that it is OK to pick a damping factor with
a little more overshoot than you prefer, since integrator clamping will remove most of it anyway. At this
point, the scaling of the frequency and time axes is irrelevant.
• Calculate the required current loop bandwidth to support the design requirements using the following
formula (obtained by curve fit analysis):
K pseries æ -
d
ö
BWc = = BWs ç d + 2.16 ´ e 2.8 - 1.86 ÷ (rad / sec)
L è ø (61)
Where:
• BWc is the current controller bandwidth

• K pseries = one of the current loop PI coefficients


• L = the motor inductance
• BWs is the speed controller bandwidth

404 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] Calculating Speed and Current PI Gains Based on Damping Factor

• δ is the damping factor.


Proceed with calculating the four PI coefficients as discussed previously in this section.
EXAMPLE
An Anaheim Automation 24V permanent magnet synchronous motor has the following characteristics:
• Rs = 0.4 ohms
• Ls = 0.6 mH
• Back-EMF = 0.0054 v-sec/radians (peak voltage phase to neutral, which also equals flux in Webers in
the SI system)
• Inertia = 2E-4 kg-m2
• Rotor poles = 8
The desired speed bandwidth = 800 rad/sec, and we would like a damping factor (δ) of 4. Find the
required current loop bandwidth to support the speed loop bandwidth, and then calculate the four PI
coefficients.
SOLUTION
The required current bandwidth can be found directly from Equation 61:
K pseries æ -
4
ö
BWc = = 800 ç 4 + 2.16 ´ e 2.8 - 1.86 ÷ = 2126rad / sec
0.6E - 3 è ø (62)
From Equation 62, we find
K pseries = 1.28 (63)
Recall that
R
K iseries = = 667
L (64)
Also recall that
K pseries
spdK iseries = = 133
d2 ´ L (65)
Finally, recall that
3Plr
K= = 162
4J (66)
and,
K pseries
spdK pseries = = 3.29
L ´ d´K (67)
The simulated speed transient step response for this example is shown in Figure 11-11 where the time
axis is now scaled appropriately for this design example.

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 405


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
Considerations When Adding Poles to the Speed Loop [Link]

Figure 11-11. Simulated Step Response of Speed Controller Design from the Above Example

Our analysis so far has assumed that the only poles in the speed loop are the two at s = 0, and the one
associated with the current controller. But what if other poles exist? For example, the speed feedback
signal in many systems is often processed by a low-pass filter. So how does this affect our tuning
procedure? This will be covered in the following section.

11.6 Considerations When Adding Poles to the Speed Loop


At the end of last section, we presented a problem that could potentially derail this whole discussion.
Throughout the PI tuning sections, we have been discussing a way to find the values for the PI
coefficients in a theoretical system where the speed loop contains two poles at "s" equals zero, and a third
pole from the current controller. Usually there are one or more additional poles in the transfer function. For
example, a very common deviation from this utopian situation is when the speed feedback signal requires
filtering, as shown in Figure 11-12.

Figure 11-12. Speed Controller with Filtered Speed Feedback

406 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] Considerations When Adding Poles to the Speed Loop

Creating a good quality high-bandwidth speed signal without spending too much design time and without
adding too much system cost can be a real challenge. Techniques have been developed to glean
information from the encoder edge transitions, and also using observer technology. But still, the speed
signal is usually filtered. This alters the open-loop transfer function of the speed loop to the form shown in
Figure 12-9.
æ s ö
K ´ spdK pseries ´ spdK iseries ç 1 + ÷
ç
è spdK iseries ÷
ø
GH(s) =
æ L ö æ s ö
s2 ç 1 + series s ÷ ´ ç 1 + ÷
ç Kp ÷ çè K spd _ filter ÷ø
è ø (68)
Where:
• K is a coefficient that contains several terms related to the motor and load

• spdK pseries and spdK iseries are the PI coefficients for the speed loop
• L is the motor inductance

• K pseries is one of the PI coefficients for the current loop


• Kspd_filter is the pole of the speed feedback filter
• s is the Laplace frequency variable.
So what does this do to the tuning procedure? There are several dimensions to this problem, as well as
possible solutions. The selected damping factor and the relative location of the poles all contribute to
these challenges. So let's target these challenges one at a time.
The procedure outlined in the last section assumes that a suitable speed bandwidth and damping factor
are chosen based on application requirements, and then using the equation presented in step 3, we can
calculate the required current controller bandwidth to satisfy these design requirements. But it turns out
that the pole calculated in step 3 defines the minimum frequency of any pole which occurs above the unity
series
gain frequency. Armed with this knowledge, we can define a more general expression for spdK i :
p
spdK iseries = 2
d (69)
Where:
p = the lowest value pole above the 0 dB frequency in the speed open-loop frequency response.
series
The value of p could be set by the current controller, the speed filter, or something else. Since spdK p
series
is referenced to spdK i , then its value will also be potentially affected:
d ´ spdK iseries
spdK pseries =
K (70)
If you can't meet the required frequency separation between the desired closed-loop speed bandwidth and
p as dictated by your chosen value for δ, then something has got to give. It's like a water balloon—you can
squeeze one part of the balloon, but it will pop out somewhere else. In this case, you can have your
bandwidth at the expense of the damping factor, or vice versa.
The problem is exacerbated when the current controller pole and the speed filter pole are within a half
decade of each other and δ is less than 3. With both poles so close to the 0 dB frequency and fighting
together to bring down the phase margin, you will get a more underdamped response than you might
otherwise expect. For example, Figure 11-13 shows the step response of a system where we used a
damping factor of 2.5 to calculate the PI coefficients as described in the last section. The green curve
assumes there is no filtering of the speed signal. The red curve shows the addition of a speed feedback
filter where the value of the filter's pole equals the current controller's pole. The system is still stable, but
the damping is much less than expected for a δ value of 2.5. At this point, we have two options, either
increase the damping factor (and consequently lower the speed loop frequency response), or move one of
the poles to a higher frequency. The cyan curve shows the first option where we increase the damping
factor from 2.5 to 3.8 in order to bring the overshoot down to the original expected value. Unfortunately

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 407


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
Speed PI Controller Considerations: Current Limits, Clamping and Inertia [Link]

this reduces the bandwidth as indicated by the increased transient time. The yellow curve shows the latter
option where we increase the value of one of the poles by a factor of 3 (about half a decade). In this case,
the transient time is relatively unaffected, but the damping is still not as good as the green waveform. You
can continue to increase the pole value, and at about one decade of separation you get a response that
looks pretty close to the green waveform again. But in many cases, moving one of the poles this
drastically has other negative effects on your system.

Figure 11-13. Step Response of a System with Variable Damping and Pole Placement

Up to now, we have only dealt with "small signal" conditions (i.e., linear operation with no saturation
effects). But in the real world, step transient responses almost always involve saturation of the system's
voltage or current levels, which tends to lengthen the response times. When this happens, you can
increase the PI gains all you want, but it won't speed up the response. In fact, it will usually just make the
overshoot worse, since the integrator is acting on a gained-up error signal, which it will just have to dump
eventually. So how do we deal with this problem? Are we doomed to simply using low integrator gains? It
turns out that there is another solution which doesn't involve changing your integrator gains, which we will
cover in the next section.

11.7 Speed PI Controller Considerations: Current Limits, Clamping and Inertia


Up to now, we have only discussed the tuning problem in the context of a linear system. This is because
under steady-state conditions when the system settles out, you will most likely find that you are operating
in the linear region, and the AC signal content will be very small. Therefore, performing a small-signal
(linear) analysis will tell you how stable your system will be when it is not operating in saturation. But in
most real-life scenarios, the system will saturate because of limits on your voltage and/or current,
especially under large transient conditions. This saturation effect can play an important role in the PI
controller; especially the integrator. Since the maximum torque the motor can produce is limited by your
current limit, the acceleration of the system is also limited. But the integrator doesn't know this, and it
thinks it can make the motor speed up faster by increasing its output. This increased integrator output
can't help the situation since the system is already saturated. All it does is create a very large output that
will cause the system to overshoot when it does come out of saturation. For this reason, most PI integrator
outputs are clamped to keep them from continuing to integrate needlessly when the system is saturated.

408 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] Speed PI Controller Considerations: Current Limits, Clamping and Inertia

A simple static clamping scheme is illustrated in Figure 11-14. The most common scenario is to set the
clamp values equal to the PI output limit values. For example, the output limit of a PI controller that
regulates speed is usually what sets your current limit value since the speed PI output is the reference
input signal for the current PI controller. However, there is nothing that says that the integrator limit must
equal the PI output limit, and many designs use different clamp values based on the specific application.

Figure 11-14. PI Controller with Static Integrator Clamping

Figure 11-15 shows a dynamic clamping scheme which provides superior performance over the static
scheme. The thinking behind the design of this scheme is based on the rationale that if the system is
already saturated by the P gain output, then why continue integrating? Only during conditions where
changes in the integrator output would result in changes in the PI controller output is the integrator allowed
to continue to integrate error unconstrained.

Figure 11-15. PI Controller with Dynamic Integrator Clamping

The effectiveness of integrator clamping can be seen by the simulated curves in Figure 11-16. Let's
stimulate the system we designed in Chapter 5 with a commanded speed step from zero to a target speed
of 1500 RPM. Shown are the effects of system overshoot under the conditions of no clamping, static
clamping where the integrator clamp values equal the output clamp values and finally, dynamic clamping.
As you can see, no integrator clamping at all is unacceptable as it results in extremely high overshoot
which triggers further system saturation and oscillation. Static integrator clamping dramatically improves
this situation. However, dynamic clamping improves performance even further, resulting in a 6 times
improvement in the overshoot peak value compared to static clamping in this example.

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 409


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
Speed PI Controller Considerations: Current Limits, Clamping and Inertia [Link]

Figure 11-16. Example Comparison of Integrator Clamping Techniques

At this point, let's double-back and talk about a very important part of this whole discussion. Everything we
have talked about in these seven sections is not very significant without knowing one critical piece of the
system which is the inertia. Without this knowledge, there is no definitive way of stabilizing the speed loop.
In many cases, you can calculate the inertia by knowing the form factor and mass distribution of your
rotating load. If a gearhead is present on the motor shaft with a big enough gear ratio, the load inertia can
often be ignored since transferred inertia is inversely proportional to the square of the turns ratio, and just
deal with the motor inertia which is listed on most motor data sheets. If neither of these options is valid,
there are several techniques used to measure inertia which usually involve some type of controlled
acceleration, deceleration, or both. However, it is not common to see techniques which also take into
consideration static torque loading on the motor shaft ("static," loads in this context mean loads which
don't change as a function of time, such as friction or an elevator load). The following is a proposed (but at
the time of this writing, untested) technique which should yield a better inertia estimate than the
techniques mentioned above:
1. Design the current controller using techniques discussed in the PI tuning sections.
2. Set the PI coefficients for the speed loop to conservative values that will just allow spinning the motor
up to speed (i.e., having sluggish dynamic response should not be a concern at this point).
3. Spin the motor up to a low speed and allow it to settle (so that inertia torque equals zero). Then take a
reading of the average motor torque (Figure 11-17).
4. Repeat step 3 at successively higher speeds, and generate a graph of average torque readings as a
function of speed (Graph 1). Record the average current required for the highest speed setting. Then
turn off the motor and allow it to stop.
5. Disable the speed loop and using current mode only, apply about 1.2x to 1.5x the current from step 4
to the motor. As the speed hits each speed for which a torque value was recorded in step 4, record the
torque again (Graph 2), and also take a time stamp.
6. Subtract graph 1 from graph 2 (this should be the acceleration torque only) (Graph 3).
7. For each point in graph 3, calculate the delta speed and delta time between the points before and after

410 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] Considerations When Designing PI Controllers for FOC Systems

the target point. Divide delta speed by delta time to get the local acceleration value for that point.
8. For each torque value in graph 3, divide it by the local acceleration for that point from step 7, to create
a graph of inertia (J) as a function of speed.
9. Average the inertia values at different speeds to obtain a single estimate for system inertia.
This process can be done a priori on a bench dynamometer test, or, if there is a way to measure torque in
the control algorithm such as the torque output of InstaSPIN-FOC, this can be done as part of the
commissioning process of the motor in its target application.
Up to now, we have only discussed PI tuning in generic terms which are independent of the control
topology. In the next section, we will focus on some of the subtle points to consider when designing PI
controllers for use in a Field-Oriented Control (FOC) system.

Figure 11-17. Average Motor Torque Readings

11.8 Considerations When Designing PI Controllers for FOC Systems


Let's see how the different PI tuning topics we have discussed so far apply to Field-Oriented Control
(FOC) systems. Figure 11-18 shows a typical field oriented system which utilizes three PI controllers: two
for controlling the quadrature components of current, and one for controlling the speed.

Figure 11-18. Typical FOC Speed Control of a PMSM

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 411


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
Considerations When Designing PI Controllers for FOC Systems [Link]

The design of the speed controller doesn't change much in a field oriented system compared to other
control algorithms. Just make sure to use the q-axis current controller values when calculating the
coefficients for the speed controller. But there a subtle differences which affect how the current controllers
should be designed, which are covered next.

11.8.1 FOC Differences Between Motor Types


The motor's equivalent RL circuit that is seen by the controller (which determines the PI coefficients) will
vary depending on the motor type. For BLDC and Permanent Magnet Synchronous Motors (PMSMs), R is
simply the stator resistance, and L is the stator inductance. But with AC Induction Motors (ACIMs), this is
not the case. The equivalent inductance value that is needed to use for both axes is not the stator
inductance value, but rather the "series" inductance (or sometimes called the "leakage" inductance) which
is defined as follows:
æ L 2 ö
L = Ls ç 1 - m ÷ = Ls ´ s
ç L sLr ÷
è ø (71)
Where:
• L = the equivalent series inductance
• Ls = the stator inductance
• Lm = the magnetizing inductance
• Lr = the rotor inductance
• σ = the "leakage factor" of the induction motor
Also, the resistor value seen by the current controllers for an ACIM will be different between the d and q
axes. For the d-axis controller, the equivalent resistance is simply the stator resistance Rs. However, for
the q-axis, the equivalent resistance is the sum of the stator resistance plus the rotor resistance (Rs + Rr).
series series
If these subtleties are not taken into consideration when calculating K p and K i , you could end up
with a PI controller that is incompatible with your motor, resulting in less than optimal control.

11.8.2 Coupling Between Q-Axis and D-Axis


It turns out that the control of the d-axis and q-axis currents are not independent from one another. Within
the motor, the q-axis current has an effect on the d-axis current and vice-versa. This is substantiated by
the differential equations below for a PMSM.
id (R + DL s ) = Vd + wL siq (72)
iq (R + DL s ) = Vq - w (L sid + K e ) (73)
Where:
• R = the stator resistance
• Ls = the stator inductance
• D = the differential operator
• ω = the electrical frequency
• Ke = the Back EMF constant
From Equation 72 we see that the d-axis current is not only affected by the output voltage of the d-axis
current regulator (Vd), but also a voltage which is a function of iq. From Equation 73, Vq is also competing
with the voltage "ω(Ls id + Ke)" for control of the iq level. For both regulators, this cross-coupling effect
manifests itself as an unwanted disturbance which is most prominent during transient conditions at high
speeds. To correct for this situation, feed-forward decoupling should be applied to each axis which exactly
cancels these competing voltage terms. This correction results in each regulator acting on the equivalent
of a simple RL circuit, just like we have with a DC motor. The result is the regulator topology shown in
Figure 11-19. To judge the effectiveness of this technique, consider the simulation results of Figure 11-20
which show a step response in Q-axis current and how it affect the d-axis current, with and without
decoupling compensation.

412 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] Considerations When Designing PI Controllers for FOC Systems

Figure 11-19. Decoupled PI Controllers for a PMSM

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 413


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
Considerations When Designing PI Controllers for FOC Systems [Link]

Figure 11-20. Simulated Effectiveness of Current Regulator Decoupling

For AC Induction Motors, the correction becomes a little more complicated. The differential equations
defining AC induction motor operation are shown below:
L
id (Rs + DL s s ) = Vd + wL s s iq - m Dlrd
Lr (74)
L
iq (Rs + DL s s ) = Vq - wL s s id - w m lrd
Lr (75)
Where:
• Rs = the stator resistance
• Ls = the stator inductance
• σ = the leakage factor defined in Equation 71
• D is the differential operator
• ω = the electrical frequency
• Lm = the magnetizing inductance
• Lr = the rotor inductance
• λrd = the d-axis rotor flux
Similar to the situation with a PMSM machine, we see that there are other voltages besides Vd and Vq
competing for control of id and iq respectively. As a result, compensation voltages are added to Vd and Vq
which nullify these other voltage terms. This results in each axis acting on the equivalent of a simple RL
circuit, again just like we have with a DC motor. But with an ACIM, please remember that the inductance
series series
value used for calculating K p and K i is the stator inductance multiplied by the leakage factor σ, as
indicated by Equation 71. The compensation block used to provide correction voltages to the outputs of
the Id and Iq regulators is shown in Figure 11-21.

414 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] Sampling and Digital Systems Considerations

ω
Lm / Lr Vd compensation
+
Rr Σ
Lm -
Lr
id
+

-
Σ ∫ Ls −
Lm 2
Lr
iq

r / LR
r Lm / Lr Vq compensation
+
Σ
+
2
L
Ls − m
Lr

Figure 11-21. Compensation Block Used for Axis Decoupling with ACIMs

11.9 Sampling and Digital Systems Considerations


Throughout the PI tuning sections we have discussed a practical and efficient way to tune the PI
controllers in a cascaded speed loop by simply specifying the desired bandwidth of the speed loop, and a
factor which determines the desired damping of the system. From these two parameters, plus a
rudimentary knowledge of some of the motor and load parameters, the PI coefficients for the speed loop
and the inner current loop can be calculated. But nowhere have we discussed what limits are imposed
upon the system, especially when dealing with a digital system. Obviously, to get a stiffer response, we
would like higher gains, which also translate into higher bandwidth. But how high can we go?
To answer this question, take a look at Figure 11-22, which shows a high level view of a digital FOC
based Variable Frequency Drive (VFD). To simplify the discussion, we will assume that the entire control
loop is clocked by a common sampling signal, although this limitation is not imposed on real-world
applications. In many cases, the speed loop is clocked at a much lower frequency than the current loop,
since the frequencies associated with the speed loop are typically much lower.

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 415


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
Sampling and Digital Systems Considerations [Link]

Figure 11-22. Digital Field-Oriented Control System for a PMSM

In an analog system, any change in the motor feedback signals immediately starts having an effect on the
output control voltages. But with the digital control system of Figure 11-22, the motor signals are sampled
via the ADC at the beginning of the PWM cycle, the control calculations are performed, and the resulting
control voltages are deposited into double-buffered PWM registers. These values sit unused in the PWM
module until they are clocked to the PWM output at the start of the next PWM cycle. From a system
modeling perspective, this looks like a sample-and-hold function with a sampling frequency equal to the
PWM update rate frequency. The fixed time delay from the sample-and-hold shows up as a lagging phase
angle which gets progressively worse at higher frequencies. Figure 11-23 shows a normalized frequency
plot for a sample-and-hold function, where the sampling frequency is assumed to be 1. The phase plot is
the most important graph, as it shows that the phase delay from the sample-and-hold can reach down into
frequencies much lower than the sampling frequency. For example, even at one tenth the sampling
frequency, the S&H is still affecting a phase shift of -18 degrees.

416 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] Sampling and Digital Systems Considerations

Figure 11-23. Magnitude and Phase Plots for a Sample-and-Hold

Since the current controller processes higher bandwidth signals than the speed loop, it is usually the
current loop that suffers most by the S&H effect of the PWM module. Since the S&H is in series with the
signal path for the current loop, its magnitude and phase contributions add directly to the open-loop
response for the current controller. If we rewrite the equation for the open loop response of the current
controller (assuming we have already made the substitutions recommended in the PI tuning sections), we
end up with Equation 76.
I (s ) æ BWc ö
Gloop (s) = PI (s )´ =ç ÷
V (s ) è s ø (76)
Where:
BWc is the chosen closed-loop bandwidth for the current controller.
The 0 dB frequency obviously occurs when s = BWc. The single pole at s = 0 implies that the 0 dB
frequency will have a 90 degree phase margin. While there is no magic ratio that exists, it is usually
preferred to use the rule of thumb that the sampling frequency should be at least 10 times the bandwidth
(BWc) of the current controller. This ensures that the impact of the S&H's phase delay will only subtract 18
degrees from the phase margin of the current controller, resulting in a very stable 72 degree margin. You
can obviously have a higher sampling frequency if desired, but this typically comes at the expense of a
more expensive processor with higher MIPS.
Finally, let's look at the other end of the frequency range. At low frequencies, viscous damping may affect
your speed loop response times by changing the phase margin at the 0 dB frequency. Recall from
Section 11.3, the following transfer function between motor torque and load speed was established:
w (s ) 11
=
T (s ) Js (77)

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 417


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
Sampling and Digital Systems Considerations [Link]

However, when viscous damping is present, it uses part of the motor's torque to do work to move fluid.
Since viscous torque is directly proportional to the speed of the load, we can rewrite Equation 77 to be:
w (s ) 1 1
= =
T (s ) Js + k v æ J ö
kv ç s + 1÷
è kv ø (78)
Where:
kv is the viscous damping factor.
As you can see from Equation 78, adding the viscous damping term moves the pole that was at s = 0 to s
= kv/J. Figure 11-24 shows how the addition of viscous damping changes the load's Bode plot.

Figure 11-24. Effect of Viscous Damping (kv) on the Load Bode Plot

From Figure 11-24, we see that as viscous damping increases from zero, low frequency gain plateaus to a
value of 1/kv. The net effect on the phase plot is to add more phase margin at lower frequencies, since
the phase lag of a load with viscous damping will always be less than a load with inertia only. As a result,
stability should actually improve for non-zero values of kv. However, the response time may take a hit,
depending on where the speed open-loop 0 dB frequency is with respect to the pole frequencies shown in
Figure 11-24. So if your system response is sluggish and the motor doesn't seem to put out as much
torque as it is rated for, you could have excessive viscous damping in your system.
Before closing out this series of PI Tuning sections, there is one more topic to be discussed. In many
cases an engineer correctly calculates PI coefficients. After using those coefficients in their code, the
motor spins out of control, or sit there and does nothing. So what happened? It is most likely the fault of
one of the following situations:

418 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
[Link] Sampling and Digital Systems Considerations

11.9.1 Sampling Period Considerations in the Integral Gain


It was forgotten to take into consideration the sampling frequency effect on the I gain term. Figure 11-25
shows how to implement a typical integrator for a PI controller. To scale the output to match what an
analog integrator would provide, we must multiply the signal by the sampling period "T". In order to avoid
two separate multiply operations, most code examples simply lump T together with the I gain term. If T is
not accounted for, the integrator gain will be much larger than you anticipated.

Figure 11-25. Typical Implementation of a Digital Integrator

11.9.2 Number Format Considerations


Up until now we have assumed there are no limitations on the number format itself. If a floating-point
processor is used, then there is no need to worry about the fractional component of the PI terms. But most
motor control applications are implemented on fixed-point machines for cost reasons. The good news is
that TI has developed a linkable library which is in ROM of most C2000 processors which solves this
problem. It is called the "IQ Math" library which stands for "Integer Quotient". This allows the user to
handle floating point values with ease on a fixed-point machine without suffering from the performance hit
you typically get with a full floating-point support device. IQ math creates a new variable type in the code
which is designated by an "IQ" followed by a number. For example, say you have a 32 bit variable which
is typed as an "IQ24" variable type. This means that any variable of this type is assumed to have a 24-bit
fractional component, and an 8-bit integer part. But what occasionally happens is that someone copies TI
code into their design without realizing that the coefficients are represented in IQ format. For example, if
the I-gain was calculated to be 10,000 (0x00002710 in IQ0 format), but it is not realized that the code
assumed the variable to be in IQ24 format, you will end up with an integrator gain of 0.596E-3 instead of
10,000. The two values are obviously very different. If the same mistake is made for all of the PI
coefficients, the motor will most likely just sit there and do nothing since all the gains are way too low. So,
it is advised to make sure that the numerical format your coefficients are in is well known.

SPRUHJ1H – January 2013 – Revised June 2019 Tuning Regulators 419


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated
Sampling and Digital Systems Considerations [Link]

11.9.3 PI Coefficients Scaling Considerations


Finally, the scaling of the PI coefficients throughout this series of PI Tuning sections has been done
assuming we want to represent real system values throughout the signal chain. For example, the output of
the speed PI controller equals the actual input reference current in amperes for the current controller. The
output of the current controller equals the actual voltage applied to the motor windings. But in many
designs, the PI controller outputs are normalized to per unit scaling where a value of 1 represents the
maximum value possible, and a value of -1 represents the minimum value possible. For example, a
current regulator's output might be scaled in such a way that 1 corresponds to 100% PWM, and -1
corresponds to 0% PWM. In these cases, it is required to know the exact scale factor between the PI
output and the actual system parameter you are controlling so that you can adjust the PI coefficients
accordingly.

420 Tuning Regulators SPRUHJ1H – January 2013 – Revised June 2019


Submit Documentation Feedback
Copyright © 2013–2019, Texas Instruments Incorporated

You might also like