Post Reply 
Impedance of an RLC Circuit (Series and Parallel)
04-05-2015, 04:02 AM
Post: #4
RE: Impedance of an RLC Circuit (Series and Parallel)
I see my mistake... first of all, apologizes, second of all, here is the code with nothing repeated:

Code:
// Impedance of a Series
// EWS 2015-02-22
// Turn allow complex from real input on
// Declare subroutines
chsubr();
casubr();

// Main Routine
EXPORT RLCSERIES()
BEGIN
// initial steps
Z0:=0;
// radian mode
HAngle:=0;
// counter
I:=0;
// battery information
INPUT({V,F},"Battery Information",
{"V = ","F = "},
{"Volts","Frequency (Hz)"});
chsubr();
END;


// Choose Subroutine
chsubr()
BEGIN
LOCAL ch;
CHOOSE(ch,"# of Components: "+STRING(I),
{"Add Resistor (R)",
"Add Capacitor (C)",
"Add Inductor (L)",
"Calculate"});
// Execute calculation subroutine
casubr(ch);
END;

// Calculation Subroutine
casubr(x)
BEGIN
LOCAL a,b;
IF x==1 THEN
INPUT({a,b},"Resistor (Ω)",
{"a =","bi="});
Z0:=Z0+(a+b*i);
I:=I+1;
chsubr();
END;

IF x==2 THEN
INPUT({a,b},"Capacitor (farad)",
{"a =","bi="});
Z0:=Z0-i/(2*π*F*(a+b*i));
I:=I+1;
chsubr();
END;

IF x==3 THEN
INPUT({a,b},"Inductor (henry)",
{"a =","bi="});
Z0:=Z0+i*2*π*F*(a+b*i);
I:=I+1;
chsubr();
END;

// Calculation
IF x==4 THEN 
PRINT();
PRINT("Impedance = "+Z0);
PRINT("Magnitude (Ω) = "+ABS(Z0));
PRINT("Phase Angle (°) ="+
STRING(ARG(Z0)*180/π));
PRINT("Current (amps) = "+
STRING(V/ABS(Z0)));
RETURN Z0;
END;
END;
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Impedance of an RLC Circuit (Series and Parallel) - Eddie W. Shore - 04-05-2015 04:02 AM



User(s) browsing this thread: 1 Guest(s)