HELP!! S Function for squirrel cage

Thread Starter

AEM

Joined Feb 18, 2011
3
Got stuck at my poor model for couple of weeks now, was wondering if anyone would be kind enough to take a look at it for me.

Haven't been able to pinpoint the problem since the model is running but not returning the results I'm looking for (I compared my results with SimPowerSystem's very own power_pwm)... Inputs are 220V, 60Hz ac to the stator terminals, no input to rotor terminals, and try putting it in generating mode by putting negative torque...

HELP!!!!

This is the S-Function

function [sys,x0,str,ts] = ASYM_SF(t,x,u,flag,Param)
%Rev 0.1

switch flag

%%%%%%%%%%%%%%%%%%
% Initialization %
%%%%%%%%%%%%%%%%%%
case 0
[sys,x0,str,ts] = mdlInitializeSizes(Param);

%%%%%%%%%%%%%%%
% Derivatives %
%%%%%%%%%%%%%%%
case 1
sys = mdlDerivatives(t,x,u,Param);

%%%%%%%%%%%
% Outputs %
%%%%%%%%%%%
case 3
sys = mdlOutputs(t,x,u,Param);

%%%%%%%%%%%%%
% Terminate %
%%%%%%%%%%%%%

case {2 4 9}
sys = []; % do nothing


otherwise
error(['Unhandled Flag =',num2str(flag)]);

end

%end simom2

%
%=============================================================================
% mdlInitializeSizes
% Return the sizes, initial conditions, and sample times for the S-function.
%=============================================================================
%
function [sys,x0,str,ts] = mdlInitializeSizes(~)

sizes = simsizes;

sizes.NumContStates = 6;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 7;
sizes.NumInputs = 5;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 1;

sys = simsizes(sizes);
x0 = zeros(6,1);
str = [];
ts = [0 0];

% end mdlInitializeSizes

%
%=============================================================================
% mdlDerivatives
% Return the derivatives for the continuous states.
%=============================================================================
%
function sys = mdlDerivatives(t,x,u,Param)

sys = DE_ASYM(t,x,u,Param);

% end mdlDerivatives

%
%=============================================================================
% mdlOutputs
% Return the output vector for the S-function
%=============================================================================
%
function sys = mdlOutputs(t,x,u,Param)
% I_qs = Y(1)
% I_ds = Y(2)
% I_qr = Y(3)
% I_dr = Y(4)
% Te = Y(5)
% Wr = Y(6)
% Tht_r = Y(7)

Ls = Param.Ls;
Lm = Param.Lm;
Lr = Param.Lr;
Wb = 1; %p.u.

Xm = Wb*Lm;
Xs = Wb*Ls;
Xr = Wb*Lr;
Xaq = 1/(1/Xm + 1/Xs + 1/Xr);
Xad = Xaq;

phimq = Xaq*(x(1)/Xs + x(3)/Xr);
phimd = Xad*(x(2)/Xs + x(4)/Xr);

Y1 = (1/Xs)*(x(1)-phimq);
Y2 = (1/Xs)*(x(2)-phimd);
Y3 = (1/Xr)*(x(3)-phimq);
Y4 = (1/Xr)*(x(4)-phimd);
Y5 = x(2)*Y1-x(1)*Y2;
Y6 = x(5);
Y7 = x(6);

sys = [Y1;
Y2;
Y3;
Y4;
Y5;
Y6;
Y7];

% end mdlOutputs

%
%=============================================================================
% DFIG Differential Equations
%=============================================================================
%
function dX = DE_ASYM(t,x,u,Param)
% Model for DFIG
%
% Fi_qs = x(1) Flux linkages per second (Volts)
% Fi_ds = x(2)
% Fi_qr = x(3)
% Fi_dr = x(4)
% Wr = x(5) p.u. Rotor speed
% Tht_r = x(6) Theta_r, Rotor angle
%
%
% V_qs = u(1)
% V_ds = u(2)
% V_qr = u(3)
% V_dr = u(4)
% Tm = u(5) p.u. Mechanical torque
%
%
% I_qs = Y(1)
% I_ds = Y(2)
% I_qr = Y(3)
% I_dr = Y(4)
% Te = Y(5) p.u. Electrical torque
% Wr = Y(6) p.u. Rotor speed
% Tht_r = Y(7) Theta_r, Rotor angle
%
%
% J = Param.J; Inertia
% B = Param.B;
% H = J/(2*P); Inertia constant
% F = (B/J)*(2*H); Friction coefficient
Ls = Param.Ls;
Lm = Param.Lm;
Lr = Param.Lr;
Rs = Param.Rs;
Rr = Param.Rr;
H = Param.H;
F = Param.F;
P = Param.P;

Ws = 1; %p.u Synchronous speed
Wb = Ws; %p.u Base electrical angular velocity

Xs = Wb*Ls;
Xm = Wb*Lm;
Xr = Wb*Lr;
Xaq = 1/(1/Xm + 1/Xs + 1/Xr);
Xad = Xaq;

%--------------------------------------------------------------------------
%Electrical Equations

phimq = Xaq*(x(1)/Xs + x(3)/Xr);
phimd = Xad*(x(2)/Xs + x(4)/Xr);

dX1 = Wb*u(1) - Ws*x(2) + ((Wb*Rs)/Xs)*(phimq-x(1));

dX2 = Wb*u(2) + Ws*x(1) + ((Wb*Rs)/Xs)*(phimd-x(2));

dX3 = Wb*u(3) - (Ws-x(5))*x(4) + ((Wb*Rr)/Xr)*(phimq-x(3));

dX4 = Wb*u(4) + (Ws-x(5))*x(3) + ((Wb*Rr)/Xr)*(phimd-x(4));

%Mechanical Equations

Te = (1/Xs)*x(2)*(x(1)-phimq) - (1/Xs)*x(1)*(x(2)-phimd);

dX5 = (Wb/(2*H))*(Te-u(5));

dX6 = x(5);

%--------------------------------------------------------------------------

dX =[dX1;
dX2;
dX3;
dX4;
dX5;
dX6];
 
Top