1 Implementation of adaptive control algorithm based on SPOC form Winter 2011 Supervisor: Submitted by: Dr. Ilan Rusnak Ofer Rosenberg Roy Mainer 2 Project Background • Why do we need adaptive control? • What is an SPOC form? • What was accomplished in previous projects? ▫ Implementations of linear systems identification algorithms – in simulations and based on recorded data – not real time ▫ Different algorithms returned different results when applied on the same system. Which is correct? 3 Project Goals • Implementation of SPOC form adaptive control algorithm – in REAL TIME • Observation and measurement • Conclusions 4 System Hierarchy Linear motion system Dspace interface Matlab + Simulink 5 Project Development Steps: • Introduction to the linear motion system and the Dspace interface. • Understanding and repeating the results of previous related projects. • Implementation of the SPOC algorithm in Simulink. • Test the algorithm on both simulation and real time. • Gathering results and conclusions. 6 The SPOC Simulink blocks implementation Constant5 Ce eye(3) Constant diag(ones(1,2),1) Constant1 In1 -K- Constant3 Product2 zeros(3) 1 Qe Math Product3 Function Matrix Concatenation1 uT Matrix Multiply Matrix Multiply Matrix Multiply -CuT Gain Constant2 eye(3) Ke Matrix Multiply Add1 1 eye(9) [1x9] Add2 Product7 Inv Add4 Product4 Math Function1 1.2e-9 Ke Re -K- Add3 Product5 P0 Product Gain1 P0 1 z 1 Aed Matrix Concatenation2 2 eye(3) Constant4 -KGain2 In2 Product1 1 Matrix Concatenation3 Matrix Multiply 2 Matrix Multiply Matrix Concatenation Ke Product10 Matrix Multiply Matrix Multiply Product9 Add5 X0 1 Out1 1 z X0 Product8 y Add6 7 The SPOC Simulink blocks implementation - continued • Using matrix building blocks and algebra we implement the SPOC algorithm. • Process noise estimation vector (Qe block) is constant. 8 Simulation and Real Time • Once the SPOC block was complete, our work was divided to two parts – simulation and real time. • Simulation: ▫ Mainly based on simulated inputs and transfer functions. • Real Time: ▫ Linear systems transfer function estimated in real time and recorded. • Both methods estimate the transfer function during run time! 9 Main System Simulink Diagram (simulation) UU To Workspace3 Scope In1 Out1 YY YY To Workspace4 State Space Plant SPOC Subsystem UU In1 Out1 UU In2 Sine Wave states Sine Wave1 X0 Add Divide4 Sine Wave2 Kdc SW denominator numerator Acker Gain denom num 0 denom Constant8 1 When openloop gain=0 X states In1 Out1 In2 In3 KX Kc Out2 ACKER Subsystem denom num Kc In1 In2 Out1 In3 KDC Subsystem num To Workspace1 denum To Workspace2 Kdc 10 Main System Simulink Diagram (simulation) - continued • A 3rd order linear system requires an input comprised of at least 3 non dependent signals. • Input is fed to both the transfer function (also 3rd order) and the SPOC block. • Transfer function output is recorded and fed to the SPOC block. • The SPOC block outputs are the state space vector, the numerators and denominators vectors. • Other blocks: Acker and KDC are used to gain stability by moving the poles to pre determined locations and normalizing the system’s gain respectively. 11 Simulation Results Numerator Coefficients Denominator Coefficient Numerator Coefficients Denominator Coefficients 2.5 0 b1 b2 b3 2 -0.5 -1 1.5 -1.5 -2 1 -2.5 0.5 a1 a2 a3 -3 0 0 10 20 30 40 50 60 time [sec] 70 80 90 100 -3.5 0 10 20 30 40 50 60 time [sec] 70 80 90 100 12 Simulation Results – continued • Simulated transfer function: • Estimated transfer function: • Success! 13 Main System Simulink Diagram (real time) RTI Data 0 ENCODER MASTER SETUP Clock1 DS1104ENC_SETUP 1 shut down at simulation end start simulation with 0 inputs for 10 sec. One Switch1 Mult Switch2 4 5 3 UU UU_norm error 1 error Divide4 pos_error input gain 20 v el_error DAC to motor Kp 0 limit YY 0.012 Enc position Zero Enc delta position 1 DS1104ENC_POS_C1 YY enc_scale_factor Constant SPOC Subsystem 2 YY Sine Wave1 YY UU Sine Wave Add5 Multiport Switch Sine Wave2 Inv_Gain Manual Switch In1 Out1 Kcx_gain 0/0.1/0.5/1 error In2 0 Constant2 1 Sine Wave3 X0 states xo Switch denominator numerator Pulse Generator num denum states_out 8 Chirp Signal denum_out 7 states In1 Out1 Kcx In2 In3 Out2 ACKER Subsystem kc 1 Kcx_out 10 Kc_out denum num_out 6 Constant1 num kc 0 Clock 0 In1 In2 Out1 In3 KDC Subsystem 9 inv_gain_out 14 Main System Simulink Diagram (real time) - continued • Based on the simulation schematic. • Input switching to allow multiple choices and stop the motor from reaching the rail end. • Gain blocks based on previous empiric results. • Dspace designated blocks: • Inputs are fed to motor through Dspace D/A. • Outputs (motor position on rail) is fed through position feedback. 15 Process noise estimation vector • • • New Qe1 1e-6*diag([1 1 1 0 0 0 0 0 0 ]) + 1e-8*diag([ 0 0 0 110 • 0 1 1]) Clock 0 1e-6*diag([1 1 1 0 0 0 0 0 0 ]) + 1e-4*diag([ 0 0 0 The ratio Qe/Re affects the estimated coefficients convergence speed. 110 • 0 1 1]) Switch Qe1 • • Re – Measurement noise Qe – Process noise Results show that high ratio improves estimation speed while low ratio reduces noise. In simulation we have no measurement noise so no need to switch. Convergence time is approximately 20 [sec] in real time. After 20 [sec] the Qe vector is switched to lower the ratio and reduce the noise. 16 Real Time Results Numerator Coefficients Denominator Coefficient Numerator Coefficients Denominator Coefficients 250 150 200 100 a1 a2 a3 50 150 b1 b2 b3 100 0 -50 50 -100 0 -150 -50 -200 -100 -150 -250 0 10 20 30 time [sec] 40 50 60 -300 0 10 20 30 time [sec] 40 50 60 17 Numerator Coefficients convergence – zoomed Numerator Coefficients 250 200 150 b1 b2 b3 100 50 0 -50 -100 -150 5 10 15 20 time [sec] 25 30 18 Real Time Results – continued • Estimated transfer function: • Success? ▫ We have no reference to compare with… 19 Conclusions Results table Conclusions summary Comparison Parameter Simulation Real Time Accuracy Perfect Convergence time Very fast, 23 [sec] without Qe switching. Noiseless Transfer function converged successfully. system might be of higher order. Also fast, 30 [sec] with proper Qe. Noise Influence of closed loop None Dramatic decrease in noise after Qe switching. Influences the estimation result • Linear system was expected to be of 3rd order. Results show it is probably of higher order. • High ratio of Qe/Re improves convergence speed, while lower ratio reduces noise. 20 Articles Links • The links will be opened from technion computers or any computer who is registered to IEEE Xplore Digital Library. • Real-Time Simultaneous State Estimation and Parameters Identification of Linear Drive System with the SPOC based Algorithm • http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=00532255 • http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=721052 • http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4793065 21 Tubes SPOC OPEN ZOOM • http://www.youtube.com/watch?v=aFKcutmu7Jg&featu re=g-upl SPOC OPEN LOOP • http://www.youtube.com/watch?v=KeURm9FxpgA&fea ture=g-upl SPOC ACKER GAIN 0.5 ZOOM • http://www.youtube.com/watch?v=nv7UwoHDDZI&fea ture=g-upl SPOC ACKER GAIN 0.5 • http://www.youtube.com/watch?v=He0nM6c7g14&feat ure=g-upl 22 Bibliography • “Real-Time Simultaneous State Estimation and Parameters Identification of Linear Drive System with the SPOC based Algorithm” \ Dr. Ilan Rusnak (article) • "Feedback Control of Dynamic Systems 6th Ed." \ Gene F. Franklin, J David Powell, Abbas Emami-Naeini (681.516) • "Linear Control System Analysis and Design with Matlab 5th. Ed" \ John j. D'azzo, Stuart N. Sheldon (681.511) • “Control for Unstable Nonminimum Phase Uncertain Dynamic Vehicle” \ Dr. Ilan Rusnak (article) • “State Observability and Parameters Identifiability of Stochastic Linear Systems” \ Dr. Ilan Rusnak (article) • “Simultaneous State Observability and Parameters Identifiability of Discrete Stochastic Linear Systems” \ Dr. Ilan Rusnak • Internet and especially Wikipedia • Project book by Gil Kanashty: ."• "יישום אלגוריתמי זיהוי של מערכות ליניאריות על מערכת מעבדתית 23 Special thanks Dr. Ilan Rusnak Koby Kochai Orly Vigderzon Gil Kanashty 24 Thanks for watching Ofer Rosneberg Roy Mainer 25 Adaptive Control (Wikipedia) • “Adaptive Control is the control method used by a controller which must adapt to a controlled system with parameters which vary, or are initially uncertain”. • For example, as an aircraft flies, its mass will slowly decrease as a result of fuel consumption; a control law is needed that adapts itself to such changing conditions. 26 SPOC Algorithm • SPOC – States and Parameters Observability Canonical Form. • SPOC algorithm is another method of estimating the transfer function of a system. • By representing the observer canonical form of a 3rd order linear system, we can isolate the condition for stability. • That condition can be solved using Kalman filter. 27 Linear Motion System • • • • Our linear motion system is based on a DC motor, traveling back and forth across the rail. The DC system has speed and even acceleration feedback. The motor is controlled by the computer via the Simulink implemented controller. This system was believed to be of 3rd order. 28 Acker Block 2 In2 (1 0 0) col 1 (0 1 0) Matrix Multiply 2 col 2 Matrix Concatenation4 2 Product13 Out2 Matrix Multiply Terminator Product12 Product14 kx [ 1 1.2 0.47 0.06] To Workspace2 pvv -required closed loop polynomial Product11 Ce1 We changed the coefficients of the polynom. The algorithem didn't work for fast poles! Scope1 eye(3) [0 0 1] Constant6 Product6 plv 1 In1 Inv Divide1 num Matrix Multiply 3 Product17 In3 Matrix Multiply KX Product18 KX To Workspace1 num num Matrix Multiply Out1 Product15 num Matrix Multiply Product16 2 controlability matrix kxx 1 29 Real-Time Simultaneous State Estimation and Parameters Identification of Linear Drive System with the SPOC based Algorithm 30 Real-Time Simultaneous State Estimation and Parameters Identification of Linear Drive System with the SPOC based Algorithm - continued 31 Real-Time Simultaneous State Estimation and Parameters Identification of Linear Drive System with the SPOC based Algorithm - continued