lqr controller with saturation for closed loop system

Hi, I want to add saturation to regulate the output of the lqr controller. I wonder how to add saturation and wanna check if the input to the plant is really regulated in between +-1. I also tried simulink but it shows not desired results.
I'll really appreciate if you can help. thanks!
the code for lqr is below:
% LQR
%%%%%%%%%%
s = tf('s');
Gs = 4000/(s*(s+10)*(s+20));
[A,B,C,D]=tf2ss(Gs.Numerator{1}, Gs.Denominator{1});
st = 0.06;
Gd=c2d(Gs,st);
[Ad,Bd,Cdl,Ddl]=tf2ss(Gd.Numerator{1}, Gd.Denominator{1});
Q = blkdiag(0.1,0.1,100);
R =0.001;
[K,P]=dlqr(Ad,Bd,Q*st,R/st);
sys12 = ss(Ad-Bd*K,Bd,Cdl,Ddl,st);
N12=1/dcgain(sys12);
sysfin = ss(Ad-Bd*K,Bd*N12,Cdl,Ddl,st);
figure;
step(sysfin)

3 Comments

This is an interesting problem when using the functions from the Control System Toolbox. I need some time to think. By the way, could you plot to show the output of the LQR?
I think I plotted the output :)
Hi Junhwi,
Can this statement be clarified: "I wonder how to add saturation and wanna check if the input to the plant is really regulated in between +-1."
I think I understand the second part, which is that for your code above you want to check if the input the plant is between -1 and +1 for a unit step input. Is that correct? And if the plant input is not between those bounds, you want to add a saturation function on the output of the controller to ensure the input to the plant stays within those bounds?

Sign in to comment.

 Accepted Answer

Hi,
As per my understanding, you are trying to saturate the output of "lqr controller" and ensure that the input to the "plant" is regulated between -1 and +1. You can manually implement saturation in your code.
Here is an example to demonstrate how you can accomplish this:
u = max(min(u, 1), -1);
Alternatively, you can achieve this by using "Saturation" block in simulink.
Please refer to the following MathWorks documentation for more information:
  • "Saturation" - https://www.mathworks.com/help/simulink/slref/saturation.html
I hope this resolves the issue you were facing.

1 Comment

To enhance the value of your response, could you illustrate how to apply the saturation function to the 3rd-order system mentioned by the OP?
s = tf('s');
Gp = 4000/(s*(s + 10)*(s + 20))
Gp = 4000 -------------------- s^3 + 30 s^2 + 200 s Continuous-time transfer function.
[num, den] = tfdata(Gp, 'v');
A = [zeros(2, 1), eye(2); 0 -den(3) -den(2)];
B = [zeros(2, 1); num(4)];
C = [1 0 0];
D = 0;
K = lqr(A, B, eye(size(A)), 1) % LQR control gains
K = 1×3
1.0000 1.6830 0.9929

Sign in to comment.

More Answers (0)

Products

Release

R2023b

Asked:

on 6 Dec 2023

Commented:

on 9 Jan 2024

Community Treasure Hunt

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

Start Hunting!