%% ANN-based programmable LQR for inverter-fed induction motor
%
% Bartlomiej Ufnalski
% Institute of Control and Industrial Electronics
% Warsaw University of Technology
%
% The idea (dated back to 2006) is to use linear-quadratic regurator (LQR)
% concept to synthesize optimal controller for plants with the non-constant
% state matrix. It is assumed that this matrix changes with working point.
% An induction motor can serve here as an example.
%
% Basically, this model illustrates the concept described in detail here:
% http://dx.doi.org/10.1109/IJCNN.2006.246811
% (Neural-Network-based Programmable State Feedback Controller for
% Induction Motor Drive)
%
% rev. 2014.10.02 for Matlab Central
%
clear all
training = 0; % this submission already includes ANN stored in .mat --> you can run the model skipping the training stage;
% training = 1 is needed if you experiment with different Q
% and R matrices (see:
% http://www.mathworks.com/help/control/ref/lqr.html)
with_noise = 1;
%
% Plant parameters (induction motor)
Ls = 0.1004;
Lr = 0.0969;
Lm = 0.0915;
sigma = 1-Lm*Lm/Lr/Ls;
lambda = Ls*Lr-Lm*Lm;
Rr = 1.294;
Tr = Lr/Rr;
Ts = 1e-4;
Tp = Ts;
Rs = 1.54;
Rs_ident_error = 1; % Rs in EMF estimation = Rs * Rs_ident_error
wc = 1/Ts;
pb = 3;
psi_ref = 0.7;
J = 0.15;
slip_max = 280;
omega_max = 300; % omega flux
%
if training == 0,
load net_lqr.mat
open('sfoc_lqr_ann.slx');
disp('Simulating...');
set_param('sfoc_lqr_ann','SimulationCommand','start');
return
end
%
% The ststes: isx isy psisx omegam p1-psi p2-omega
%
k = 1;
disp('LQR: calculating gain matrices K for different slips at different speeds...');
for a1 = -omega_max:20:omega_max,
% disp(['LQR: calculating gain matrices for different slips at ',num2str(a1),'rad/s']);
for a2 = -slip_max:20:slip_max,
A = [-(Rr*Ls+Rs*Lr)/lambda a2 Rr/lambda 0 0 0;
-a2 -Rr*Ls/lambda a2*Lr/lambda 0 0 0;
-Rs 0 0 0 0 0;
0 0 -1/J*3/2*pb*psi_ref*a1/Rs 0 0 0;
0 0 1 0 0 0;
0 0 0 1 0 0];
B = [Lr/lambda 0;
0 0;
1 0;
0 1/J*3/2*pb*psi_ref/Rs;
0 0;
0 0];
%
% Q and R by guessing and checking. The Bryson's rule might be helpful.
% Some hints on choosing Q in augmented systems (i.e. with
% auxiliary state variables) can be found here:
% http://dx.doi.org/10.1109/TIE.2014.2334669
% (Particle Swarm Optimization of the Multi-oscillatory LQR for a 3-phase 4-wire Voltage Source Inverter with an LC Output Filter
% AKA Particle Swarm Optimization of the Multi-Oscillatory LQR
% for a Three-Phase Four-Wire Voltage Source Inverter with an LC Output Filter)
% or here:
% State-Space Current Control For Four-Leg Grid-Connected PWM
% Rectifiers With Active Power Filtering Function (PEMC 2014)
% or soon here: http://pe.org.pl/last.php?lang=1 (A. Galecki,
% B. Ufnalski, A. Kaszewski, L.M. Grzesiak).
%
Q = diag([1/100 1/100 1/0.7^2 1/10000 1/0.7^2 1/10000].*[0.1 0.1 0.002 0.1 100000 100]);
R = diag([1/40000 1/40000].*[0.01 0.01]);
%
[Klqr,S,E] = lqr(A,B,Q,R);
inputANN(:,k) = [a1;a2];
outputANN(:,k) = [Klqr(1,:)';Klqr(2,:)'];
k = k+1;
end
end
%
norm_input = max(abs(inputANN'))';
norm_inputANN = repmat(norm_input',max(size(inputANN)),1)';
norm_output = max(abs(outputANN'))';
norm_outputANN = repmat(norm_output',max(size(outputANN)),1)';
P = inputANN./norm_inputANN;
T = outputANN./norm_outputANN;
s1 = 3;
s2 = 5;
[s3,pom] = size(T);
%
net = feedforwardnet([s1,s2]);
net.layers{1}.transferFcn = 'tansig';
net.layers{2}.transferFcn = 'tansig';
net.layers{3}.transferFcn = 'purelin';
net.divideFcn='dividetrain';
net.trainParam.show = 5;
net.trainParam.epochs = 100;
disp('Training...');
net = train(net,P,T);
%
gensim(net,-1); % The net has to be copied manually into .slx. Sorry for that. I could do better.
net.userdata.norm = [norm_input' norm_output'];
save net_lqr net
% Some graphs can be plotted using lqr_ann_graphs script.
% That's all folks!
天天Matlab代码科研顾问
- 粉丝: 3w+
- 资源: 1873
最新资源
- 【Unity场景构建工具】Prefab World Builder 使用Prefabs快速生成和编辑大型环境
- java数组反转 的四种方法 超实用
- 本科阶段最后一次竞赛Vlog-2024年智能车大赛智慧医疗组准备全过程-9二维码识别附件
- ++i和i++的区别 c/c++开发中
- 2076 -112 IBM V7000 firmware 7.8.1.16
- 0-1背包限界剪枝.cpp
- 基于MATLAB图像腐蚀膨胀代码面板GUI(1).zip
- 随堂练习编程题的参考代码c4.c
- 自制功能强大的自动点击工具
- 【Unity代理导航插件】Agents Navigation与现有的 Unity 技术和框架完美融合
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈