Calculating PID Gains Symbollically


Jump to: navigation, search
Calculating PID Gains Symbollically
Green carrot left.gif
PID Control Classical Control
Green carrot.jpg
In order to prevent spam, users must register before they can edit or create articles.

1 Introduction to Calculating PID Gains Symbollically

Peter Nachtway provided the meat of this article to me. (You can see the original file here.)

Peter had answered a problem on the sci.engr.control usenet group (the question that was asked can be found here). Here's the original question


The task: I will simulate a numerical PID under scicos. I use a Scifunc-Block. This block is triggered each ms. There I have following question:

1. The integral part of the PID has the form Yi = Yi + Ki * u1; The Problem: It seems, as Yi keeps not the value of the run before. Thus no integration is done. How can I reach, that Yi keeps this value?

2. Variable init: The variables are initialized in Diagram/context. Is this the correct place? is This init at "context" only done at the start of simulation and not every Scifunc-calling?

3. What else must be considered that the PID works propper?

Best regards


There were some private conversations between Peter and Wolfgang. The result is the pdf I linked to above.

2 PID Control Problem Formulation

The plant is standard second order system (Type 0). Peter Nachtway formulates that system as follows

LaTeX: G_{s}\left(s\right)=\frac{K}{s^2+A_1s+A_0} Type 0 System with 2 poles

The PID controller is

LaTeX: G_c\left(s\right)=\frac{K_i}{s}+K_p+K_ds Standard PID Controller

The closed loop transfer function for a controller and second order velocity is

LaTeX: \frac{G_c\left(s\right)G_s\left(s\right)}{1+G_c\left(s\right)G_s\left(s\right)} '1'

Let's start by evaluating

LaTeX: \begin{alignat}{2}L\left(s\right) & = G_c\left(s\right)G_s\left(s\right) \\ & =\left(\frac{K_i}{s}+K_p+K_ds\right)\left(\frac{K}{s^2+A_1s+A_0}\right) \\ & = \left(\frac{K_ds^2+K_ps+K_i}{s}\right)\left(\frac{K}{s^2+A_1s+A_0}\right) \\ & = \frac{K\left(K_ds^2+K_ps+K_i\right)}{s^3+A_1s^2+A_0s}\end{alignat} '2'

Substituting Eqn. 2 into Eqn. 1

LaTeX: \frac{\frac{K\left(K_ds^2+K_ps+K_i\right)}{s^3+A_1s^2+A_0s}}{1+\frac{K\left(K_ds^2+K_ps+K_i\right)}{s^3+A_1s^2+A_0s}} '3'

} Multiply top and bottom by LaTeX: s^3+A_1s^2+A_0s and get

LaTeX: \frac{K\left(K_ds^2+K_ps+K_i\right)}{s^3+\left(A_1+KK_d\right)s^2+\left(A_0+KK_p\right)s+KK_i} '4'

The closed loop transfer function with characteristic equation in powers of s. Explicitly, the characteristic equations is

LaTeX: s^3+\left(A_1+KK_d\right)s^2+\left(A_0+KK_p\right)s+KK_i '5'

Based on design requirements we can construct a desired closed loop transfer function.

In this example the desired characteristic equation is

LaTeX: \begin{alignat}{2}\Phi_{CL} & = \left(s+\lambda\right)^3 \\ & = s^3+3s^2\lambda+3s\lambda^2+\lambda^3 \end{alignat} '6'

2.1 Symbollic Solution

Using Eqn. 5 and Eqn. 6 it is easily determined that

LaTeX: \begin{alignat}{2}\lambda^3 & = & KK_i \\ 3\lambda^2 & = & KK_p+A_0 \\ 3\lambda & = & KK_d + A_1 \end{alignat} '7'

The values of K, A1, A0 are part of the plant model and therefore known at the time of the PID controller design. As a result there are 3 equations and 3 unknowns. Here are the values of Ki, Kp, adn Kd.

LaTeX: \begin{alignat}{2}K_i & = & \frac{\lambda^3}{K} \\ K_p & = & \frac{3\lambda^2-A_0}{K} \\ K_d & = & \frac{3\lambda-A_1}{K} \end{alignat} '8'

2.2 Example

Figure 1: Viscous Damping for single DOF system

This example comes from

For this example

    M = 1 kg
    c = 10 Ns/m
    k = 20 N/m
    F = 1 N

Leading to

LaTeX: \frac{X\left(s\right)}{F\left(s\right)}=\frac{1}{s^2+10s+20} '


K = 1
A1 = 10
A0 = 20

So if we choose LaTeX: \lambda=4\pi rad/sec then we get

LaTeX: \begin{alignat}{2}K_i & = & \frac{64\pi^3}{1} \\ K_p & = & \frac{48\pi^2-20}{1} \\ K_d & = & \frac{12\pi-10}{1} \end{alignat} '