error in discrete space state depeding on coefficient
8 views (last 30 days)
Show older comments
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§ion=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.
0 Comments
Accepted Answer
Paul
on 9 Jun 2025
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)
The eigenvalues of the discretized system are
Ts = 0.1;
eig(eye(2)+A*Ts)
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)
The dynamics are much faster and the sampling period isn't nearly small enough to maintain stability after discretization
eig(eye(2)+A*Ts)
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!