I dont get any results from this code ?

Hello,I'm trying to simulate a PTC(Predictive Torque Control) of an induction motor.However all i get in results is zeros in all outputs(rotor speed, stator currents and Electromagnetique Torque) .You'll find in attached files a model in simulink showing the schema of the simulation . This is the code i'm using for PTC :
%
function [Sa,Sb,Sc] = control(T_ref,sflux_ref,wm,i_meas)
% Variables defined in the parameters file
global Ts Rs Lr Lm Ls p tr kr r_sigma t_sigma lambda v states
persistent x_opt Fs
if isempty(x_opt)
x_opt = 1;
end
if isempty(Fs)
Fs = 0.79 + 0i*1;
end
% Stator flux estimate
Fs = Fs + Ts*(v(x_opt) - Rs*i_meas);
% Rotor flux estimate
Fr = Lr/Lm*Fs+i_meas*(Lm-Lr*Ls/Lm);
g_opt = 1e10;
for i = 1:8
% i-th voltage vector for current prediction
v_o1 = v(i);
% Stator flux prediction at instant k+1
Fsp1 = Fs + Ts*v_o1 - Rs*Ts*i_meas;
% Stator current prediction at instant k+1
Isp1 = (1+Ts/t_sigma)*i_meas+Ts/(t_sigma+Ts)*(1/r_sigma*((kr/tr-kr*1i*wm)*Fr+v_o1));
% Torque prediction at instant k+1
Tp1 = 3/2*p*imag(conj(Fsp1)*Isp1);
% Cost function
g = abs(T_ref - Tp1)+ lambda*abs(sflux_ref-abs(Fsp1));
if (g<g_opt)
g_opt = g;
x_opt = i
end
end
[~, x_opt] = min(g);
%**************************************
% Output switching states
Sa = states(x_opt,1);
Sb = states(x_opt,2);
Sc = states(x_opt,3);

댓글 수: 6

Birdman
Birdman 2018년 3월 28일
Can you share your model?
ayoub essrifi
ayoub essrifi 2018년 3월 28일
This is the model.
Birdman
Birdman 2018년 3월 28일
Some of your variables are missing. Make sure you send all of them.
ayoub essrifi
ayoub essrifi 2018년 3월 28일
Which variables ? Can you be more precise ?
It says
Undefined function or variable 'Xmlstar'
when I try to run it. I am sure there is more than one like this.
ayoub essrifi
ayoub essrifi 2018년 3월 28일
편집: ayoub essrifi 2018년 3월 28일
Oh i'm sorry i didn't pay attention . You can add these variables in the initfuction in the model properties.
%
%Motor parameters
Rr=0.39;
Rs=0.19;
Lls=0.2e-3;
Llr=0.6e-3;
Lm=4e-3;
fb=100;
p=4;
J=0.0226;
Lr=Llr+Lm;
Ls = 175e-3;
Tr=Lr/Rr;
wb=2*pi*fb;
Xls=wb*Lls;
Xlr=wb*Llr;
Xm=wb*Lm;
Xmlstar=1/(1/Xls+1/Xm+1/Xlr);

댓글을 달려면 로그인하십시오.

답변 (1개)

khoudir kakouche
khoudir kakouche 2020년 10월 30일

0 개 추천

it is this instruction ([~, x_opt] = min(g)) that will cause the problem.

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

질문:

2018년 3월 28일

답변:

2020년 10월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by