Discrepancies in LQR controller for continuous and discrete time.

18 visualizzazioni (ultimi 30 giorni)
Hi,
I am having some problems designing a LQR controller due to inconsistencies with the controller in continuous and discrete form.
I have a continuous system with the following A,B,C and D matrices.
A = [0 0 0 1 0 0; 0 0 0 0 1 0; 0 0 0 0 0 1; 0 0 0 0 0 0; 0 0 0 0 0 0; 0 0 0 0 0 0]
B = [0 0 0 0; 0 0 0 0; 0 0 0 0; 0 0.0202 0 -0.0202; -0.0202 0 0.0202 0; -0.0053 0.0053 -0.0053 0.0053]
C = [0 0 1 0 0 0; 0 -9.8 0 0 0 0; 9.8 0 0 0 0 0; 0 0 0 0 0 0]
D = [0 0 0 0; 0 0 0 0; 0 0 0 0; -0.0096 -0.0096 -0.0096 -0.0096]
And with the following Q and R matrices.
Q = eye(6)*1e5;
R = eye(4);
Using the lqr function, I am able to find K matrix, and verify that the system is stable.
[K S e] = lqr(A,B,Q,R);
eigs(A-B*K)
ans =
-1.0063
-1.0063
-1.0534
-3.1822
-8.9775
-8.9775
This is further verified on Simulink using the following model where my system reaches equilibrium.
The problem is that I want to implement this controller in an on-board embedded digital microprocessor, thus the system needs to be discretized.
First, I convert the system into its discrete form with the c2d function
sys_ss = ss(A,B,C,D);
Ts = 1/100; % Sample time
[sys_d, G] = c2d(sys_ss,Ts,'zoh'); % Discrete system
Ad = sys_d.a;
Bd = sys_d.b;
Cd = sys_d.c;
Dd = sys_d.d;
Then, I calculate K with the discrete lqr function, dlqr.
[K S e] = dlqr(Ad,Bd,Q,R);
Everything seems fine, but when I try to verify the system in Simulink, the system never reaches equilibrium.
Both integrators have an initial condition of [1 1 0 1 1 1]. The continuous Simulink file is using the ode45 solver, while the discrete file is using the Fixed Step Discrete solver.
I have tried different approaches, but so far I have not been able to find any solution or reason why the system is working in continuous but not on discrete implementation. Any assistance would be greatly appreciated.
Thank you.
Saul
  3 Commenti
Saul Armendariz
Saul Armendariz il 20 Giu 2018
Hi Aquatris,
Reducing the step size does not helps with the stability, but the output values are reduce.
(Step Size = 1)
(Step Size = 1/10)
I have also tried reducing the sample size before converting to discrete time, with similar results. The output values are reduced greatly, but the instability persists.
(Sample Time = 1/10)
Any other idea of what might be happening?
Thank you

Accedi per commentare.

Risposte (1)

Cesar Antonio Lopez Segura
Modificato: Cesar Antonio Lopez Segura il 31 Ago 2018
Hi Saul,
To analyze your question I create two Simulink models. The first one is an open loop plant and second one is a close loop plant.
Below the open loop plant (name OpenLQ):
Below the close loop plant (name CloseLQ):
When the Simulink open plant run without errors, it is possible to study open loop response with continuous time domain point of view.
I use this code:
linsys1 = d2c( linearize('openLQ'),'tustin' )
[V,D] = eig( linsys1.A );% compute eigenvalues
[Wn,zeta] = damp(diag(D)); % damp
damp(diag(D))
Is show below that your open loop plant is unstable (real part is positive and damping factor negative):
Here you can define K feedback optimal state control.
Now, run this code:
dOpenPlant = linearize('openLQ');
Q = eye(6).*[ 1e20 1e20 1e15 1e1 1e1 1e20 ]'
R = eye(4).*[ 1 1 1 1]'
[K S e] = dlqr( dOpenPlant.A,dOpenPlant.B,Q,R )
When the optimal K value is compute it is necessary to study the 'e' value from [K S e].
As you can see, all modes are inside unit circle (stable discrete system)
Now, you can analyze your close loop system in continuous time domain:
linsys1 = d2c( linearize('closeLQ'),'tustin' )
[V,D] = eig( linsys1.A )% compute eigenvalues
[Wn,zeta] = damp(diag(D)); % damp
damp(diag(D))
Real part is not positive and damping factor is 1. It mean that your discrete system is stable (from continuous time domain point of view).
Now, I run close loop discrete Simulink system, t = 10s. As you can see states are stable.

Prodotti


Release

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by