Upload
nam2203
View
40
Download
5
Embed Size (px)
Citation preview
M A T L A BM A T L A B
Modern Control System Lab. Changwon National University
C t t P d l - Cart type Pendulum
Modern Control System Lab. Changwon National University
cx FM m ml x
2 mgl fml ml I 1 1
2
cx Fx M m mlmgl fml ml I
2
2 2 2
1( )( )
cx Fx ml I mll fM l I l l M
2 2 2( )( ) mgl fM m ml I m l ml M m
Modern Control System Lab. Changwon National University
22 2 2
1( )( )
cx Fx ml I mlmgl fM m ml I m l ml M m
2
2 2 2
( )( ) ( )1( )( ) ( ) ( )( )
x ml I cx F ml mgl fM l I l l F M l f
2 2 2( )( ) ( ) ( )( )M m ml I m l ml cx F M m mgl f
2 2 2 2
2 2 2
( ) ( )1( )( ) ( ) ( )
x c ml I x m l g mlf ml I FM m ml I m l cmlx mgl M m M m f mlF
Modern Control System Lab. Changwon National University
2 2 2 2
2 2 2
( ) ( )1x c ml I x m l g mlf ml I F
2 2 2( )( ) ( ) ( )M m ml I m l cmlx mgl M m M m f mlF 5, 1, 1, 9.8, 0.01, 0.01, 0.02M m l g c f I 5, 1, 1, 9.8, 0.01, 0.01, 0.02M m l g c f I
0.0102 9.8 0.01 1.021x x F
6.012 0.01 58.8 0.06x F
Modern Control System Lab. Changwon National University
C t t P d l - Cart type Pendulum
0.0102 9.8 0.01 1.021x x F
6.012 0.01 58.8 0.06x F
Scope
1s
Integrator1
1s
Integrator
f(u)
Fcn
Scope1
1s
Integrator3
1s
Integrator2
-K-
Gain
f(u)
Fcn1
0
Constant
Modern Control System Lab. Changwon National University
11f(u)
Scope
s
Integrator1
s
Integrator
( )
Fcn
0
Scope1
1s
Integrator3
1s
Integrator2
-K-
Gain
f(u)
Fcn1Constant
Modern Control System Lab. Changwon National University
11f(u)
Scope
s
Integrator1
s
Integrator
( )
Fcn
0
Scope1
1s
Integrator3
1s
Integrator2
-K-
Gain
f(u)
Fcn1Constant
Modern Control System Lab. Changwon National University
11f(u)
Scope
s
Integrator1
s
Integrator
( )
Fcn
0
Scope1
1s
Integrator3
1s
Integrator2
-K-
Gain
f(u)
Fcn1Constant
Modern Control System Lab. Changwon National University
11f(u)
Scope
s
Integrator1
s
Integrator
( )
Fcn
0
Scope1
1s
Integrator3
1s
Integrator2
-K-
Gain
f(u)
Fcn1Constant
Modern Control System Lab. Changwon National University
11f(u)
Scope
s
Integrator1
s
Integrator
( )
Fcn
0
Scope1
1s
Integrator3
1s
Integrator2
-K-
Gain
f(u)
Fcn1Constant
Modern Control System Lab. Changwon National University
Modern Control System Lab. Changwon National University
M A T L A BM A T L A B
Modern Control System Lab. Changwon National University
( ,0)r( 0)r( ,0)r
l = 5;r = 0.1;
l [ 10 10 10 10]x_plane = [-10 -10 10 10];y_plane = [-0.6 -0.5 -0.5 -0.6];x_cart = [-1 -1 1 1];y_cart = [-0.5 0.5 0.5 -0.5];
l [ ]
( , )r l
x_pole = [-r -r r r];y_pole = [-l 0 0 -l];plane = fill(x_plane, y_plane, 'k');
id( , )r l grid onhold on
cart = fill(x_cart, y_cart, 'g','EraseMode','normal');pole = fill(x_pole, y_pole, 'b','EraseMode','normal');h ld ffhold offaxis([-10 10 -8 4]);
Modern Control System Lab. Changwon National University
cos , sinl l ( ,0)r
( 0)r
cos , sinl l cos , sinl l
( ,0)r
1tan rl
l
( , )r l
1 13 3cos tan , sin tan2 2
r rl ll l
( , )r l
1 13 3cos tan , sin tan2 2
r rl ll l
Modern Control System Lab. Changwon National University
l = 5;r = 0.1; 4
x_plane = [-10 -10 10 10];y_plane = [-0.6 -0.5 -0.5 -0.6];x_cart = [-1 -1 1 1];y_cart = [-0.5 0.5 0.5 -0.5];x pole = [-r -r r r]; 0
2
x_pole = [-r -r r r];y_pole = [-l 0 0 -l];plane = fill(x_plane, y_plane, 'k');grid onh ld
-2
hold oncart = fill(x_cart, y_cart, 'g','EraseMode','normal');pole = fill(x_pole, y_pole, 'b','EraseMode','normal');hold offaxis([-10 10 -8 4]); -6
-4
([ ])t = 0:0.01:20*pi/180;for t = 0:0.01:20*pi/180
updatedX cart = x cart + t;-10 -8 -6 -4 -2 0 2 4 6 8 10
-8
updatedX_cart = x_cart + t;temp_x = [l*cos(3/2*pi+t-atan(r/l)) r*cos(pi+t) r*cos(t) l*cos(3/2*pi+t+atan(r/l))];temp_y = [l*sin(3/2*pi+t-atan(r/l)) r*sin(pi+t) r*sin(t) l*sin(3/2*pi+t+atan(r/l))];updatedX_pole = t + temp_x;updatedY_pole = temp_y;
t( t 'Xd t ' d t dX t)set(cart, 'Xdata', updatedX_cart);set(pole, 'Xdata', updatedX_pole,'Ydata', updatedY_pole);drawnow;for i=1:5000000
Modern Control System Lab. Changwon National University
temp = i;end
end
M A T L A BM A T L A B
Modern Control System Lab. Changwon National University
Scope
1s
Integrator1
1s
Integrator
f(u)
Fcn
1s
1s
-K-f(u)0
Constant
Click HereTerminator
Scope1
MATLABFunction
Integrator3Integrator2 GainFcn1
pole
cart
TerminatorMATLAB Fcnp
Modern Control System Lab. Changwon National University
1s
1s
f(u)
Scope
11
Integrator1Integrator
Kf( )
Fcn
0
Scope1
MATLAB
1s
Integrator3
1s
Integrator2
-K-
Gain
f(u)
Fcn1
cart
Constant
Click HereTerminator
MATLABFunction
MATLAB Fcnpole
Modern Control System Lab. Changwon National University
Modern Control System Lab. Changwon National University
l = 5;r = 0.1;x plane = [-10 -10 10 10];x_plane [ 10 10 10 10];y_plane = [-0.6 -0.5 -0.5 -0.6];x_cart = [-1 -1 1 1];y cart = [-0.5 0.5 0.5 -0.5];y_ca t [ 0.5 0.5 0.5 0.5];x_pole = [-r -r r r];y_pole = [-l 0 0 -l];plane = fill(x_plane, y_plane, 'k');p ( p y p )grid onhold oncart = fill(x_cart, y_cart, 'g','EraseMode','normal');pole = fill(x_pole, y_pole, 'b','EraseMode','normal');hold offaxis([-10 10 -8 4]);
Modern Control System Lab. Changwon National University
1s
1s
f(u)
Scope
11
Integrator1Integrator
Kf( )
Fcn
0
Scope1
MATLAB
1s
Integrator3
1s
Integrator2
-K-
Gain
f(u)
Fcn1
cart
Constant
Click HereTerminator
MATLABFunction
MATLAB Fcnpole
Modern Control System Lab. Changwon National University
1s
1s
f(u)
Scope
11
Integrator1Integrator
Kf( )
Fcn
0
Scope1
MATLAB
1s
Integrator3
1s
Integrator2
-K-
Gain
f(u)
Fcn1
cart
Constant
Click HereTerminator
MATLABFunction
MATLAB Fcnpole
Modern Control System Lab. Changwon National University
Modern Control System Lab. Changwon National University
function y = test1(pos cart theta cart pole)function y = test1(pos_cart, theta, cart, pole)l = 5;r = 0.1;r 0.1;x_cart = [-1 -1 1 1];updatedX cart = x cart + pos cart;p _ _ p _ ;temp_x = [l*cos(3/2*pi+theta-atan(r/l)) r*cos(pi+theta) r*cos(theta) l*cos(3/2*pi+theta+atan(r/l))];temp_y = [l*sin(3/2*pi+theta-atan(r/l)) r*sin(pi+theta) r*sin(theta) p y p pl*sin(3/2*pi+theta+atan(r/l))];updatedX_pole = pos_cart + temp_x;updatedY_pole = temp_y;set(cart, 'Xdata', updatedX_cart);set(pole, 'Xdata', updatedX_pole,'Ydata', updatedY_pole);drawnow;y = 1;
Modern Control System Lab. Changwon National University
Modern Control System Lab. Changwon National University
Modern Control System Lab. Changwon National University
Modern Control System Lab. Changwon National University
M A T L A BM A T L A BLQR
Modern Control System Lab. Changwon National University
LQR - LQR
0 0102 9 8 0 01 1 021x x F 0.0102 9.8 0.01 1.0216.012 0.01 58.8 0.06
x x Fx F
0 1 0 0 0x x 0 0.0017 1.6301 0.0017 0.16970 0 0 1 0
x xF
0 0.0017 9.7804 0.01 0.1663 A BA B
Modern Control System Lab. Changwon National University
0 1 0 0 0 0 1 0 0 00 0.0017 1.6301 0.0017 0.1697
,0 0 0 1 0
A B
0 0 0 1 00 0.0017 9.7804 0.01 0.1663
1 0 0 00 0 0 0 0 0 0 0 , 0.010 0 5 00 0 0 0
Q R 0 0 0 0
K = lqr(A,B,Q,R)
Modern Control System Lab. Changwon National University
>> A = [0 1 0 0; 0 -0.0017 -1.6301 -0.0017; 0 0 0 1; 0 -0.0017 -9.7804 -0.01];[ ; ; ; ];>> B = [0 0.1697 0 0.1663]';>> Q = [1 0 0 0; 0 0 0 0; 0 0 5 0; 0 0 0 0];>> R = 0.01;>> K=lqr(A,B,Q,R)K =
10.0000 13.0808 12.7367 3.2320
Modern Control System Lab. Changwon National University
Click HereClick Here
Scope
1s
Integrator1
1s
Integrator
f(u)
Fcn p
1s
1s
-K-f(u)
T i
Scope1
MATLABFunction
Integrator3Integrator2
Gain1
GainFcn1
cart
TerminatorMATLAB FcnK*u pole
Modern Control System Lab. Changwon National University
Click HereClick Here
Scope
1s
Integrator1
1s
Integrator
f(u)
Fcn p
1s
1s
-K-f(u)
T i
Scope1
MATLABFunction
Integrator3Integrator2
Gain1
GainFcn1
cart
TerminatorMATLAB FcnK*u pole
Modern Control System Lab. Changwon National University
Modern Control System Lab. Changwon National University
Modern Control System Lab. Changwon National University
2Click Here
11f( )
Scope
s
Integrator1
s
Integrator
f(u)
Fcn
Scope1
1s
Integrator3
1s
Integrator2
-K-
Gain
f(u)
Fcn1
Terminator
Scope2 MATLABFunction
MATLAB FcnK*u
Gain1
pole
cart
Modern Control System Lab. Changwon National University
2Click Here
11f( )
Scope
s
Integrator1
s
Integrator
f(u)
Fcn
Scope1
1s
Integrator3
1s
Integrator2
-K-
Gain
f(u)
Fcn1
Terminator
Scope2 MATLABFunction
MATLAB FcnK*u
Gain1
pole
cart
Modern Control System Lab. Changwon National University
2Click Here
11f( )
Scope
s
Integrator1
s
Integrator
f(u)
Fcn
Scope1
1s
Integrator3
1s
Integrator2
-K-
Gain
f(u)
Fcn1
Terminator
Scope2 MATLABFunction
MATLAB FcnK*u
Gain1
pole
cart
Modern Control System Lab. Changwon National University
Click Here
Signal 1
Signal Builder
1s
Integrator1
1s
Integrator
f(u)
Fcn
Scope1
Scope
1s
Integrator3
1s
Integrator2
-K-
Gain
f(u)
Fcn1
Terminator
Scope2
Scope1
MATLABFunction
MATLAB Fcn
Integrator3Integrator2
K*u
Gain1
GainFcn1
l
cart
MATLAB Fcnpole
Modern Control System Lab. Changwon National University
22.5Signal 1
test/Signal Builder : Group 1
0.5
1
1.5
-1
-0.5
0
2 5
-2
-1.5
1
0 2 4 6 8 10 12 14 16 18 20 22-2.5
Time (sec)
Modern Control System Lab. Changwon National University
Modern Control System Lab. Changwon National University