Meo To To who it ay concern Date Reference Nuber of pages 219-1-16 SVN: 5744 22 Fro Direct line E-ail Jan Mooian +31 )88 335 8568 jan.ooian@deltares nl +31 6 4691 4571 Subject PID controller ass-spring-daper syste Copy to Version control inforation Location : https://repos.deltares.nl/repos/ds/trunk/doc/user_anuals/ white_papers/sobek/pid-controller/pid.tex Revision : 5744 Contents 1 PID controller in SOBEK................................ 2 2 Ai of this docuent.................................. 3 3 Conclusion....................................... 3 4 Mass-Spring-Daper syste.............................. 3 4.1 Energy of Mass-Spring-Daper syste.................... 4 5 Feedback loop, PID-controller............................. 5 5.1 Unit ipulse function.............................. 5 5.2 Unit step function................................ 6 6 PID controller positional)................................ 7 6.1 Proportional ter................................ 8 6.2 Derivative ter................................. 8 6.3 Integral ter.................................. 9 7 PID controller velocity)................................. 1 8 Deterine coefficients fro experients........................ 11 9 Nuerical discretisation................................ 12 9.1 Mass-Spring-Daper syste as syste of first order PDE s......... 12 9.2 PID controller positional)........................... 12 9.2.1 Iplicit Mass-Spring-Daper syste with explicit PID-controller. 12 9.2.2 Iplicit Mass-Spring-Daper syste with iplicit PID-controller. 13 9.2.3 Corrected Mass-Spring-Daper syste while using an explicit PID controller............................... 13 9.3 PID controller velocity)............................ 14 9.3.1 Iplicit Mass-Spring-Daper syste with explicit velocity PID controller................................ 14
219-1-16 SVN: 5744 2/22 9.3.2 Iplicit Mass-Spring-Daper syste with iplicit velocity PID controller................................ 14 9.3.3 Corrected Mass-Spring-Daper syste while using an explicit velocity PID controller......................... 15 1 Experients....................................... 16 1.1 Solutions deterined by Maplesoft...................... 17 1.2 Nuerical experients............................. 18 1.2.1 Tie integration ethod...................... 18 1.2.2 Convergence behaviour....................... 2 References.......................................... 22 Used references Berdahl and III 27), Callafon 214), Rowell 24), Yon-Ping Mass-Daper-Spring systes/pid control of the siplest second-order systes, eq. 23): PD-Controller, desired set-point will not be reached. Rao 29, pg. 13, eq. 2-39): Integral of Dirac delta functions unit ipulse and unit step response) Åströ and Murray 216, pg. 47 eq. 2.19): Unit step response solution. Seborg et al. 211, 8.6.1) To Do 1 Transfer functions. 1 PID controller in SOBEK The discretised PID-controller in SOBEK2 read: f n = f n 1 + K p e n + K i n e j + K d e n e n 1), 1) j= No literature references are found for this PID-controller i.e. Equation 1)). The proposed discretised PID-controller read: f n = f n 1 + K p e n e n 1) + K i n e n + K d e n 2e n 1 + e n 2 This PID-controller Equation 2)) is based on the linearisation of the standard PID-controller. 2)
219-1-16 SVN: 5744 3/22 2 Ai of this docuent The ai of this docuent is to find out what each ter of the PID-controller does do to a general syste. To reach that goal we look to the Mass-Spring-Daper syste without loss of generality. 3 Conclusion Matheatical physics Proportional gain factor: influence on equilibriu state. But it does not reach the required set-point. Integral gain factor: influence on the equilibriu state. You need this ter to reach the equilibriu state. Derivative gain factor: Influence transition tie to the equilibriu state, but it does not influence the equilibriu state. Nuerical experients Soe nuerical experients are perfored. Varying tie step and varying the tie integration ethod of the PID-controller. The tie integration of the Mass-Spring-Daper-syste is iplicit. Explicit ipleentation black box approach of the PID-controller) does have a severe draw back on the coputation tie because the should be decreased w.r.t. the other ethods. 4 Mass-Spring-Daper syste k c ft) Figure 1: Drawing of Mass-Spring-Daper syste. Equation of Mass-Spring-Daper syste >, c > and k > ): ẍ + cẋ + kx = ft) ẍ + c ẋ + k x = 1 ft) 3)
219-1-16 SVN: 5744 4/22 The natural free) angular velocity ω n is c = and ft) = ): ω n = k, The decay tie constant τ is: τ = 2 c and the daping ratio ζ is: ζ = c 2 k The daping ratio is related to ω n. r 2 + cr + k = r 1,2 = c± c 2 4k Decay of solution is: exp c 2 Daping rate is: exp ζω nt) = exp ct 2 The equation can also be written as: ) 2, so the decay tie constant is: τ = 2 ) c ζωn = c c ζ = ζ = 2 2ω n c 2. k ẍ + 2ζω nẋ + ω 2 n = 7) r 2 + 2ζω nr + ω 2 n = r 1,2 = ζω n ± 1 2 4ζ2 ω 2 n 4ω 2 n r 1,2 = ζω n ± ω n ζ2 1. Define ω d = ω n 1 ζ 2 as the frequency for the under daped oscillations. ζ = not daped oscillations) ζ < 1 under daped oscillations) ζ = 1 critical daped ζ > 1 over daped 4.1 Energy of Mass-Spring-Daper syste Write the Mass-Spring-Daper syste as a set of first order of PDE s, without external forces as: ẋ = v v = cv kx, The total energy of the syste read: E tot = E kin + E pot = 1 2 v2 + 1 2 kx2 1) Energy conserving: d dt E tot = d dt 1 2 v2 + 1 2 kx2 ) = v v + kxẋ 12) 4) 5) 6) 8) 9) 11) Substituting gives: d dt E cv kx tot = v + kxv = cv 2 vkx + kxv = cv 2 13) d So if c = the syste is energy conserving, other wise the syste is dissipative. If dt E tot = the Mass-Spring-Daper syste is called a Hailtonian syste, if d dt E tot the Mass-Spring-Daper syste is called a Lyapunov function.
219-1-16 SVN: 5744 5/22 5 Feedback loop, PID-controller Ipleent the feed back loop external force is dependent on solution, Berdahl and III 27)) and an external force as step function i.e. new setpoint) with ft) = K p x K d ẋ + ut) 14) K p gain factor proportional to x. K d gain factor proportional to the tie derivative of x i.e. ẋ, velocity) and ut) the unit step function is defined as Rao 29, pg. 13, eq. 2-28): { t < ut) = 1 t After substitution of Equation 14) in Equation 3) consider only t ; assue everything is in rest for t < ) we get: ẍ + cẋ + kx = K p x K d ẋ + ut) 16) ẍ + c + K d )ẋ + k + K p )x = ut) 17) To evaluate the stepfunction ut) of Equation 15), we first discuss the solution for the Dirac delta function or unit ipulse function) and than the unit step function. 5.1 Unit ipulse function To evaluate the Dirac delta function or unit ipulse function): { t = a δt a) = t a which satisfies δt a)dt = 1 19) ft)δt a)dt = fa) 2) Suppose gt) is the solution of the syste: 15) 18) g + cġ + kg = δt) 21) Integrate this equation fro to T T > ), just the length of the pulse. Resulting in a valid value at the right hand side T T g + cġ + kg) dt = δt) dt 22) T g dt + T T cġ dt + kg dt = T δt) dt 23)
219-1-16 SVN: 5744 6/22 Taking the liit as T, we obtain ter by ter): T li gt) dt = li ġt) T = li [ġt ) ġ)] = T T T ġ+ ) li T T T li and thus T T ġt) is discontinue cġt) dt = li cgt) T = li c [gt ) g)] = gt) is continue 25) T T kgt) dt = li ktg) T = li k [T g) g)] = because g) = 26) T T δt) dt = 1 ġ + ) = 1 ġ + ) = 1 Now that we know that the response of a second-order resting syste is to change the velocity while leaving position unchanged), we can use this fact to obtain the ipulse response gt). In particular, assuing an underdaped syste, we know that the general for of the free response is given as gt) = e ζωnt A cos ω d t + B sin ω d t) 29) Therefore, with g) = and ġ + ) = 1/ the response of the syste to a unit ipulse at t = is given as { t gt) = 1 ω d e ζωnt 3) sin ω d t t > 5.2 Unit step function The unit step function is defined as { t < a ut a) = 1 t a The relation between the δt) and ut) is as follows: 24) 27) 28) 31) ut a) = t d ut a) dt δτ a) dτ 32) = δτ a) 33) The function st) is called the step response and satisfies: s + cṡ + ks = ut) 34)
219-1-16 SVN: 5744 7/22 The function st) will be obtained as follows, starting fro the unit ipulse solution gt): g + cġ + kg = δt) 35) g + cġ + kg = d ut) dt Integrating this equation fro to t: t d2 g dτ 2 + cd g ) dτ + kg dτ = t 36) d uτ) dτ = ut) 37) dτ Using the fundaental theore of calculus we get d2 dt 2 + c d ) t dt + k gτ) dτ = ut) 38) It is seen that st) = t gτ) dτ For t we have st) = and for t > we have integrating Equation 3)) t ) 1 st) = e ζωnτ sin ω d τ dτ 4) ω d After soe calculation, using sin x = e ix e ix )/2i and e ix + e ix )/2 = cos x Rao, 29), we get { t st) = )) 1 1 e ζωnt 41) cos ω d t + ζωn sin ω d t t > or ω 2 n )) t st) = 1 1 e ζωnt cos ω d t + ζ sin ω 1 ζ 2 dt t > ω 2 n This solution brings the syste to a new equilibriu state using Equation 4)): li st) = 1 t ω 2 n = 1 k 6 PID controller positional) ω d 39) 42) 43) Assue that the equilibriu value x or setpoint new equilibriu) is a desired value, the error deviation) to that value is defined as: et) = x xt). This error deviation) will be investigated. The PID-controller can been seen as an external force on the Mass-Spring-Daper-syste and read: where ft) = K p et) + K i t det) eτ) dτ + K d, 44) dt
219-1-16 SVN: 5744 8/22 K p K i K d gain factor proportional to et), gain factor proportional to the tie integral of et) and gain factor proportional to the tie derivative of et). 6.1 Proportional ter Consider just the proportional ter, so K i = K d =. The proportial ter K p et) does influence the equilibriu state of the Mass-Spring-Daper syste, but will not reached the desired equilibriu state x. ẍ + cẋ + kx = K p x x) 45) ẍ + cẋ + k + K p )x = K p x 46) So the particular solution will not reach the equilibriu state li t, and ẍ = ẋ = ): li xt) = t K p k + K p ) x and k + K p > 47) also the free angular frequency is influenced by the proportional gain K p ω n = k + Kp 6.2 Derivative ter and k + K p > 48) Consider just the derivative ter, so K p = K i =. The derivative ter K d ėt) does not influence the equilibriu state of the Mass-Spring-Daper syste: d ẍ + cẋ + kx = K d dt x x) 49) ẍ + cẋ + kx = K d ẋ ẋ) 5) With ẋ = for the equilibriu state, so ẍ + cẋ + kx = K d ẋ 51) ẍ + c + K d )ẋ + kx = 52) So, just the daping factor resistance, friction) is adjusted by the derivative gain K d and the equilibriu state is the sae as for the hoogeneous solution ẍ = ẋ = ): li kxt) = li xt) =. 53) t t Reark: c + K d > other wise the syste is unstable, see section 4.1
219-1-16 SVN: 5744 9/22 6.3 Integral ter Consider just the integral ter, so K p = K d =. t The integral ter K i eτ) dτ does influence the equilibriu state of the Mass-Spring-Daper syste. Switching a Mass-Spring-Daper syste to another equilibriu state is done by prescribing a value other than zero as external force. For exaple a constant value, the integral of a Dirac delta function or another bounded integral. Prescribing a constant value of 1 will give as equilibriu state ẍ = ẋ = ): li ẍ + cẋ + kx) = 1 54) t kx = 1 x = 1 k The integral of the Dirac delta function is equal to 1, δt a)dt = 1 and will give therefore the sae solution as above Equation 55)). Prescribing the external force as ft) = t x xτ)) dτ 57) will force the solution xt) to x, because li t x xt)) = 58) and the integral is bounded < ). 55) 56)
219-1-16 SVN: 5744 1/22 7 PID controller velocity) Assue that a equilibriu value x or setpoint a new equlibriu), is a desired value, the error deviation) to that value is defined as: et) = x xt), and need to be investigated. The PID-controller can been seen as a external force on the Mass-Spring-Daper-syste and read: t det) f PID t) = K p et) + K i eτ) dτ + K d, equal to Equation 44) 59) dt The tie derivative velocity) of the PID-controller Equation 59)) read: f PID t det) = K p dt + K i et) + K d d 2 et) dt 2 6) Which coes fro the linearisation i.e. δy = K δx) of the PID-controller: f PID t + δt) = f PID t) + K δt 61) f PID t + δt) f PID t) = K δt 62) Divide Equation 62) by δt and take li δt, we get: f PID t + δt) f PID t) li δt δt f PID t = K 63) = K RHS Equation 6) 64) In discrete for Equation 6) read, with n = is constant, e n = x x n : f n f n 1 e n e n 1 = K p + K i e n e n 2e n 1 + e n 2 + K d n n 2 65) { f n = f n 1 e n e n 1 + n K p + K i e n e n 2e n 1 + e n 2 } + K d n 2 66) f n = f n 1 + K p e n e n 1) + K i n e n e n 2e n 1 + e n 2 + K d 67)
219-1-16 SVN: 5744 11/22 8 Deterine coefficients fro experients Taken fro Callafon 214) Estiation of odel paraeters With the ties t, t n and the values y, y n and y fro step response: Allows us to estiate: Figure 2: Collect data fro easureent. n ω d = 2π daped resonance frequency 68) t n t ) 1 y y βω n = ln exponential decay ter 69) t n t y y where n as subscript of t is the nuber of oscillations between t n and t. With the estiations of the deped frequency ω d and βω n we can now copute the natural frequence ω n and the daping ratio β: ω n = ω d 2 + βω 2 n undaped resonance frequency 7) β = βω n ω n daping ratio 71)
219-1-16 SVN: 5744 12/22 9 Nuerical discretisation 9.1 Mass-Spring-Daper syste as syste of first order PDE s The equation of a Mass-Spring-Daper syste ẍ + cẋ + kx = ft) 72) can be written as a syste of first order partial differential equations, which read: ẋ = v v = cv kx + ft) 74) with initial conditions: ẋ = v = and x = 1. In atrix notation this equation read: ) ẋ ) ) ) ) 1 1 x = + v k c v ft) This syste of equations in discrete for, with = t t n, read: x x n = v n v v n = cv kx + fx, x n,...) 77) Rearranging gives: x = x n + v n 78) 1 + ) c v = v n kx + fx, x n,...) 79) 9.2 PID controller positional) 9.2.1 Iplicit Mass-Spring-Daper syste with explicit PID-controller An explicit discrete for of the PID-controller Equation 44)) read: f n = K p e n + K i n j= 73) 75) 76) e j j + K d e n e n 1 n 8) The syste of equations will than read: x = x n + v n 81) 1 + ) c v = v n kx + n K p e n + K i e j e n e n 1 j + K d 82) n j=
219-1-16 SVN: 5744 13/22 9.2.2 Iplicit Mass-Spring-Daper syste with iplicit PID-controller An iplicit discrete for of the PID-controller Equation 44)) read: f = K p e + K i e j e e n j + K d 83) j= The syste of equations will than read: x = x n + v n 84) 1 + ) c v = v n kx + K p e + K i e j e e n j + K d 85) j= 9.2.3 Corrected Mass-Spring-Daper syste while using an explicit PID controller Therefore we will adjust the Mass-Spring-Daper syste for the explicit values used by the PIDcontroller by adding those ters who will ake the PID-controller iplicit. We will separate Equation 8) fro Equation 83). The individual ters belonging to Equation 8) will be placed between square brackets. f = K p e + K i e j e e n j + K d 86) j= = K p e K p e n + [K p e n ] + n K i e + K i e j j j= e e n e n e n 1 e + K d K d + [K n e n 1 ] d n n The part between square brackets, is equal to Equation 8), which is the PID-controller based on explicit tie levels: 87) So we get: f n = K p e n + K i n j= e j j + K d e n e n 1 n 88) f = K p e K p e n + K i e + K d e e n K d e n e n 1 n + f n 89)
219-1-16 SVN: 5744 14/22 Substitution of Equation 13) in Equation 79) leads to the following syste of equations: x = x n + v n 9) 1 + ) c v = v n kx + 1 [ Kp x x n ) + K i e e e n e n e n 1 ] +K d K d + f n 91) n Soe rearranging: x = x n + v n 92) 1 + ) c v = v n k + K p) x + K px n + f n is given by Equation 8). 9.3 PID controller velocity) + K ie + + K d e e n K d e n e n 1 9.3.1 Iplicit Mass-Spring-Daper syste with explicit velocity PID controller n + f n 93) An explicit discrete for of the PID-controller based on the linearisation Equation 6)) read: f n = f n 1 + K p e n e n 1) + K i e n e n 2e n 1 + e n 2 + K d, equal to Equation 67) 94) The syste of equations will than read: x = x n + v n 95) 1 + ) c v = v n kx + [f n 1 + K p e n e n 1) + K i e n e n 2e n 1 + e n 2 ] + K d 96) 9.3.2 Iplicit Mass-Spring-Daper syste with iplicit velocity PID controller An iplicit discrete for of the PID-controller based on the linearisation Equation 6)) read: f = f n + K p e e n) + K i e e 2e n + e n 1 + K d, equal to Equation 67) 97)
219-1-16 SVN: 5744 15/22 The syste of equations will than read: x = x n + v n 98) 1 + ) c v = v n kx + [f n + K p e e n) + K i e e 2e n + e n 1 ] + K d 9.3.3 Corrected Mass-Spring-Daper syste while using an explicit velocity PID controller Therefore we will adjust the Mass-Spring-Daper syste for the explicit values used by the velocity PID-controller by adding those ters who will ake the velocity PID-controller iplicit. We will separate Equation 94) fro Equation 97). The individual ters belonging to Equation 94) will be placed between square brackets. is constant. f = f n + K p e e n) + K i e + K d e 2e n + e n 1 = f n f n 1 + [ f n 1] + + K p e 2e n + e n 1) + [ K p e n e n 1)] + K i e K i e n n + [K i e n n ] e +... + [K n 2e n 1 + e n 2 ] d 99) 1) 11) The part between square brackets, is equal to Equation 94), which is the PID-controller based on explicit tie levels: So we get: f n = f n 1 + K p e n e n 1) + K i e n + K d e n 2e n 1 + e n 2 f =... + f n Substitution of Equation 13) in Equation 79) leads to the following syste of equations: 12) 13) x = x n + v n 14) 1 + ) c v = v n kx +... + f n ) 15) Soe rearranging: x = x n + v n 16) 1 + ) c v = v n +... + f n 17) f n is given by Equation 8).
219-1-16 SVN: 5744 16/22 1 Experients Mass-Spring-Daper-syste: with ẍ + cẋ + kx = ft), 18) t det) ft) = K p et) + K i eτ) dτ + K d dt Initial values: x) = 1 and ẋ) =. Coefficients: = 1, c = 2, k = 1. PID gain factors: K p = 1.; K i =.5; K d = 1.. Setpoint:.5. et) = x xt). x = setpoint. Table 1: Equilibriu solution. K p K i K d Equili 1....45..5..5.. 1.. 19)
219-1-16 SVN: 5744 17/22 1.1 Solutions deterined by Maplesoft =1., c=., k=1.).5;.,.,.) PID t_eq:. Aplitude [] 1..75.5.25..25.5.75 1. =1., c=2., k=1.).5; 1.,.5, 1.) PID t_eq: 3. tau : 16.666667 zeta:.1897 Aplitude [] 1..8.6.4.2 Mass Spring Daper. 6. 12. 18. 24. 3. Tie [s] Figure 3: The natural frequency; c = K p = K i = K d =. MassSpringDaper: MapleSoft deterined solution. 6. 12. 18. 24. 3. Tie [s] Analytic.5; setpoint.45; pd-setpoint c=.; not daped.5; setpoint.; pd-setpoint Figure 4: PID controller on Mass-Spring-Daper using MapleSoft solution. The integral ter is quite sall and therefor the influence is noticed after a while.
219-1-16 SVN: 5744 18/22 1.2 Nuerical experients Table 2: Perfored nuerical experients. tie integration 1.2.1 Tie integration ethod 1. s.5 s explicit 9.2.1) iplicit 9.3.2) corrected 9.2.3).25 s Figure 5: Nuerical experient = 1 s); explicit blue, 9.2.1), iplicit red, 9.3.2), corrected black, 9.2.3).
219-1-16 SVN: 5744 19/22 Figure 6: Nuerical experient =.5 s); explicit blue, 9.2.1), iplicit red, 9.3.2), corrected black, 9.2.3). Figure 7: Nuerical experient =.25 s); explicit blue, 9.2.1), iplicit red, 9.3.2), corrected black, 9.2.3).
219-1-16 SVN: 5744 2/22 1.2.2 Convergence behaviour Figure 8: Nuerical experient explicit 9.2.1); black, = 1. s; red, =.5 s; blue, =.25 s. Figure 9: Nuerical experient corrected 9.2.3); black, = 1. s; red, =.5 s; blue, =.25 s.
219-1-16 SVN: 5744 21/22 Figure 1: Nuerical experient, different and tie integration; explicit red, =.25 s, 9.2.1), corrected black, = 1. s, 9.2.3). Figure 11: Maple solution blue) vs corrected red, = 1. s, 9.2.3).
219-1-16 SVN: 5744 22/22 References Åströ, K. J. and R. M. Murray 216). Feedback Systes. Tech. rep. 3.h/. Caltech California Institute of Technology). URL: http://www.cds.caltech.edu/~urray/awiki/ index.php/main_page. Berdahl, Edgar J. and Julius O. Sith III 27). PID Control of a Plucked String. Tech. rep. Center for Coputer Research in Music and Acoustics CCRMA), and the Departent of Electrical Engineering REALSIMPLE Project ). Stanford, CA: Stanford University. Callafon, R. A. de 214). Position Control Experient MAE171A). URL: http://aecourses. ucsd.edu/callafon/labcourse/index.htl. Rao, A.V. 29). Mechanical vibrations: Lecture notes for course EML 422. URL: http://vdol. ae.ufl.edu/coursenotes/eml422/vibrations.pdf. Rowell, D. 24). Review of First- and Second-Order Syste Response. EducationMIT. URL: http: //web.it.edu/2.151/www/handouts/firstsecondorder.pdf. Seborg, D.E., T.F. Edgar, D.A. Mellichap, and F.J. Doyle III 211). Process Dynaics and Control. John Wiley & Sons, Inc. Yon-Ping, Chen. Mass-Daper-Spring systes/pid control of the siplest second-order systes. URL: http://jsjk.cn.nctu.edu.tw/jsjk/dsas/dsas_11_12.pdf.