How do I implement LQR (Linear Quadratic Regulator) design script in my Piezo Bender Simulink Model ?

조회 수: 20 (최근 30일)
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)
sys1 = A = x1 x2 x3 x4 x5 x6 x7 x8 x1 0 0 0 0 1 0 0 0 x2 0 0 0 0 0 1 0 0 x3 0 0 0 0 0 0 1 0 x4 0 0 0 0 0 0 0 1 x5 2.301e+07 4.175e+05 -2.301e+07 3.131e+05 230.1 4.175 -230.1 3.131 x6 -8.698e+09 -1.479e+08 8.698e+09 -1.282e+08 -8.698e+04 -1479 8.698e+04 -1282 x7 -2.301e+07 -3.131e+05 2.301e+07 -4.175e+05 -230.1 -3.131 230.1 -4.175 x8 -8.698e+09 -1.282e+08 8.698e+09 -1.479e+08 -8.698e+04 -1282 8.698e+04 -1479 B = u1 u2 u3 u4 x1 0 0 0 0 x2 0 0 0 0 x3 0 0 0 0 x4 0 0 0 0 x5 7384 -1.744e+06 -1846 -8.721e+05 x6 -1.744e+06 5.494e+08 8.721e+05 3.845e+08 x7 -1846 8.721e+05 7384 1.744e+06 x8 -8.721e+05 3.845e+08 1.744e+06 5.494e+08 C = x1 x2 x3 x4 x5 x6 x7 x8 y1 1 0 0 0 0 0 0 0 y2 0 1 0 0 0 0 0 0 y3 0 0 1 0 0 0 0 0 y4 0 0 0 1 0 0 0 0 D = u1 u2 u3 u4 y1 0 0 0 0 y2 0 0 0 0 y3 0 0 0 0 y4 0 0 0 0 Continuous-time state-space model.
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)
G = 4×8
0.5024 -0.0078 0.4976 -0.0078 0.9935 -0.0000 0.0076 -0.0000 -0.1397 0.9415 0.1397 0.0541 -0.0002 1.0000 0.0002 -0.0000 0.4976 0.0078 0.5024 0.0078 0.0076 0.0000 0.9935 0.0000 -0.1397 0.0541 0.1397 0.9415 -0.0002 -0.0000 0.0002 1.0000
H = A - B*G;
sys2 = ss(H, B, C, D)
sys2 = A = x1 x2 x3 x4 x5 x6 x7 x8 x1 0 0 0 0 1 0 0 0 x2 0 0 0 0 0 1 0 0 x3 0 0 0 0 0 0 1 0 x4 0 0 0 0 0 0 0 1 x5 2.264e+07 2.107e+06 -2.265e+07 1.229e+06 -7634 1.744e+06 2094 8.721e+05 x6 -8.567e+09 -6.86e+08 8.568e+09 -5.2e+08 1.833e+06 -5.493e+08 -9.609e+05 -3.845e+08 x7 -2.265e+07 -1.229e+06 2.264e+07 -2.107e+06 2094 -8.721e+05 -7634 -1.744e+06 x8 -8.568e+09 -5.2e+08 8.567e+09 -6.86e+08 9.609e+05 -3.845e+08 -1.833e+06 -5.493e+08 B = u1 u2 u3 u4 x1 0 0 0 0 x2 0 0 0 0 x3 0 0 0 0 x4 0 0 0 0 x5 7384 -1.744e+06 -1846 -8.721e+05 x6 -1.744e+06 5.494e+08 8.721e+05 3.845e+08 x7 -1846 8.721e+05 7384 1.744e+06 x8 -8.721e+05 3.845e+08 1.744e+06 5.494e+08 C = x1 x2 x3 x4 x5 x6 x7 x8 y1 1 0 0 0 0 0 0 0 y2 0 1 0 0 0 0 0 0 y3 0 0 1 0 0 0 0 0 y4 0 0 0 1 0 0 0 0 D = u1 u2 u3 u4 y1 0 0 0 0 y2 0 0 0 0 y3 0 0 0 0 y4 0 0 0 0 Continuous-time state-space model.
step(sys2, 10)
The Simulink Model.

답변 (0개)

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by