MATLAB Unable to produce desired results using state-space model with observer for inverted pendulum

AI Thread Summary
The discussion revolves around creating a state-space observer for an inverted pendulum system using MATLAB code. Key points include the definition of system parameters such as mass, gravitational constant, and pendulum length, followed by the formulation of state-space matrices A, B, C, and D. The user attempts to design a state feedback controller using the "place" function to assign desired pole locations and subsequently designs an observer with a different set of poles. However, the user encounters issues with the output of the model, indicating that the implementation may not be functioning as intended. The request for assistance highlights the need for troubleshooting the code to identify potential errors affecting the observer's performance.
e0ne199
Messages
56
Reaction score
5
TL;DR Summary
I am unable to produce desired results using state-space model with observer for inverted pendulum
Hello everyone, I am trying to make a state-space observer of inverted pendulum using this code :
% Parameters of the system
M = 1.0; % Mass of the cart
m = 0.1; % Mass of the pendulum
g = 9.81; % Gravitational constant
l = 0.6; % Length of the pendulum

%for state-space block on top
A_ = [0 1 0 0;
0 0 -(m*g)/(M - m) 0;
0 0 0 1;
0 0 (g*M)/(l*(M - m)) 0];

B_ = [0;
1/(M - m);
0;
-1/(l*(M - m))];

C_ = eye(4); % Identity matrix as all states can be observed
D_ = [0;0;0;0]; % No direct feedthrough

sys2=ss(A_,B_,C_,D_)

%sys_ctrl = compreal(sys2,"c");

%A_ctrl = sys_ctrl.A
%B_ctrl = sys_ctrl.B
%C_ctrl = sys_ctrl.C
%D_ctrl = sys_ctrl.D

p= [-2 -2.5 -3 -3.5];
K=place(A_,B_,p)
pol= eig(A_-B_*K)

op = [-5 -6 -7 -8];
%op = [-1;-1;-1;-1];
L_mat=place(A_',C_',op)'

%for state-space block on bottom
A_new = A-L_mat*C_;
B_new = [B,L_mat];
C_new=eye(4);
D_new = 0;
sys3=ss(A_new,B_new,C_new,D_new)
and I connect it to this model :
xx.png

but somehow I am only able to produce this result :
zz.png

Do you know what is actually wrong with my code?? any response and help is really appreciated..thanks before
 
Back
Top