HP Forums
Impedance of an RLC Circuit (Series and Parallel) - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP Prime Software Library (/forum-15.html)
+--- Thread: Impedance of an RLC Circuit (Series and Parallel) (/thread-3178.html)



Impedance of an RLC Circuit (Series and Parallel) - Eddie W. Shore - 02-22-2015 09:42 PM

The program RLCSERIES and RLCPAREL calculate:

• The total impedance of the circuit, and its magnitude in ohms
• Phase angle in a circuit in degrees.
• Current of the series in amps.

RLCSERIES works with series circuits while RLCPAREL works with parallel circuits.

Input:
Battery/Source: enter voltage and frequency
Add as many resistors (R) (in Ohms Ω), capacitors (C) (in farad), and inductors (L) (in henrys) as needed. On the input screen, enter the real (a) and imaginary (if needed) (bi) parts separately.

Example - Series Circuit:
Series circuit powered by a 14 V, 5000 Hz battery. The circuit has: a resistor of 100 Ω, a capacitor of 3.2*10^-6 farads, and an inductor of 0.082 henrys.

Results:
Total Resistance:
100 + 2566.158792*i
Magnitude:
2568.10649035
Phase Angle:
87.7683842611°
Current:
5.45148733225 * 10^-3

RLCSERIES: HP Prime

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
IF x==1 THEN
INPUT(R,"Add Resistor","R =",
// 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; 

Example - Parallel Circuit:
Parallel circuit powered by a 14 V, 5000 Hz battery. The circuit has:
a resistor of 100 Ω, a capacitor of 3.2*10^-6 farads, and an inductor of 0.082 henrys.

RLCPAREL: HP Prime

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

// Main Routine
EXPORT RLCPAREL()
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},"Add Resistor (Ω)",
{"a =","bi ="});
Z0:=Z0+1/(a+b*i);
I:=I+1;
chsubr();
END;

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

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

// Termination
IF x==4 THEN
Z0:=1/Z0;
PRINT();
PRINT("Total Resistance = "+Z0);
PRINT("Magnitude (Ω) = "+ABS(Z0));
PRINT("Phase Angle (°) ="+
STRING(−ARG(Z0)*180/π));
PRINT("Current (amps) = "+
STRING(V/ABS(Z0)));
RETURN Z0;
END;
END;



Sources:
ElectronicsTutorials. Series RLC Circuit Analysis URL: http://www.electronics-tutorials.ws/accircuits/series-circuit.html
Retrieved February 22, 2015

ElectronicsTutorials. Parallel RLC Circuit Analysis URL:
http://www.electronics-tutorials.ws/accircuits/parallel-circuit.html
Retrieved February 22, 2015

Van Valkenburg, Mac E. (Editor) and Wendy M. Middelton (Editor) "Reference Data for Engineers: Radio, Electronics, Computer, and Communications" 9th Edition. Newnes, Butterworth-Heinemann: Wolburn, MA 2002. Print.


RE: Impedance of an RLC Circuit (Series and Parallel) - Thomas_Sch - 02-23-2015 11:28 AM

Hello Eddy,

many thanks for this programs!

Maybe your routines for RLCSERIES are partly two times in the first code block.
casubr(x) ends after "INPUT(R,"Add Resistor","R =", " then the code starts new.

Thomas


RE: Impedance of an RLC Circuit (Series and Parallel) - salvomic - 04-03-2015 01:05 PM

(02-23-2015 11:28 AM)Thomas_Sch Wrote:  Maybe your routines for RLCSERIES are partly two times in the first code block.
casubr(x) ends after "INPUT(R,"Add Resistor","R =", " then the code starts new.
Thomas

yes, Thomas,
I think it should be so:
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;

Isn't it, Eddie?


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

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;