error in discrete space state depeding on coefficient

1 次查看(过去 30 天)
Im trying to make a space-state controller and there is a problem.
I refered to here: https://ctms.engin.umich.edu/CTMS/index.php?example=MotorPosition&section=SystemModeling
There was no problem with continuous state-space open loop response based on transfer function, and discrete space-state, at first.
But i encountered with a problem that the response of discrete state-space doesnt work properly when using another values at J,b,K, etc, of motor.
Here is my code.
This works properly:
--------------------------------------------------------------------------------------------------------------------------------
clc;clear;
J = 0.01;
b = 0.1;
K = 0.01;
R = 1;
L = 0.5;
A = [-b/J K/J
-K/L -R/L];
B = [0
1/L];
C = [1 0];
D = 0;
sys=ss(A,B,C,D);
step(sys)
title('Continuous SS')
x=[0 0]';
u=heaviside(1);
Ts=0.1;
t=Ts:Ts:140;
for i=1:1400
x=(A*Ts+eye(2))*x+B*Ts*u;
y(i)=x(1);
end
plot(t,y)
xlim([0 3.5])
title('Discrete SS')
--------------------------------------------------------------------------------------------------------------------------------
And this fails.
--------------------------------------------------------------------------------------------------------------------------------
clc;clear;
J = 3.2284E-6;
b = 3.5077E-6;
K = 0.0274;
R = 4;
L = 2.75E-6;
A = [-b/J K/J
-K/L -R/L];
B = [0
1/L];
C = [1 0];
D = 0;
sys=ss(A,B,C,D);
step(sys)
title('Continuous SS')
x=[0 0]';
u=heaviside(1)
Ts=0.1;
t=Ts:Ts:140;
for i=1:1400
x=(A*Ts+eye(2))*x+B*Ts*u;
y(i)=x(1);
end
plot(t,y)
title('Discrete SS')
And this problem disturbs me to make state observer, ESO, disturbance compensate at my project by simulink.

采纳的回答

Paul
Paul 2025-6-9
Hi SUENGTAE,
In the first case we have:
J = 0.01;
b = 0.1;
K = 0.01;
R = 1;
L = 0.5;
A = [-b/J K/J
-K/L -R/L];
The eigenvalues of the A matrix are
eig(A)
ans = 2×1
-9.9975 -2.0025
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
The eigenvalues of the discretized system are
Ts = 0.1;
eig(eye(2)+A*Ts)
ans = 2×1
0.0003 0.7997
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
The sampling period, Ts, is small enough so that the discretized system is stable (all poles are inside the unit circle), though Ts = 0.1 still feels too large to accurately represent the dynamics when the fastest pole has time constant of 1/9.9975, which is also 0.1.
In the other case
J = 3.2284E-6;
b = 3.5077E-6;
K = 0.0274;
R = 4;
L = 2.75E-6;
A = [-b/J K/J
-K/L -R/L];
eig(A)
ans = 2×1
1.0e+06 * -0.0001 -1.4545
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
The dynamics are much faster and the sampling period isn't nearly small enough to maintain stability after discretization
eig(eye(2)+A*Ts)
ans = 2×1
1.0e+05 * -0.0000 -1.4545
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
  1 个评论
SUENGTAE
SUENGTAE 2025-6-9
Paul, Thank you!
I verified my code according to your great advice.
Unfortunately, I have more extreme system coefficient than case 2.
I tried to change simulink solver's sample time smaller and smaller.
Improved results in the graph but still it can't get stability even at Ts=1e-9.
If it requires smaller sampling time than 1e-9 or something, simulink and my processor(ESP-32) seems not to be able to endure that condition.
Anyway, Thank you for your help.

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by