Professional Documents
Culture Documents
Control Review 1
Paulo Garrido
Departamento de Eletrónica
Escola de Engenharia da Universidade do Minho
dx
= Ax + Bu
dt
y = Cx + Du
F – fulcrum SR1
B
R – wheels SP2 E SP1
SR2M
Gr K m Gr2 K m2
fm = u− 2 v
Rr Ra Rr Ra
u – DC motor supply voltage; v – cart velocity
Gr – transmission ratio from the motor axis to the wheel axis
Rr – wheel radius
Ra – DC motor armature resistance
Km – gain from DC motor armature current to torque
(Lm)2 g J + L2 m
aa,θ =− ba, f =
J ( M + m) + L2 mM J ( M + m) + L2 mM
Lmg( M + m) Lm
aα ,θ = bα , f = −
J ( M + m) + L2 mM J ( M + m) + L2 mM
Gr K m Gr2 K m2
k f ,u = k f ,v =− 2
Rr Ra Rr Ra
⎡ x! ⎤ ⎡⎢ 0 0 1 0 ⎤⎡
⎥⎢ x ⎤ ⎡⎢ 0 0 ⎤
⎥
⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥⎡ ⎤
⎢ θ! ⎥ ⎢ 0 0 0 1 ⎥⎢ θ ⎥ ⎢ 0 0 ⎥⎢ u ⎥
⎢ ⎥=⎢ ⎥⎢ ⎥+⎢ b k ⎥⎢ ⎥
⎢ v! ⎥ ⎢ 0 a a ,θ ba , f k f ,v 0 ⎥⎢ v ⎥ ⎢ a , f f ,u ba , f ⎥ ⎢⎣ f e ⎥⎦
⎢ ⎥ ⎢ ⎥ ⎥ ⎢ ⎥
⎢ ω! ⎥ ⎢ 0 a α,θ bα, f k f ,v 0 ⎥ ⎢⎣ ω ⎥⎦ ⎢ bα, f k f ,u bα, f ⎥
⎣ ⎦ ⎣ ⎦ ⎣ ⎦
Exercise 1
a) (Easy) Check that the above state equation is correct,
given the expression for fm.
b) (Hard) Derive the expression for fm as a function of u
and v.
22/09/20 Digital control review 7
Declaring the model in Scilab – scalars
clear // To avoid errors in simula7on
//Nominal con7nuous 7me model
g=9.8; // Gravity
M=10; // Cart mass
m=0.25; // Pendulum mass
L=0.5; // Distance from the center of mass to the fulcrum
J=m*(2*L)^2/12 // Moment of iner7a referred to center of mass
fator=J*(M+m)+L^2*m*M
aa=-(L*m)^2*g/fator; aalfa=L*m*g*(M+m)/fator
ba=(J+L^2*m)/fator; balfa=-L*m/fator
sz=size(A);dimx=sz(1,1)
I=eye(dimx,dimx)
sz=size(C); dimy=sz(1,1)
pend_c=syslin('c',A,B,C);
disp(spec(A),"Nominal model poles in s:")
• dim(H) = o×m
• The command variable in discrete time u(kh) is assumed to be set at the same
instants where the output variable y(t) is sampled to y(kh).
• The D/A converter is assumed to work as a first-order hold: kh ≤ t < kh+h,
u(t) = u(kh). Then u(t) is a sequence of rectangular impulses.
• Exercise: discuss how this general model fits the control of the inverted
pendulum on cart
22/09/20 Digital control review 12
General expression of the state evolu7on;
matrix transfer func7on
−1 −1
X(s ) = (s I− A) x(0)+(s I− A) BU(s )
t
x(t ) = e x(0)+ ∫ e
At A( t−τ )
Bu(τ )d τ
0
= e Ah x(kh)+ ∫ e Aτ d τ Bu(kh)
0
= Φ(h)x(kh)+ Γ(h)u(kh)
⎧⎪x(k +1) = Φx(k)+ Γu(k)
• Taking h implicitly, the model is written:
⎪⎨
⎪⎪⎩ y(k) = Cx(k)+ Du(k)
⎡ 1 1 ⎤
h ∈ ⎢⎢ , ⎥
⎥
⎢⎣ 10 s max
4 s max ⎥⎦
T=1/(max(abs(spec(A))))
h=round(1000*(T/Ns))/1000 //Ns samples in T
disp(h,"Sampling period:")
pend_d=dscr(pend_c,h)
Fi=pend_d(2)
Gama=pend_d(3)
Gamau=Gama(:,1)
Gamap=Gama(:,2)
disp(Fi, 'Fi')
disp(Gama, 'Gama')
22/09/20 Digital control review 17
Pulse transfer operator of state space
model
y(k) = H(q)u(k)
= (C(q I−Φ)−1 Γ + D )u(k)
−1 −1
X(z ) = (zI −Φ) zx(0)+ (zI −Φ) ΓU(z )
−1 ⎡ −1 ⎤
Y(z ) = C (zI −Φ) zx(0)+ ⎢C (zI −Φ) Γ + D ⎥ U(z )
⎣ ⎦
• The pulse transfer function and the pulse transfer operator can
be reciprocally obtained by substituting q for z or z for q:
H(z ) = H(q)|q is changed to z H(q) = H(z )|z is changed toq
• The technical name for this is that they are isomorphic. They
have the same form, but different meaning.
Hpend_d=clean(C*inv(z*I-Fi)*Gamau)
disp(Hpend_d,"Hpend_d")
Hpend_dzpk=zpk(pend_d)
disp(Hpend_dzpk,"Hpend_dzpk")
Res < 0 → z = 1
s = jω → z = 1
Res > 0 → z = 1
• The projection is periodic along the jω axis with period ωs. All
the points s = σ+j(ω+kωs) project on the same z.
∃z i , z i >1
∨ ← unstable
∃z i , z i = 1∧ m(z i ) >1
x(nh) = Φn x(0)+WcU
U = Wc−1 ⎡⎢ x(nh)−Φn x(0)⎤⎥
⎣ ⎦
22/09/20 Digital control review 27
Criterion to choose the eigenvalues of Φf
K−1
• Performance measures: J x = ∑ x (k)
2
u_sat_plus=10; u_sat_minus=-10
N=round(1000*(p/h))/1000+1
tk=0:h:(N-1)*h
//Ini7al values
xk=x0
//External inputs
p=p_amp*ones(1,N) //Disturbance
for k=0:1:N-1
//Inputs calcula7on
pk=p(k+1)
//Measurement noise and measurement
nk=kn.*rand(dimx,1); xmk=xk+nk
//Calcula7on of command
uk=-L*xmk
if satura7on_enable==1 then
if uk>u_sat_plus then uk=u_sat_plus end
if uk<u_sat_minus then uk=u_sat_minus end
end
22/09/20 Digital control review 32
//Calcula7on of next state
xkplus1=Fi*xk+Gama*[uk pk]’
//Storing values
u(:,k+1)=uk;
x(:,k+1)=xk;
n(:,k+1)=nk
//Shit for next itera7on
xk=xkplus1;
end
Jx=h*sum(x.*x,"c")
disp(Jx, "Jx: [ x teta v omega]")
Ju=h*sum(u.*u,"c")
disp(Ju, "Ju")
• Because it is not easy to measure all state variables, one can use estimates of
their values generated instead. How does performance degrade?
Y = Wo x(0)
x(0) = Wo−1Y
22/09/20 Digital control review 46
Criterion to choose the eigenvalues of Φe
K=ppol(Fi',C',poles_zo)
K=K'
disp(K,'Observer feedback gains:')
xk=x0
xok=zeros(dimx,1) //Es7mator ini7al state
//Calcula7on of command
uk=-L*xok
if satura7on_enable==1 then
if uk>u_sat_plus then uk=u_sat_plus end
if uk<u_sat_minus then uk=u_sat_minus end
end
nk=kn.*rand(dimy,1)
yk=C*xk+nk // measured y
yok=C*xok // es7mated y
xokplus1 = Fi*xok+Gamau*uk+K*(yk-yok) //es7mate for next k
xkplus1=Fi*xk+Gama*[uk pk]'
//Storing values
u(:,k+1)=uk
x(:,k+1)=xk
xo(:,k+1)=xok
n(:,k+1)=nk
//Shit for next itera7on
xk=xkplus1
xok=xokplus1
…
scf(2)
clf
e=x-xo
drawlater()
b=gca();
plot(tk',clean(e)')
Je=h*sum(e.*e,"c")
disp(Je, "Je")