You are on page 1of 63

UESTC

Lirui@uestc.edu.cn

-
The Computer Simulation of Control System

u(t)x(t)

X ( s ) c ds

U ( s ) a bs

a,b,c,d

1a0,b=0()

c d
d
x[( k 1)T ] (
)u(kT )
u[( k 1)T ]
a aT
aT

UESTC

-
The Computer Simulation of Control System

2a0,b0

d
z (t ) x (t ) u (t )
b

z[( k 1)T ] e

a
T
b

d c
z(kT ) ( )[(1 e
b a

a
T
b

b
)
1]u(kT )
aT

d
x[( k 1)T ] z[( k 1)T ] u (kT )
b
UESTC

-
The Computer Simulation of Control System

3a =0,b0

c
d
(t ) u (t ) u (t )
x
b
b

cT
cT
z[( k 1)] z ( kT )
u( kT )
u[( k 1)T ]
2b
2b

d
x[( k 1)T ] z[( k 1)T ] u (kT )
b

UESTC

-
The Computer Simulation of Control System

z[( k 1)T ] Ez(kT ) Fu(kT ) Gu[( k 1)T ]

x[( k 1)T ] Hz[( k 1)T ] Lu (kT ) Qu[( k 1)T ]


E,F,G,H,L,Q
a,b

UESTC

-
The Computer Simulation of Control System

E,F,G,H,L,Q
a0,b0

a0,b0

a0,b0

exp[-(a/b)T]

cT/(2b)

(d/b-c/a)[(1-E)*b/(aT)-1]

(d/b-c/a)[1+
(E-1)(1+b/(aT))]

H
L

0
(c+d/T)/a

1
d/b

1
d/b

-d/(aT)

UESTC


The Computer Simulation of Control System

r2
r1

u1

x1

u2

x2

u3

x3 u 4

x4

2
x5

u5

UESTC


The Computer Simulation of Control System

-:

u1 r1
u r x x
2
1
2 2
2
x2
u3
u
x3
4

x3
u5

4 x4 x5

y x4
UESTC


The Computer Simulation of Control System

u1 0 0
u 1
2
2
u3 0 1

u4 0 0
u5 0 0

0 4
0 0
0 0
1 0
1 0

1 x1 1
0 x2 0
0 x3 0

0 x4 0
0 x5 0

0
1
r1
0
r2
0
0

y 0 0 0 1 0 x1

x2

x3

x4

x5

UESTC


The Computer Simulation of Control System

r [r1 , r2 ]

u [u1 , u2 , u3 , u4 , u5 ]

x [ x1 , x2 , x3 , x4 , x5 ]

u Wx W0 r

1
0

W0 0

0
0

(1);

0
1
0

0
0

y Wc x

(2)

0 0
1
2

W 0 1

0 0
0 0

Wc 0 0 0 1 0

0 4
0
0

0
0

1
1

0
0

1
0
0

0
0
UESTC


The Computer Simulation of Control System

1.
2.:

UESTC


The Computer Simulation of Control System

1
4-2
x

x u
s

u s
s u s

-s

u
0

us
4-2
UESTC


The Computer Simulation of Control System

MATLAB
saturation.m
function x=saturation(u,s)
if (abs(u)>=s)
if (u>0) x= s;
else x=-s; end
else x= u;
end

UESTC


The Computer Simulation of Control System

2
4-3
x

u s

x 0
u s

u s
s u s
us

-s

u
0

4-3
UESTC


The Computer Simulation of Control System

MATLAB
deadzone.m
function x=deadzone(u,s)
if (abs(u)>=s)

if (u>0) x=u-s;

else x= u+s;end
else x=0;
end

UESTC


The Computer Simulation of Control System

3
4-4 x
u(kT ) s

x(kT ) u(kT ) s
u[( k 1)T ]

u 0 x 0
u 0x 0

MATLAB

backlash.m

-s

u
0

4-4

UESTC


The Computer Simulation of Control System

function [x,u1]=backlash(u1,u,x1,s)
if (u>u1)

if ((u-s)>=x1) x=u-s;else x=x1;end


else if (u<u1)

if ((u+s)<=x1) x=u+s;else x=x1;end

else x=x1;

end
end
u1=u;
u1uk-1kx1x
k-1k

UESTC


The Computer Simulation of Control System

4
4-5
x
s

s
x
s

u0
u0

u
0

-s
4-5
UESTC


The Computer Simulation of Control System

MATLAB
sign.m
function x=sign(u,s)
if (u>0) x = s; end
if (u<0) x=- s; end

11

UESTC


The Computer Simulation of Control System


PW
W0Wc


a,b,c,d
FZs

UESTC


The Computer Simulation of Control System


FZ=0

FZ=1

FZ=2

FZ=3

FZ=4

FZ=5

FZ=6

FZ=7

FZ=8

x
UESTC


The Computer Simulation of Control System

FZs
P

a1 b1 c1 d1 FZ1 s1
a b c d FZ s
2
2
2
2
2
2

an bn cn d n FZ n sn

UESTC


The Computer Simulation of Control System


x(i)





P,

W,W0 Wc
Tf
h

x(i)


E,F,G,H,L,Q


u(i)

x(i)
Y
u(i)

y
t=t+h

N
N

t=Tf
Y

UESTC


The Computer Simulation of Control System

1 4-7,
y
r =10

+
-

s 0.5
s 0.1

1
s

2
s2

10
s 10

4-7

UESTC


The Computer Simulation of Control System

0
1
W
0

0
Wc [0

0.1
0
P
2

10

0 0 1
1

0 0 0
0

, W0
0
1 0 0


0 1 0
0
0 0 1]

1 0.5 1 3 1

1 1 0 0 0
1 2 0 0 0

1 10 0 0 0

UESTC


The Computer Simulation of Control System

Tf=10
h=0.025
MATLAB

UESTC


The Computer Simulation of Control System

r = 10;
P = [0.1 1 0.5 1 3 1; 0 1 1 0 0 0; 2 1 2 0 0 0; 10 1 10 0 0 0];
W = [0 0 0 -1; 1 0 0 0; 0 1 0 0; 0 0 1 0];
W0 = [1; 0; 0; 0];
Wc = [0 0 0 1];
Tf = input('Simulation Time Tf = ');
T = input('Step Time h = ');

A = P(:, 1); B = P(:, 2); C = P(:, 3); D = P(:, 4);


FZ = P(:, 5); S = P(:, 6);
n = length(A);

UESTC


The Computer Simulation of Control System

for i = 1: n
if (A(i) ~= 0)
if (B(i) == 0)
E(i) = 0; F(i) = 0; G(i) = 0; H(i) = 0;

L(i) = (C(i) + D(i) / T) / A(i);


Q(i) = -D(i) / (A(i) * T);
else
E(i) = exp(-A(i) * T / B(i));
F(i) = (D(i) / B(i) - C(i) / A(i)) * ((1 - E(i)) * B(i) / (A(i) * T)

- 1);

UESTC


The Computer Simulation of Control System

G(i) = (D(i) / B(i) - C(i) / A(i)) * (1 + (E(i) - 1) * (1 + B(i) / (A(i) * T)));


H(i) = 1; L(i) = D(i) / B(i); Q(i) = 0;
end
else
if (B(i) ~= 0)
E(i) = 1;
F(i) = 0.5 * C(i) * T / B(i);

G(i) = F(i); H(i) = 1;


L(i) = D(i) / B(i); Q(i) = 0;
UESTC


The Computer Simulation of Control System

else
disp('A(i) = B(i) = 0');
end

end
end

UESTC


The Computer Simulation of Control System

x = [zeros(length(A), 1)]; x0 = x; z = x;
u = [zeros(length(A), 1)]; u0 = u;
y = [zeros(length(Wc(:, 1)), 1)]; t = 0;
for j = 1: Tf / T
u1 = u; u = W * x + W0 * r;
for i = 1: n
if (FZ(i) ~= 0)

if (FZ(i) == 1)
u(i) = saturation(u(i), S(i));
end

UESTC

if (FZ(i) == 2)

The Computer Simulation of Control System

u(i) = deadzone(u(i), S(i));


end

if (FZ(i) == 3)
[u(i), u0(i)] = backlash(u0(i), u(i), u1(i), S(i));
end
if (FZ(i) == 4)
u(i) = sign1(u(i), S(i));

end
end
end
UESTC

x1 = x;
for i = 1: n

The Computer Simulation of Control System

z(i) = E(i) * z(i) + F(i) * u(i) + G(i) * u1(i);


x(i) = H(i) * z(i) + L(i) * u(i) + Q(i) * u1(i);
end
for i = 1: n

if (FZ(i) ~= 0)
if (FZ(i) == 5)
x(i) = saturation(x(i), S(i));

end
if (FZ(i) == 6)
x(i) = deadzone(x(i), S(i));
end

UESTC

if (FZ(i)
== 7)
5
[x(i), x0(i)] = backlash(x0(i), x(i), x1(i), S(i));

The Computer Simulation of Control System

end
if (FZ(i) == 8)
x(i) = sign1(x(i), S(i));
end
end
end

y = [y, Wc * x]; t = [t, t(j) + T];


end
plot (t, y)
% axis([0 Tf 0 20]);

UESTC


The Computer Simulation of Control System

UESTC

Simulink
The Computer Simulation of Control System

3. Simulink

UESTC

Simulink
The Computer Simulation of Control System

Backlash:
Coulomb&Viscous Friction:
Dead Zone:
Dead Zone Dynamic:
Hit Crossing:

Quantizer:
Rate Limiter:
UESTC

Simulink
The Computer Simulation of Control System

Rate Limiter Dynamic:


Relay:
Saturation:
Saturation Dynamic:

Wrap To Zero:

UESTC

Matlab/Simulink
The Computer Simulation of Control System

2 Simulink
10.5

1SimulinklibraryFile|New,
Simulink

2
Sine,Scope,Mux Dead Zone

UESTC

Matlab/Simulink
The Computer Simulation of Control System

3
Start of
dead zone-0.5, End of dead zone0.5

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

4. Matlab/Simulink
3
r(t)
-

G1(s)

G2(s)

G3(s)

c(t)

-N

G1 ( s) 5, G2 ( s)

1
1
, G3 ( s ) ,
0.5s 1
s

x 2 x 2

y 0
x 2
x 2 x 2

Simulink

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

plot(t,c)
xlabel('t');ylabel('c(t)')

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

Matlab/ Simulink
1MatlabSimulink

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

Simulink

UESTC

Matlab/Simulink
The Computer Simulation of Control System

0.05-0.05
out1
0.1-0.1
out20.20.2out3
0. 5-0. 5
out4

UESTC

Matlab/Simulink
The Computer Simulation of Control System

plot(tout1,out1,tout2,out2,tout3,out3,tout4,out4);
gtext('0.05');
gtext('0.1');
gtext('0.2');
gtext('0.5')

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

UESTC

Matlab/Simulink
The Computer Simulation of Control System

:
0

UESTC

UESTC

Lirui@uestc.edu.cn

You might also like