Dynamics and motion control Lecture 5 Model following control -servo design Jan Wikander,Bengt Eriksson KTH, Machine Design Mechatronics Lab e-mail: benke@md.kth.se KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 1(35) 5.1. Lecture outline • 1. Introduction • 2. Transfer function based model following • 3. Time domain based model following • 4. An example • 5. Matlab example for the dc motor KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 2(35) 5.1.1. The servo problem • The servo problem, here with error feedback. Feed forward controller Set point Trajectory planner rs u ff Model following control r Feedback controller u Controlled Output system • Characterized by frequent changes in set point (e.g in an industrial robot) • Control design mainly to follow (track) the reference (e.g. position or velocity, or position, velocity, acceleration and jerk). KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 3(35) 5.1.2. Feedback control properties • The main principle in control engineering • Typically model based (but not required to be) • Produces control signals after an error has occurred • Disturbance rejection is achieved • Effect of process parameter variations is reduced • Leads to a closed loop • Sensor noise may be amplified and deteriorate performance • May lead to instability if designed incorrectly KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 4(35) 5.1.3. Feed forward control properties Disturbance (measured or modelled) Reference signal Feed forward control Disturbance Process Output • Model based (but fairly simple models typically helps a lot) • Produces control signals before error has occurred • Uses measured or modelled disturbance and compensates for it • Uses carefully designed reference signals to make the process follow the references “exactly” and without saturating the control signal. KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 5(35) 5.1.4. The model based control concept Control u ff Model following control Setpoint r s Output y Trajectory planner S --R Reference r Controlled system Control u 0.6 Amplitude 0.4 rs 0.2 r 0 −0.2 0 0.5 1 1.5 Time 2 2.5 3 Two tasks 1.) Design the reference signals in the trajectory planner, r ( t ) . 2.) Design a model following controller, u ff ( t ) . KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 6(35) 5.1.5. The ultimate goal, Exact model following Model following control uff Set point Trajectory planner Reference Controlled Output system • Design the trajectory planner and the model following controller such that the feed forward input signal uff(t) drives the output to the desired setpoint • Note that the model following control part can be a nonlinear system • Two main concepts, Transfer function and Time domain. KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 7(35) 5.2. Lecture outline • 1. Introduction • 2. Transfer function based model following • 3. Time domain based model following • 4. An example • 5. Matlab example for the dc motor KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 8(35) 5.2.1. Model following TF-based Feed forward setpoint r s 1/Gp(s) y r + Gm(s) Gp(s) • Gm(s) is the reference model, i.e it is designed to provide reasonable references to the controller, and to make Gm ⁄ G p proper. • Gp(s) is the transfer function of the process. No feedback controller yet! • Ideally the inverse of the process, i.e. 1/Gp(s), would provide exact model following: 1/Gp(s) * Gp(s) = 1, and the closed loop y ⁄ rs = G m ( s ) • Clearly, the model following concept is directly dependent on the accuracy of the process model. KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 9(35) 5.2.2. The reference model Gm(s) • The task of the reference model is to generate smooth references that the process is able to follow. • To implement complete model following, i.e a full process inverse, we must require that the pole excess dm of the reference model is larger than or equal to the pole excess d of the process, i.e if B(s) G p ( s ) = ----------A(s) is the pole excess of the process dp d p = deg ( A ) – deg ( B ) and finally the requirement dm ≥ dp Bm ( s ) G m ( s ) = --------------Am ( s ) KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK d m = deg ( A m ) – deg ( B m ) Mechatronics Lab Slide: 10(35) 5.2.3. Model following TF-based cont. • Since exact model following involves taking the inverse of the process model, the inverse must be possible to implement. I.e. the inverse must constitute a stable dynamic system. • A stable dynamic system has no right half plane (RHP) poles. This means for model following that the process must not have any RHP zeros. • Care must be taken when doing the discrete time implementation because, as we know, a continuous time system with only LHP zeros may become zeros outside the unit circle when transformed into discrete time. This often happens for very low sampling periods. KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 11(35) 5.2.4. Implementing the TF based servo control Gm ( s ) --------------Gp ( s ) rs Gm(s) u ff r KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm Feedback controller MMK u Controlled Output system Mechatronics Lab Slide: 12(35) 5.3. Lecture outline • 1. Introduction • 2. Transfer function based model following • 3. Time domain based model following • 4. An example • 5. Matlab example for the dc motor KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 13(35) 5.3.1. Model following Time domain (TD) • Instead of the combined trajectory and model following transfer function Gm ( s ) --------------Gp ( s ) are the trajectory and model following implemented separately and based on trajectories in time. • Model following: If the inverse model (from y -> u) can be written as a function of the output and n-times the derivatives of the output (n:th order model). n ⎛ dy d 2 y d y⎞ u ( t ) = f ⎜ y, ------, --------, …, --------⎟ n ⎝ dt dt 2 dt ⎠ 2 • Trajectory planner: Design n dy d y d y y, ------, --------, …, -------2 n dt dt dt based on closed loop specifications and process limitations, e.g., saturation. KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 14(35) 5.3.2. The concept, an example Process model DC-motor with non-linear friction Gives the feed forward control, . ·· · · u ff ( t ) = Jϕ r ( t ) + dϕ r + F c sgn ( ϕ r ) . d---dt ·· ϕr G(s) J –1 d · ϕr d---dt ·· · · Jϕ = u – dϕ – F c sgn ( ϕ ) sgn() Fc u ff rs Trajectory planner r(t) KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm Feedback Controller MMK u fb ϕ u Process Mechatronics Lab Slide: 15(35) 5.3.3. Practical implementation • We want to avoid to take the derivative of signals. -> The Trajectory planner must provide the derivatives G(s) J –1 d rs Trajectory planner ·· ϕr · ϕr r = ϕr KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm sgn() Fc u ff Feedback Controller MMK u fb ϕ u Process Mechatronics Lab Slide: 16(35) 5.3.4. n-times differentiable reference signals • The DC-motor is a second order diff. eq. from input to position - The reference position must be two times differentiable (velocity and acceleration) - Which is the same as: The acceleration reference must be finite ex. ·· ϕr 1 0.8 · ϕr 0.6 0.4 ϕr 0.2 0 −0.2 −0.4 −0.6 −0.8 −1 0 0.5 KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm 1 MMK 1.5 Mechatronics Lab Slide: 17(35) 5.3.5. How to choose the reference signals • Fastest possible positioning (or specific time trajectories) - Calculate max acceleration and velocity of the process, without saturating the input to the motor. - For the DC-motor: If max input torque is ± M max then max acceleration at zero velocity is a max = ( ± M max ) ⁄ J . Max velocity at zero acceleration is v max = ( ± M sat ) ⁄ ( d + F c ) a max 1 0.8 Example reference trajectories r pos v max 0.6 0.4 0.2 0 −0.2 −0.4 −0.6 −0.8 −1 0 0.5 KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm 1 1.5 MMK 2 2.5 Mechatronics Lab Slide: 18(35) 5.3.6. Example: how to calculate the ref. traj. v = at , zero initial condition! v max t 1 = ------------ , the time when maximum velocity is reached using maximum acceleration a max t1 2 v 2 1 1 max y ( t 1 ) = a max t dt = --- a max t 1 = --- ------------ , position reached at time t 1 2 2 a max 0 ∫ v max rs r s – 2y ( t 1 ) = v max ( t 2 – t 1 ) -> t 2 = ------------ – ------------ + t 1 is the latest time to start braking. v max a max 80 Example:: 60 40 r s = 60, v max = 55 a max = 70 t2 20 0 t1 −20 −40 −60 −80 0 0.2 0.4 0.6 0.8 1 1.2 1.4 KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm 1.6 1.8 MMK 2 Mechatronics Lab Slide: 19(35) 5.3.7. General remarks • The two concepts of servo control are often combined • Some process models are inherently difficult to invert. - Flexible links: Approximate the flexible model with a stiff model, the inertia and the friction of the process is still fed forward. • You need some margin to the theoretical maximum acceleration and speeds. - delays in computer implementation, flexibility. - Maximum torque is a function of motor speed. KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 20(35) 5.4. Lecture outline • 1. Introduction • 2. Transfer function based model following • 3. Time domain based model following • 4. An example • 5. Matlab example for the dc motor KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 21(35) 5.4.1. Model following control example I • Consider a second order motion control system. The output is position. The electrical motor (the coil inductance is neglected) is operating against a linear spring with spring constant K 0 0 1 x· = K emk ⋅ K m + K m ⋅ u Kf -------– ----- – 〈 -------------------------〉 J J J • y = 1 0 ⋅ x1 x2 Or in transfer function form Km ⁄ J G p ( s ) = ---------------------------------------------------------Kf K m ⋅ K emk 2 s + s ⎛ -------------------------⎞ + ----⎝ ⎠ J J KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 22(35) 5.4.2. Model following control example II • Assuming 1 G p ( s ) = ---------------------------------2 2s + 1.5s + 1 • We get the following principle model following control scheme r setpoint rs Model following u ff Reference model,Gm(s) • 1 y 2s2 + 1.5s +1 Task: Design the reference model and the model following controller KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 23(35) 5.4.3. Implementing the model following • The perfect model following is the inverse of the model 2 u ff ( s ) Gm ( s ) 2s + 15s + 1 --------------- = -------------- = --------------------------------Gp ( s ) rs ( s ) 1 • Gm ( s ) = 1 (not proper) Use a reference model with pole excess dm > 2 (version 1) 2 2 G m ( s ) = ω ⁄ ( s 2 + 2ξωs + ω ) 2 2 u ff ( s ) ( 2s + 15s + 1 )ω -------------- = --------------------------------------------2 rs ( s ) s 2 + 2ξωs + ω • (proper) Or use a trajectory planner, position, velocity and acceleration (version 2) 2 u ff ( s ) = ( 2s + 15s + 1 )r s ( s ) ·· · u ff ( t ) = 2r s ( t ) + 15r s ( t ) + r s ( t ) KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 24(35) 5.4.4. Output from the trajectory planner 150 acceleration 100 Amplitude 50 velocity position 0 −50 −100 −150 • 0 0.5 1 Time 1.5 2 The reference model provides acceleration, velocity and position references (acceleration step, velocity ramp and a smooth position reference) 1 r vel = --- r acc t 1 1 r pos = --- r vel = ---- r acc 2 t t KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Observe, initial conditions Mechatronics Lab Slide: 25(35) 5.4.5. Acceleration feed forward 300 control signal 200 position reference Amplitude 100 system response 0 −100 −200 −300 • 0 0.5 1 Time 1.5 2 Let’s start out with feed forward to cope better with the acceleration step u ff = 2r·· . • The process follows fairly good initially when the acceleration signal dominates KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 26(35) 5.4.6. Acceleration and velocity feed forward 400 control signal, u 300 200 position reference, r 100 system response, y 0 −100 −200 −300 • 0 0.5 1 1.5 2 Next we add velocity feed forward which gives improved following of the reference. u ff = 2r·· + 15r· KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 27(35) 5.4.7. Exact model following 400 control signal 300 Amplitude 200 100 system response (equal to reference position 0 −100 −200 −300 • 0 0.5 1 Time 1.5 2 Finally we add position feed forward which gives exact model following. u ff = 2r·· + 15r· + r • Note again, that we assume exact knowledge of the model! KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 28(35) 5.4.8. Adding a zero to the model Model inverse Reference s+5 y 2s2 + 1.5s +1 • The process is extended with LHP zero. • Exact model following is still possible since the inverse system is stable. • The static gain of the process is 5. KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 29(35) 5.4.9. Feed forward without numerator inverse control signal 80 60 Amplitude 40 system response 20 0 reference position −20 −40 −60 • 0 0.5 1 Time 2 Let’s first have look on the response with only changing the gain of the feed forward controller. • 1.5 ·· + 15r· + r 2r ----------------------------. u ff = 5 The added dynamics (model zeros) is clearly visible. KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 30(35) 5.4.10. Exact model following for LHP zero 60 50 system response, y and reference 40 Amplitude 30 20 control signal, u 10 0 −10 −20 −30 • 0 0.5 1 Time 1.5 2 Exact model following is implemented by including also the inverse of the numerator. 1 u ff = ( 2r·· + 15r· + r ) ----------s+5 KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 31(35) 5.4.11. A non-minimum phase system Model inverse Reference model -s+5 y 2s2 + 1.5s +1 • Clearly, we have a RHP zero, making exact model following impossible. That is, the inverse of the process model constitute an unstable dynamic system. • The static process gain is still 5. KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 32(35) 5.4.12. Approximate model following (RHP zero) control signal 80 reference position 60 Amplitude 40 20 system response 0 −20 −40 −60 • 0 0.5 1 Time 1.5 2 An approximate model following can be implemented by taking the inverse of the static portion of the numerator • 1 u ff = ( 2r·· + 15r· + r ) --- . 5 Observe the typical response starting in the wrong direction. KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 33(35) 5.4.13. Summary Control u ff Model following control Setpoint r s Output y Trajectory planner S --R Reference u c Controlled system Control u Design the trajectory planner based on the performance of the motor. Design the model following control based on an inverse model of the process. Excellent for non-linear phenomena. KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 34(35) 5.5. Lecture outline • 1. Introduction • 2. Transfer function based model following • 3. Time domain based model following • 4. An example • 5. Matlab example for the dc motor KTH Date: 2009-08-27 File: Q:\md.kth.se\md\mmk\gru\mda\mf2007\arbete\Lectures\FinalVersions\For2009\L5.fm MMK Mechatronics Lab Slide: 35(35)