415
Appendix C: Pascal Statements
for the Simulation of a Self-
Excited Induction Generator
Pascal program for simulation of the self-excited induction
generator;
{Post-Graduation Program in Electrical Engineering - Federal
University of Santa Maria
Solution for the state equations of the transient model for
the self-excited induction generator using a 4th order Runge
Kutta method.}
USES CRT,PRINTER;
type
register1 = record
diD,diQ,diqr,didr,dilD,dilQ :real
end;
register2 = record
dVcD,dVcQ,va : real;
end;
var
arq1 : text ;
arq2 : text ;
reg1 : register1;
reg2 : register2;
X0,Y0,h,x, teste : real ;
k1,k2,k3,k4 : real ;
q1,q2,q3,q4 : real ;
p1,p2,p3,p4 : real ;
r1,r2,r3,r4 : real ;
s1,s2,s3,s4 : real ;
t1,t2,t3,t4 : real ;
u1,u2,u3,u4 : real ;
z1,z2,z3,z4 : real ;
VD,Vdr,VQ,Vqr : real ;
Pm,Rs,Rr,Ls,Lr,Xs,Xr,M,w,ws,Xm,Im,R,L,C : real ;
dVcD,iD0,iQ0,iqr0,idr0,VcD0,VcQ0,ilD0,ilQ0 : real ;
416 Appendix C: Pascal Statements for the Simulation
A1,A2,A3,t0,tf,t,difiD,dif,ma : real ;
difference,y,npoints,TQ,theta,modulev : real ;
k,j : integer ;
line : integer ;
step : real ;
a : char ;
FUNCTION f1 (VD,Rs,diD,dVcD,Vdr,w,M,diQ,Lr,diqr,Rr,didr,A1,A2 :
real) : real ;
begin
f1: = 0;
f1 : = A1*(VD-Rs*diD-dVcD)+A2*(Vdr-w*M*diQ-w*Lr*diqr-Rr*didr) ;
end ;
FUNCTION f2 (VQ,Rs,diQ,dVcQ,Vqr,w,M,diD,Rr,diqr,Lr,didr,A1,A2 :
real) : real ;
begin
f2: = 0;
f2 : = A1*(VQ-Rs*diQ-dVcQ)+A2*(Vqr+w*M*diD-Rr*diqr+w*Lr*didr) ;
end ;
FUNCTION f3 (VQ,Rs,diQ,dVcQ,Vqr,w,M,diD,Rr,diqr,Lr,didr,A2,A3 :
real) : real ;
begin
f3: = 0;
f3 : = A2*(VQ-Rs*diQ-dVcQ)+A3*(Vqr+w*M*diD-Rr*diqr+w*Lr*didr) ;
end ;
FUNCTION f4 (VD,Rs,diD,dVcD,Vdr,w,M,diQ,Lr,diqr,Rr,didr,A2,A3 :
real) : real ;
begin
f4: = 0;
f4 : = A2*(VD-Rs*diD-dVcD)+A3*(Vdr-w*M*diQ-w*Lr*diqr-Rr*didr) ;
end ;
FUNCTION f5 (diD,dilD,C : real) : real ;
begin
f5: = 0;
f5 : = (diD/C)-(dilD/C) ;
end ;
FUNCTION f6 (diQ,dilQ,C : real) : real ;
begin
f6: = 0;
f6 : = (diQ/C)-(dilQ/C) ;
end ;
FUNCTION f7 (dVcD,R,dilD,L : real) : real ;
begin
f7: = 0;
f7 : = (dVcD/L)-(R*dilD/L) ;
end ;
FUNCTION f8 (dVcQ,R,dilQ,L : real) : real ;
begin
f8: = 0;
f8 : = (dVcQ/L)-(R*dilQ/L) ;
end ;
417Appendix C: Pascal Statements for the Simulation
begin
assign(arq1,’irleber.m’);
settextbuf(arq1,reg1.diD);
settextbuf(arq1,reg1.diQ);
settextbuf(arq1,reg1.diqr);
settextbuf(arq1,reg1.didr);
settextbuf(arq2,reg2.dVcD);
settextbuf(arq2,reg2.dVcQ);
settextbuf(arq1,reg1.dilD);
settextbuf(arq1,reg1.dilQ);
rewrite(arq1);
clrscr ;
writeln(‘Input the initial values:’);
writeln;
write(‘Enter with the calculation step (h):’);
readln(h) ;
write(‘Enter with the initial time:’);
readln(t0) ;
write(‘Enter with the final time:’);
readln(tf) ;
R: = 1000;
L: = 100;
C: = 160e-6;
Rs: = 0.575;
Xs: = 1.3074;
Rr: = 0.0404;
Xr: = 1.3074;
Pm: = 4;
w: = 2*pi*60;
id0: = 0;
iQ0: = 0;
idr0: = 0;
iqr0: = 0;
VcD0: = 0;
VcQ0: = 0;
ilQ0: = 0;
k: = 0;
t : = t0 ;
dif: = 1;
Ma: = 0.0659;
M: = 0.0659;
im: = 0;
reg1.diD : = iD0 ;
reg1.diQ : = iQ0 ;
reg1.diqr : = iqr0 ;
reg1.didr : = idr0 ;
reg2.dVcD : = VcD0 ;
reg2.dVcQ : = 0.00001 ;
reg1.dilD : = ilD0 ;
reg1.dilQ : = ilQ0 ;
418 Appendix C: Pascal Statements for the Simulation
while t< = tf do
begin
k: = k+1;
if k = 1 then
begin
modulev: = sqrt(sqr(reg2.dVcD)+sqr(reg2.dVcQ));
theta: = arctan(abs(reg2.dVcD/reg2.dVcQ));
reg2.va: = (modulev/sqrt(2))*sin((w*t+theta*pi/180));
writeln(arq1,reg1.did/sqrt(2));
flush(arq1);
end;
if k = 20 then
k: = 0;
clrscr;
gotoxy(10,10);
writeln(‘tempo’,t);
k1: = 0 ;
k2: = 0 ;
k3: = 0 ;
k4: = 0 ;
q1: = 0 ;
q2: = 0 ;
q3: = 0 ;
q4: = 0 ;
p1: = 0 ;
p2: = 0 ;
p3: = 0 ;
p4: = 0 ;
r1: = 0 ;
r2: = 0 ;
r3: = 0 ;
r4: = 0 ;
s1: = 0 ;
s2: = 0 ;
s3: = 0 ;
s4: = 0 ;
t1: = 0 ;
t2: = 0 ;
t3: = 0 ;
t4: = 0 ;
u1: = 0 ;
u2: = 0 ;
u3: = 0 ;
u4: = 0 ;
z1: = 0 ;
z2: = 0 ;
z3: = 0 ;
z4: = 0 ;
419Appendix C: Pascal Statements for the Simulation
if t = t0 then
VD: = 5
else
VD: = 0;
if t = t0 then
VQ: = 5
else
VQ: = 0;
if t = t0 then
Vdr: = 0
else
Vdr: = 0 ;
if t = t0 then
Vqr: = 0
else
Vqr: = 0 ;
im: = (sqrt(sqr(reg1.diD+reg1.didr)+sqr(reg1.diQ+reg1.diqr))) ;
writeln(‘dVcD’,reg2.dVcD) ;
writeln(‘dvcQ’,reg2.dVcQ) ;
M: = (0.0423*exp(-0.0035*(sqr (Im)))+0.0236);
TQ: = -1.5*Pm/2*(reg1.diQ*reg1.didr-reg1.diD*reg1.diqr)*M ;
Xm: = M*w;
Ls: = (Xs+Xm)/w;
Lr: = (Xr+Xm)/w;
A1: = -Lr/(sqr(M)-Lr*Ls);
A2: = M/(sqr(M)-Lr*Ls) ;
A3: = -Ls/(sqr(M)-Lr*Ls);
dif : = abs(Ma-M);
Ma: = M;
k1: = h*f1(VD,Rs,reg1.diD,reg2.dVcD,Vdr,w,M,reg1.diQ,Lr,reg1.
diqr,Rr,
reg1.didr,A1,A2);
q1: = h*f2(VQ,Rs,reg1.diQ,reg2.dVcQ,Vqr,w,M,reg1.diD,Rr,reg1.
diqr,Lr,
reg1.didr,A1,A2);
p1: = h*f3(VQ,Rs,reg1.diQ,reg2.dVcQ,Vqr,w,M,reg1.diD,Rr,reg1.
diqr,Lr,
reg1.didr,A2,A3);
r1: = h*f4(VD,Rs,reg1.diD,reg2.dVcD,Vdr,w,M,reg1.diQ,Lr,reg1.
diqr,Rr,
reg1.didr,A2,A3);
s1: = h*f5(reg1.diD,reg1.dilD,C);
t1: = h*f6(reg1.diQ,reg1.dilQ,C);
u1: = h*f7(reg2.dVcD,R,reg1.dilD,L);
z1: = h*f8(reg2.dVcQ,R,reg1.dilQ,L);
k2: = h*f1(VD,Rs,reg1.diD+(k1/2),reg2.dVcD+(s1/2),Vdr,w,M,reg1.
diQ+(q1/2),Lr,reg1.diqr+(p1/2),Rr,reg1.didr+(r1/2),A1,A2);
Get Modeling and Analysis with Induction Generators, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.