Copyright © IFAC System Identification, Kitakyushu, Fukuoka, Japan, 1997
IDENTIFICA TION AND CONTROL OF A SERVO SYSTEM
Franta Kraus, Xiaobing Qiu and Waiter Schaufelberger Automatic Control Laboratory, ETH-Zentrum Swiss Federal Institute of Technology, 8092 Zurich, Switzerland E-mail:
[email protected]
Abstract. Identification for control is demonstrated on a small servo system. It is shown how to go through the entire cycle of modeling and identification with the aim of obtaining models suitable for controller design. Controllers are designed and implemented in the real time from the identified models. Keywords. Modeling and identification, implementation, rapid prototyping.
mechanical
system,
real
time
I . INTRODUCTION
A practical case is investigated in this paper. Small servo systems as the one depicted in Figures 1 and 2 shall be identified and controlled (Derighetti, et aI., 1996).
Fig. 2. Laboratory experiment setup: DC servo system, schematic diagram
2. MODELING Mathematical modeling of the DC servo system is straightforward and will yield about the following diagrams, from which the equations can be obtained easily:
Fig. 1. Laboratory experiment setup: DC servo system, scanned photo Although the Servo system permits MIMO experiments (2 inputs, 4 measurements) only a simple SISO set up will be discussed. Thereby experience in different ways of identification and the role of identification for control purposes In the whole design cycle are of the main interest.
Fig. 3. The device scheme of the DC servo system with spring angle.
197
% measurements on servo-system
clear devices_ u=randgen( I 024, 3. 1.5); ts=0.05; putnow_(TIMER_1. IS) ; y=zeros( I ,Iength(u»; for i= l:leng[h(u), y(i) = putgeUANOUT_I,u(i) ,ANIN_I); end; putnow_(ANOUT_I ,O) ; plot((O:length(u)-1 )*ts ,y,(0: leng[h(u)-I )*[s ,u) titleCStep res ponce') xlabelCTime [s]') echo off 2.---~----.----r----.----r----.
Fig. 4 . Simplified block diagram of DC servo system with XI = ({JI and X3 = ({J2
o -1
The main information to be retained from modeling is the system order of about 4, resulting from neglecting the small time constant of the armature winding of the motor. Full infonnation including the structure of the system may be used in time domain identification, only partial infonnation is used for gray box identification as armax and related models.
-2 -3 -4 -5L---~----~--~----~--~--~
o
200
400
600
800
1000
1200
Fig. 5. Random excitation signals (amplitude : 1.5, length : 1024 ) and measurements (sampling time: 0 .05s)
3. IDENTIFICAnON The identification is based on the models from above and measurements from the real process . Pseudo random binary signals with variable amplitude and/or variable pulse length are used for excitation. This can be done with or without filtering . The Matlab identification toolbox based on (Ljung, 1987) has been used for gray box identification and state space based identification with very similar results .
A typical layout of armax identification using the MATLAB identification tool box is shown as an example. % part I: system structure selection
z=[y',u']; na=I :4; nb=I :4; nk=0:3; nn=struc(na,nb,nk); v=arxs[ruc(z,z,nn) ; n=selstruc(v,'plot') ; th=arx(z,n) ; e=resid(z,th); figure(2); yh=idsim(u' ,th); plot([y' yh]) ; % part 2: ARMAX identification using selected structure z=[y',u']; na=4; nb=4; nc=4 ; nk=O; n=[na nb nc nk); th=armax(z,n); e=resid(z,th); figure(2); yh=idsim(u' ,th); plot([y' yh]) ; present(th); [a,b,c,d,k,xO]=th2ss(th); eig(a) c=c/30 ; b=b*30;
The following m-files show the generation of the PRBS u(t) and the measurements of the output
y(t) using the real time Ctrl-Lab (Derighetti, et al., 1996): function u=randgen(length, seq, amplitude); % RandGen, a program for generating random excitation
signals % using a normal distribution for amplitudes % and a uniform one for subsequence length multiplied by seq le=O; u=[];his_Io=[]; while le <= length, lIoc= seq*floor(l5*rand+ I); le=le+lloc; amp=0.5*randn*amplitude; u=[u , amp*ones(l.11oc)]; his_Io=[his_lo;lloc] ; end u=u( I :Iength) ;
198
This model is assumed to be good enough for controller design . For well excited systems very similar performance can be obtained using the model structure and optimizing the parameters in continuous time state space with the pem method . For poor excitation, however, the superiority of the direct optimization of physical based parameters in time continuous description is obvious.
The identification results are: Norm of gn-vector: 0.05438 This matrix was created by the command ARMAX on 211 1996 at 9:44 Loss fcn: l.372e-05 Akaike's FPE: 1.405e-05 Sampling interval 1 The polynomial coefficients and their standard deviations are
As a completely different alternative, an optimization by a genetic algorithm (Houck, et al., 1996) was also used (results in Fig. 7). All identification methods tried yielded very similar results, the problem at hand is not a difficult case for identification.
B=
0.0004 -0.0012 0.0002 0.0004
0.0014 -0.0004 0.0004 0.0002
A= 1.0000 -3.7081 5.3526 -3.5724 0.9280 o 0.0033 0.0093 0.0091 0.0031
c= 1.0000 -2.7955 3.1936 -1.7316 0.3912 o 0.0295 0.0764 0.0763 0.0294 a= 3.7081 -5.3526 3.5724 -0.9280
1.0000
o o o
0 0 1.0000 0 0 1.0000 0 0
b=
0.0056 -0.0169 0.0286 -0.0104 c=
0.0333
.50C---:,~0----:2:7 o ---;:-; 3o,----:4o=---~5;:0 ---::'60
o
o
Fig. 7. Time domain signals obtained by a genetic algorithm (measurements and model output)
o
d=
For this simple dynamic process it was possible to identify a time discrete model as well as a time continuous one. The main difference was, that for the discrete time identification much more effort was needed to find a suitable input sequence to obtain acceptable, accurate results . Thereby the identification success was not visible by simulation nor clearly by validation with a similar input sequence but immediately after the implementation of the controller.
3.7455e-04
0.8732 + 0.4499i 0.8732 - 0.4499i 1.0001 0.9617
The measurement sequences of the length of 1024 are rather short for this mechanical system.
~:f· · · ·:·'-···"= I o
5
10
15
20
4. CONTROLLER DESIGN A LQ Design with special emphasis on the choice of weighting matrices is used . Starting from the root locus of the optimal LQ problem
25
"9
where
Q(Z)
a(z)
= (zI - Ar' B
IS the input-state transfer function matrix , we obtain for system description in companion form a
Fig. 6. ARMAX analysis
199
5. DESIGN OF OBSERVER
very useful connection between the coefficients of the polynomial p(Z) and the weighting matrix
The same relationship between the weighting matrix and the zeros of the associated root locus for the companion form description can be formed also for the observer normal form. Instead of transforming the system description we transform the weighting matrix Q.
Q. 2n
More
precisely
p(Z)
given
= LP;Zi
with
i=O
Q as a Hermitian
reciprocal roots we obtain Toeplitz matrix
Q=
toePlitz([P!n Pn-II /(n-l)
Given the matrix QQ with desired properties w.r.t observer normal form and the transformation matrix T between the actual state x and observer normal form state X
.. .
For example looking for root locus with three zeros at 0 and one at 0.6737 we obtain
= [0
the weighting matrix is transformed according
1
3
p(::)
x=Tx
= -2 (::-0.6737)( ;: - 0.6737) 0 0 -I
2.158 -I
and the weighting matrix
0
0 0][1
Q= T' . QQ . T
'- .. . z~ ]'
The same QQ matrix as for control design or a different one can be used, i. e.
Q is
Q=p(2)*(diag( I ,3)+diag( 1.-3))+p(3)/2*(diag([ 1 I], 2) +diag([1 1] .-2)) + p(4)/3*(diag([1 1 1],1) + diag([1 I I]. -I ))+p(5)*eye(4)/4;
p=conv([ 1 -5 1 0],[1 -2 .5 I 0]); p=[O 0 p]; forces beside the two zeros at 0 additional ones at
The corresponding root locus is then:
[roO[s([ I -5 I ]) roots([ I -2.5 I])]
controller poles
4.7913 0.2087
0 .5
2.0000 0.5000
04
The scaled Q matrix is obtained as
03 0 .2
Ob=obsv(A ,C): T=(Ob\[zeros(n-l , I); 1])';TT=T: T=[T* A';TT] ;T=[T* A':TT];T=[T* A';TT];
0.1
-0 .1
Q= T*QQ*T/norm(T);Q=Q+Q'
·0 2 ·0 3 -0 .4
with the corresponding root locus marked at points
_-le
-0 .5
. 0 10 .2 - - - j \ - - - n O.\;-2----;1 0".4 ----,, 0'T .6 ----,;-0.'0"8<----'
P =0.41 InormT p = YrlOrmT
Fig. 8. Root locus of controller design Marked are R=5 and R= 10000 leading to
observer poles 05
K(5) = [0.1792 -0.4489 K(I0000) = [1.4210 -2.9770
., 'X
0.4042 -0.1308] 2.2632 -0.6257]
04
"
" p'
0 .3 0 .2
,. 1
For R=lOOOO (expensive control energy) the open loop poles are partially used .
0.1
J i
/
- --- . ~ le;
-0.1
eig(A) = 0.8980 + 0.0794i 0.8980 - 0.0794i 0.7979 + 0.4200i 0.7979 - 0.4200i
.- -- ------
---.-
·0.2 ·0 .3 .
·0.5
.,. "'
.. -
--
.0'3. - - - - ,Oh.4----,0.... .6 - - - - ,0..... 8.L..----..J 2 --j\--colo
With cheap energy the poles converge
to
zeros of
p(Z) . Fig. 9. Root locus used during observer design
200
Lab (Derighetti, et al., 1996). Because of the closed connection of the Ctrl-Lab and Matlab rapid prototyping with the same matrix description as for design can be used .
From the above two designs we get the following feedback vectors : 1.0520 0.8254
0.4632 0.4103
reasonable
gains
L(O.4) = 1.0e+04 *[1.7458 L(4) = 1.0e+04 *[1.2973 Balancing controller:
yields
0.0299) 0.0898) for
A= [ 3.5710 -4 .9407 3.1613 -0.7916 o 1.0000 0 0 o o 1.0000 0 o 0 1.0000 0) B = [I 0 0 0) C= [0.0009 -0.0027 0.0034 -0.(013) 0= [0)
the
% ======= Observer based state controller Ar=A-H*C-B*K; Br=[H Bl: Cr=K:Db=[O 0) : [Ab,Bb,Cb,M,T) = DBALREAL(Ar.Br.Cr) ;
Ab= -0. 1086 -0.6062 -0.1681 0.6062 0.5063 -0.3004 -0. 1680 0.3003 0.6119 -0.0367 0.0288 -0.2405 Bb
K = [0.1792 -0.4489 L=1.0e+03*[8.7228 v = 12.3333 ;
0.0368 0.0291 0.2407 0.9007
tend=150: t=Ts:Ts:tend : N=length(t) ;
=
YO = [Yphi ;O:O;O): XO = YO*ky:XeO = XO; Xe = zeros(4,N+I) ; Xe(: , I) = XeO: Y = zeros(1 ,N) ; Ye = zeros(1 ,N): Uphi = zeros(i ,N+I); Uphib = zeros(I,N+I) ; Uphi(i , I) = (0); E = zeros(I.N);
9.4249 0.0044 3.1182 -0.0109 1.4052 0.0724 -0.0234 0.0679 Cb = 9.4249 -3 .1182
0.4042 -0.1308) 6.1406 3.6911 1.6615),
1.4054
0.0226 % Generating the reference signal R
A prefilter can be used for reducing the control signal amplitude :
R(1 :N I +N2) = ramp(O, up , dn . kr , Tr, rhi . rio , ramp 1. Ts, NI+N2) ; R(NI+N2+1:NI+N2+N3+N4) = ramp(R (NI+N2), up , dn, kr, Tr, rhi, rio, ramp2, Ts, N3+N4); R(N I +N2+N3+N4+ I :N I +N2+N3+N4+N5+ I) = ramp(R(N I +N2+N3+N4) , up, dn , kr, Tr, rhi , rio. ramp3, Ts, N5+1);
[Af,Bf,Cf.Df) = ZP2SS([),[.5 .5 ], I); KKg=ddcgain(Af,Bf,Cf,Df) [W ,X)=dlsim(Af,Bf.Cf,Df,V IKKg) ; The simulation results are shown in Fig . 10. The new reference signal is W .
% Real time control loop:
putnow_(TIMER_I,Ts); Ts;
0 8
6 -~
forn=I :N, yen) =putgeU[ANOUT_I) ,[Uphi(n)),[ANIN_I]) ; E(n) = Y(n)-R(n); Xe( :, n+I)= Ae*Xe(:,n)+B* Uphi(n)+L*Y(n); Uphib(n+ 1)= R(i ,n+ I )*v-K*Xe( :,n+ I) ; if Uphib(n+ I »Uhi , Uphi(n+ I )=Uhi; elseif Uphib(n+ I) < Ulo, Uphi(n+ I )=Ulo: else Uphi(n+ 1) = Uphib(n+ I); end; % Ende der Regierschleife end;
4
2
\
y
V
w"'-
0\/
V
v
-2
u
-4
-8 ·1 0
o
50
100
150
200
% set the sampling period to
250
% Graphical display of the results Ye(i :N) = C*Xe(: ,: ); figure(1 ) plot(t, Y (: ),t,R( :)); plot(t, Uphi( :)) :
300
Fig . 10. Simulation results Also loop transfer recovery techniques can be used to modify the first design and combine the two separate design steps to one.
% Save the experiment save fwctrldt t R Uphi Y Ye Xe Ts K L
The on line measurements shown in Fig . 11.
6. ON-LINE REAL TIME CONTROL
on the system
are
These results demonstrate that the design specifications can be met: No overshoot for the
The design from above with K(5) and L(4) was used directly in connection with real time Ctrl-
201
very oscillatory system and acceptable signal amplitude and settling time .
A typical result from student experiments is shown in Fig. 13 and this may be directly compared to the more elaborate design of Fig. 11 .
control
Vph l mU5 ureC! oUlput, Rphl rele rence mput Yph l measured outp ut Rphl relerenc. mput
\
so
10 0
CJ
\
>
]~.-,.,~., c
so
•
so
""-11
.
10 0
~
150
con troll er output Uph l
I SO
100
Ilme (s )
tj
controll er output Uphl
+,..._IWiI1lt_..'J _d.M'.'r
.. "..
150
tlme (s)
o
SO
100
150
tJme(s)
Fig. 11. Results of real time control Fig. 13. Typical results of a simple real time control 7 . EDUCATIONAL EXPERIENCE Students have usually no problems in finishing the task in the time given. The assignment may also be simplified by controlling speed instead of position. This simplification can be used fruitfully for the identification also . Some more experiments useful in teaching of identification and digital control can be found in Milek (1996).
The servo-system is also used for a miniproject with 4th year undergraduate students. They spend 16 hours in the laboratory and go through the entire design cycle during this time. The identification problem is solved in a similar way as presented in this paper, but a more traditional approach is taken for observer- and controller design. Following arguments from Anderson and Moore (1989) the following performance indices are used for the observer and controller design (Matlab-notation, variation of PI and P2)
Qo
= PI * b * b'·'
8. CONCLUSIONS It is shown in the paper how to combine identification and controller design methods for good performance. The consequent using of the same description leads to easy verified rapid prototyping. In combination with a graphical interpretation of identification and design steps we had obtained a powerful and easy to use tool for overall design .
Qc = P2 * c' * C-'
This design leads to an identical root distribution for controller and observer for the same weighting coefficients. Marked are roots for weights I , 100, 10000 and 1000000. With this approach, it is much more difficult to obtain well damped behaviour as follows from direct comparison with Fig. 8 and Fig. 9.
REFERENCES Anderson, B. D. 0. , 1. B. Moore (1989). Optimal Control. Prentice Hall. New Jersey . Derighetti, M ., A. H. Glattfelder, G. Peretti , X. Qiu, L. Rickenbach , W . Schaufelberger and J. Wang (1996). Laboratory Experiments for an Integrated Basic Control Course. In : Proceedings of the 13th IFAC World Congress . Vol. G . San Francisco, USA. pp 35-40. Houck, C. R., 1. Joines and M. Kay (1996). A genetic algorithm for function optimization : A Matlab implementation . ACM Transactions on Mathmatical Software. Submitted. Ljung, L. (1987) . System identification - theory for the user. Prentice Hall. New Jersey . Milek , J. (1996). A Lecture Demonstration for a Course in Digital Control. In: Proceedings of the 13th IFAC World Congress. Vol. G. San Francisco, USA. pp 13-18.
controller I observer poles
0 .5
04 0.3
02 01
-0 .1
'
..- .• .... __ .. -..,.
·0.2 ·0.3 -0.4
·0.5
.... • .... . ... .'- '"
. 0·~ . 2 ----~--~ 0 . 2~--~0~ . 4--~0~ .6----0~.8~---
Fig. 12. Root locus for a simple controller/observer design
202