Discrepancies in LQR controller for continuous and discrete time.
23 次查看(过去 30 天)
显示 更早的评论
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 个评论
Wooshik Kim
2018-7-5
Rather than changing integrator block to discrete form you can simulate discrete-time model by changing the sample time of the controller. https://www.mathworks.com/videos/getting-started-with-simulink-part-8-modeling-continuous-and-discrete-systems-in-one-simulink-model-1508446587027.html
回答(1 个)
Cesar Antonio Lopez Segura
2018-8-31
编辑:Cesar Antonio Lopez Segura
2018-8-31
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!