How do I implement LQR (Linear Quadratic Regulator) design script in my Piezo Bender Simulink Model ?
22 views (last 30 days)
Show older comments
Hi. Below is the LQR Design MATLAB code created to design a closed-loop controller of my Piezo Bender Energy Harvester in order to optimize the transfer of power and improve the efficiency of the energy harvester in different conditions. So, how do I implement this LQR script into my Simulink model ?
% Parameters
rho = 7804.89;
l = 3.175e-2;
w = 1.72e-2;
d = 5.084e-4;
E = 1.36628e11;
I = 1.3907e-14;
e31 = 7.5459;
epsl = 1.38965e-8;
bm = 0;
kb = 1e-5;
% Mass matrix
m = (rho*l*w*d)/420;
M1 = [156 22*l 54 -13*l;
22*l 4*l^2 13*l -3*l^2;
54 13*l 156 -22*l;
-13*l -3*l^2 -22*l 4*l^2];
M = m*M1;
% Stiffness matrix
K = [12*E*I/l^3 6*E*I/l^2 -12*E*I/l^3 6*E*I/l^2;
6*E*I/l^2 4*E*I/l -6*E*I/l^2 2*E*I/l;
-12*E*I/l^3 -6*E*I/l^2 12*E*I/l^3 -6*E*I/l^2;
6*E*I/l^2 2*E*I/l -6*E*I/l^2 4*E*I/l];
% Damping matrix
B = kb*K + bm*M;
%State-space
n = size(M, 1);
a11 = zeros(n);
a12 = eye(n);
a21 = - M\K;
a22 = - M\B;
b1 = zeros(n);
b2 = M\a12;
A = [a11 a12; a21 a22];
B = [b1; b2];
C = [eye(n) zeros(n)];
D = zeros(n);
sys1 = ss(A, B, C, D)
step(sys1, 10)
%Optimal Gain matrix
q = 1.0e0; % to make the response faster, increase exponent of q with r fixed at 1
Q = q*eye(2*n);
r = 1.0e0; % to reduce the energy consumption, increase exponent of r with q fixed at 1
R = r*eye(n);
G = lqr(A, B, Q, R)
H = A - B*G;
sys2 = ss(H, B, C, D)
step(sys2, 10)
The Simulink Model.
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!