Teaching Your PI Controller to Behave (Part IV)


Dave Wilson, Motion Products Evangelist, Texas Instruments

 

At the end of my last blog, we discussed the possibility of creating a single parameter that could automatically tune the PI coefficients for a velocity loop used in a motor speed control system.  To develop such a parameter, let’s review the open-loop transfer function for the entire velocity loop:

                                             Equ. 1

where      K is a coefficient that contains several terms related to the motor and load

                Kc and Kd are the PI coefficients for the velocity loop

                L is the motor inductance

                Ka is one of the PI coefficients for the current loop

                t is the time constant of the velocity feedback filter

                s is the Laplace frequency variable

Assuming that the zero dB frequency occurs somewhere between the zero at s = Kd and the two nonzero poles in the denominator of the expression, we should end up with a Bode plot that looks something like this:

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 general, in order to get a phase shift at 0 dB that leads to good stability, the magnitude response should cross 0 dB at a rate no steeper than -20 dB per decade.

As you can see from equation 1, we must solve for three unknowns (Ka, Kc, and Kd) which are affected by multiple system parameters.  But instead of wading through pages and pages of esoteric equations, it’s time to make another simplification.  Let’s assume that there is only one pole higher than the zero-dB frequency instead of two.  This assumption could mean that you don’t have a velocity filter in your system, OR that the velocity filter’s pole is way higher than the current controller’s pole, OR that the current controller’s pole is way higher than the velocity filter’s pole.  For most systems, it is plausible to assume the latter scenario.  So if we eliminate the effect of the current controller pole, we can rewrite the velocity open-loop transfer function as shown below:

                                                  Equ. 2

For now, let’s assume that the delta in frequency between the pole 1/t and the zero Kd is fixed.  In order to achieve maximum phase margin (phase shift + 180o), the unity gain frequency should occur exactly half way in-between these two frequencies on a logarithmic scale.  Translating from dB to a normal gain scale, this means the following is true:

                                                              Equ. 3

and,

                                                                 Equ. 4

Combining Equ. 3 and Equ.4 we can establish that:

                                                                              Equ. 5

Solving for Kd,

                                                                                 Equ. 6

Where “d ”we will define as the "damping factor."  If d is increased, it forces the zero corner frequency (Kd) and the velocity filter pole (1/t) to be further apart.  And the further apart they are, the phase margin is allowed to peak to a higher value in-between these frequencies.  This improves stability but unfortunately reduces system bandwidth.  If d = 1, then the zero corner frequency and the velocity filter pole are right on top of each other, resulting in pole/zero cancellation.  In this case the system will be unstable.  Theoretically, any value of d > 1 is stable since phase margin > 0.  However, values of d close to 1 are usually not practical as they result in severely underdamped performance.

I will talk more about d later.  But for now, let’s turn our attention towards finding Kc.  From Equ. 3 we see that the open-loop transfer function of the speed loop will be unity gain at a frequency equal to the zero frequency (Kd) multiplied by d.  In other words,

                                         Equ. 7

By performing the indicated substitution for “s” in Equ. 7, we obtain:

                                                         Equ. 8

We can see that the expression within the magnitude brackets is a scalar term multiplied by a vector term.  So we can pull the absolute value of the scalar term out of the brackets, resulting in the following expression: 

                                                          Equ. 9

It can be shown that the magnitude of the vector inside of the magnitude brackets is simply equal to d.  Performing this substitution and simplifying leads to the following equality:

                                                                                   Equ. 10

Finally, we can solve for Kc:

                                                             Equ. 11

 

 

 

At this point, let’s step back and try to see the forest for the trees.  We have just designed a cascaded velocity controller for a motor which contains two separate PI controllers: one for the inner current loop and one for the outer velocity loop.  In order to get pole/zero cancellation in the current loop, we chose Kb as follows:

                                                                                        Equ. 12

Next, we select a value for the damping factor (d) which allows us to precisely quantify the tradeoff between velocity loop stability and bandwidth.  Then it’s a simple matter to calculate Kd and Kc:

                                                                                Equ. 6

                                                                 Equ. 11

All that remains is the selection of Ka (the current controller bandwidth), which I will address in a later blog.  The benefit of this design approach is that instead of trying to empirically tune four PI coefficients which have seemingly little correlation to system performance, all you need to do is select what damping factor you want for the velocity loop.

In my next blog, let’s take a harder look at the damping factor and how it affects the performance of the velocity loop.  Until then…

 

Keep Those Motors Spinning,

  

  • Your explanation is almost perfect. I enjoyed your prominent technical guide.

  • Thanks Joseph.  I consider this particular blog to be the heart of the entire series, and perhaps the most difficult one to understand due to the math associated with this technique.  The fact that you followed it so well is a testimony to your technical prowess.

    Best wishes for success of your own motor control projects!

    -Dave

  • detailed & accurate explanation

  • i liked your explanation of shape of the curve and the slopes to determine system stability, in particularly "he magnitude response should cross 0 dB at a rate no steeper than -20 dB per decade."  that tid-bit was new to me.  

  • Hello High Hopes,

    Ha!  I suspect the reason this may be new to you is because it's a very old technique.  With all of the new-fangled computer analysis techniques available today, I doubt if they really emphasize the Bode Plot stability analysis technique anymore in control systems courses.

    Bode Plots were developed as a graphical way to estimate system stability using semilog graph paper.  My old file cabinets are full of them!  It assumes that you are dealing with real poles and zeros that are reasonably well distributed along the damping axis (ie, no torsional resonances or other effects which would cause complex poles).  Although it is the PHASE plot that really determines stability at the 0-dB frequency, there is a correlation between the phase plot and the gain plot.  Whenever you encounter a pole, it causes a phase shift of -45 degrees/decade starting one decade before the pole frequency and ending one decade above the pole frequency.  It also causes a -20dB/decade rolloff on the gain plot which starts at the pole frequency and continues for all higher frequencies.  A "zero" has the opposite effect of creating a phase shift of PLUS 45 degrees/decade, and a 20dB/decade INCREASE on the gain plot.

    If your gain plot crosses 0dB at -20dB/decade, it means that the number of lower frequency poles minus the number of lower frequency zeros equals 1.  Translating this to the phase plot (assuming no other  poles or zeros within +/- 1 decade), it means the phase shift will be -90 degrees (stable).  However, if the gain plot is falling at -40 dB/decade under the same assumptions, it means the phase shift will be -180 degrees (unstable).  Of course, if there are other poles or zeros within a +/- 1 decade vicinity of 0dB, you have to hedge your guess of the true phase shift at 0dB based on how close they are.  Older control systems engineers were really good at doing this.  But with the advent of the modern digital computer, most engineers today just run an actual frequency plot to determine the exact gain and phase plots.

    I'm glad to see you are progressing through my series!  Please let me know if you have any other questions.  :-)

    -Dave

  • Thank You very much.Could you say , Why  unit_factor = damping factor  x Kd

  • Hello Erdi,

    I assume you are referring to equation 3 above.   If you look at both equations 3 and 4 together, you will see that I am requiring that the ratio of the 0 dB frequency to the Kd frequency be exactly the same as the ratio of the velocity filter pole frequency to the 0 dB frequency.  I call this ratio "the damping factor."  When these two ratios are the same, the phase plot (not shown) will peak at the 0 dB frequency.  Since the phase margin is determined at the 0 dB frequency, this means that the phase margin will be at its optimum value for a given value of damping factor.

    When you plot the frequencies on a logarithmic scale, you will discover that the linear distance between the Kd frequency and the 0 dB frequency will be exactly the same as the linear distance between the 0 dB frequency and the velocity filter pole frequency, as shown in the above Bode plot.

    Hope that helps...

    -Dave

  • Hello Dave,

             Can you kindly explain that how did you go from http://url.cn/YfmPzr to http://url.cn/XPvSrt.

    If we just look at the expression of  current loop that is (1+ ls/Ka). How did you change this to (1 + s/(delta_sqaured*Kd). According to the previous posts Ka = L * Current Loop Bandwidth. If I put the Ka into  (1+ ls/Ka), I get (1 + s/bandwidth). So how did you deduce delta_squared*Kd from bandwidth. Can you explain?

    Thanks,

  • Hi Fahad Raza,

    I think you missed a critical assumption in the equation derivation.  Quoting from the text above:

    ...But instead of wading through pages and pages of esoteric equations, it’s time to make another simplification.  Let’s assume that there is only one pole higher than the zero-dB frequency instead of two.  ...So we eliminate the effect of the current controller pole.

    This is a reasonable assumption in most cases since you want your current controller to have much higher bandwidth than the velocity loop anyway.  This makes the current controller's closed-loop gain appear to be unity to the velocity loop.  So the expression for the current loop gain drops out of the expression altogether.

    Hope that helps...-Dave

  • Hello Dave,

      I have a question related on Load Inertia (the Inertia seen by motor, but from load contribution).

    What should I do in the case where: motor inertia is 100 e-3 [Kg*m^2]  and  load inertia is 7 [Kg*m^2] ?  The system looks nice for speed response but not the same for torque response where I see some oscillations.

    I read that I have to use a gearbox for inertia reduction... To reconsider the all control, something like a tuning for PI coefficients, can be a solution, or only the gearbox?

     Thank you in advance,

                          Aly

  • Hello Aly, thanks for your question.

    When designing your tuning algorithm, it theoretically doesn't matter whether the inertia is part of the load or part of the motor.  (Notice I said "theoretically".)  All of the equations in this series assume that the entire load (motor + load) acts as a "rigid body".  If this is true, stable operation can be achieved by simply adjusting the tuning coefficients to their proper values. Therefore, the control algorithm is only concerned with the TOTAL value of inertia.  As this inertia is increased, it moves the mechanical pole of the system to a lower value, which means you must commensurately lower the bandwidth of the control algorithm to achieve stability.  This is done by reducing the value of Kc in most cases.  Again, you want to achieve a good phase margin in your system for good stability.

    But let's say you have already adjusted Kc appropriately, your frequency plots look good, but it is still oscillating.  I would next turn my attention to HOW your load is coupled to your motor shaft.   If your load coupling is not rigid enough, it can flex under high torque and high inertia conditions, which inserts a complex pole pair in your open-loop transfer function.  If these poles are anywhere near the 0-dB point, they can really screw up your phase margin and cause oscillation.  You either need a stiffer coupler,  or you need to build a compensation network in your controller.

    Another potential source of oscillation which is found in geared systems is backlash.  This can really be a problem if you design a position control system and you put the feedback sensor on the load side of the gears.  In many cases, designers will choose to use TWO feedback sensors.  They close the position loop with the load position sensor, but they close the velocity loop either with sensorless techniques, or with a velocity sensor mounted directly on the motor shaft.  This removes any effects of gear backlash from the velocity loop.  If you must use gears, make sure to use anti-backlash gears.  These are special gears which contain springs that must be preloaded during the assembly process.  For tuning purposes, please remember that the load inertia is reflected back to the motor as a function of the gear-ratio squared.

    Good luck finding your oscillation.  If you have any other questions, please let me know.  If you discover the source of your oscillation, I'm sure that our readers would benefit from your shared wisdom.

    Best Regards,

    Dave

  • Hello Dave,

    Congratulations for your blog. Its really clear.

    I have a small question.

    I have a matlab model of a PMSM and I have to tune the two PIs. I thought as a first step to impose a constant torque and tune only the current controller. Is that a valid idea? However, it works only for a very low torque and only for a few secs and then it gets unstable..

    Any suggestions?

    Thanks in advance.

    Regards,

    Dimitra

  • Hi Dimitra,I am glad you found this blog helpful!  

    While you are tuning your torque (current) loop, what are you doing with the velocity loop?  In order to keep the velocity loop out of the picture while you are tuning the torque loop, you should break the velocity loop by replacing the output of the velocity PI controller (which is the reference input for the q-axis current controller) with a controlled current value.

    With the velocity loop out of the picture, there is now nothing controlling the speed of your system.  That means that unless your load torque perfectly matches the electromagnetic torque being generated by your torque loop, the speed will run away.  I have seen in the past that this can cause problems with my simulations, especially if the load torque is greater than the electromagnetic torque.  What I do to keep this from happening is replace my load model with an X^2 type of load curve (like a fan load model, or something else which increases torque bi-directionally as a function of speed.  This will cause the torque loop to settle out and prevent speed runaway.  Then, you can observe the response of your torque loop to different stimuli.  I have found that a step input of the iq reference current is very effective in gauging the stability response of the current loop.

    Hope that helps,Dave

  • Hello Dave,

    I have been following your motor control blogs for long time.

    You have been using lot of MATHS in current blog of your.

    You have skipped detailed explanation of some equations &  also derived the transfer function between q-axis current and motor torque.

    Please can you suggest right book where these explanation of equation have been done in details. This will make me good motor control algorithm who can derive the transfer function of  PMSM.

    Regards,

    Dinesh

  • hi,dave.thanks for your work.

    but I have a question.I read the TI user guide ,it set the deta =4,but in my book ,it set the deta = sqrt(5).

    Please tell me which one is better.

    Thanks