The Museum of HP Calculators

Two-bus AC Power Transfer for the HP-33S

This program is by Karl Schneider and is used here by permission.

This program is supplied without representation or warranty of any kind. Karl Schneider and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.


PROGRAM FUNCTION: Calculates transfer of complex power between two AC buses

DESIGNED FOR: HP-33S (using RPN mode)




This program calculates the total active (real) power "P" and reactive power "Q" injected into either end of an AC line or pair of paralleled AC lines joined by two buses. The AC line(s) may be three-phase or single-phase.

Each AC line is modeled with one set of "balanced-pi" parameters of series resistance, series reactance, and shunt susceptance. The AC bus voltages are defined in terms of rms magnitudes and a phase-angle difference.

The program includes a routine "Z" that will calculate the equivalent parameters of a parallel line-pair, if needed. The user may also run "Z" separately as a stand-alone program.

IMPORTANT: This program was written for RPN logic. Each routine places the HP-33S in RPN mode via an "RPN" instruction in their second lines. Users who normally operate the HP-33S in Algebraic (ALG) mode should consider the Algebraic-mode version of this program.


Total storage:   425 bytes

Program labels:    4

Stored variables: 10

Flags:             1 (flag 2)


Label  Bytes  Checksum  Description

  S      42     0C24    Starts program; prompts for input variables

  C     107     FE31    Drives calculation of the output variables

  P     165     7F88    Calculates all injections of real and reactive power

  Z     111     1CA5    Calculates equivalent parameters of line-pair

INPUT VARIABLES (in order of entry):

Variable  Description                              Unit of measure    Notes

   V      Voltage magnitude at first bus           [per unit]         (1)

   W      Voltage magnitude at second bus          [per unit]         (1)

   D      Voltage-angle difference between buses   [degrees]          (2)

   R      Series resistance of line                [per unit]         (3)

   X      Series reactance of line                 [per unit]         (3)

   B      Total shunt susceptance of line          [per unit]         (4)

   R      Series resistance of second line         [per unit]         (3,5)

   X      Series reactance of second line          [per unit]         (3,5)

   B      Total shunt susceptance of second line   [per unit]         (4,5)

(1)  1-phase lines: Base voltage is rms nominal line-ground (LG) voltage
     3-phase lines: Base voltage is rms nominal line-line (LL) voltage = sqrt(3)*LG

(2)  Positive-valued angle difference is inputted for voltage at the first bus
     leading that of the second bus; negative-valued angle difference is entered
     for a lagging first-bus voltage.

(3)  Base impedance for R and X is the squared base voltage divided by power base
     (100 MVA in line P0028).

(4)  Base admittance for B is the reciprocal of base impedance.

(5)  R, X, and B for the second line are to be input only if two lines are modeled.

OUTPUT VARIABLES (in order of display):

Variable   Description                                    Unit of measure   Notes

   P, S    Real power injected by first bus               [MW]              (6,7)

   Q, T    Reactive power injected by first bus           [MVAr]            (6,8)

   P       Real power injected by second bus              [MW]              (6)

   Q       Reactive power injected by second bus          [MVAr]            (6)

stack x    Real-power consumption (losses) on the line    [MW]              (6)

stack y    Reactive-power consumption on the line         [MVAr]            (6)

(6)  These units (MW or MVAr) assume a base voltage in kV and base power of 100 MVA.

(7)  P is re-stored to variable S when second-bus power is calculated.

(8)  Q is re-stored to variable T when second-bus power is calculated.


  1. Set Flag 2 if two parallel transmission lines are to be entered

  2. Start program using "XEQ S"

  3. Enter input variables V, W, D, R, X, and B

  4. Enter additional input variables R, X, and B for second line if necessary

  5. Read total first-bus real power P; press "R/S"

  6. Read total first-bus reactive power Q; press "R/S"

  7. Read total second-bus real power P; press "R/S"

  8. Read total second-bus reactive power Q; press "R/S"

  9. Read total real-power and reactive power line losses



S0001  LBL S       Enter main program
S0002  RPN
S0003  DEG
S0004  INPUT V     First-bus voltage magnitude (V1)
S0005  INPUT W     Second-bus voltage magnitude (V2)
S0006  INPUT D     Voltage-angle difference (d)
S0007  FS? 2       2-line network?
S0008  XEQ Z       -- If yes, run parallel-line program
S0009  FS? 2
S0010  GTO C
S0011  INPUT R     -- Else, enter line parameters here
S0012  INPUT X
S0013  INPUT B
S0014  GTO C

C0001  LBL C
C0002  RPN
C0003  CF 2
C0004  XEQ P       Calculate power from first bus
C0005  RCL P
C0006  STO S       Copy P from first bus
C0007  RCL Q
C0008  STO T       Copy Q from first bus
C0009  RCL V       Set variables to calculate power from second bus:
C0010  x<> W       -- Swap V and W
C0011  STO V
C0012  RCL D       -- Change sign of D
C0013  +/-
C0014  STO D
C0015  XEQ P       Calculate power from second bus
C0016  RCL V       Restore original values of V, W, and D
C0017  x<> W
C0018  STO V
C0019  RCL D
C0020  +/-
C0021  STO D
C0022  RCL T       Add complex power at first bus and second bus
C0023  RCL S
C0024  RCL Q
C0025  RCL P
C0026  CMPLX+
C0027  SF 10
C0028  "LOSSES P:X Q:Y"   [Unquoted text is entered in Equation mode]
C0029  PSE         Display P loss in x-register, and Q loss in y-register
C0030  CF 10
C0031  RTN

P0001  LBL P       Begin calculation of power injections
P0002  RPN
P0003  RCL D       Voltage-angle difference (d)
P0004  RCL V       First-bus voltage magnitude (V1)
P0005  RCL W       Second-bus voltage magnitude (V2)
P0006  *
P0007  Th,r->y,x
P0008  0
P0009  RCL V
P0010  x2
P0011  Rdown
P0012  Rdown
P0013  CMPLX-      V_dif = V1^2 - V1*V2*(cos d + j*sin d)
P0014  RCL X
P0015  +/-
P0016  RCL R
P0017  CMPLX/      S through line [in pu] = V_dif / (R - j*X)
P0018  RCL B
P0019  2
P0020  /
P0021  RCL V
P0022  x2
P0023  *
P0024  0
P0025  CMPLX-     Subtract line-charging Q (= j*B/2 * V1^2)
P0026  0
P0027  ENTER
P0028  100        Power base = 100 MVA
P0029  CMPLX*     Multiply P and net Q by power base
P0030  STO P
P0031  x<>y
P0032  STO Q
P0033  VIEW P     Show P injected into line(s)
P0034  VIEW Q     Show Q injected into line(s)
P0035  RTN

Z0001  LBL Z
Z0002  RPN
Z0003  INPUT R    Enter resistance of first line (R1)
Z0004  INPUT X    Enter reactance of first line  (X1)
Z0005  INPUT B    Enter susceptance of first line (B1)
Z0006  RCL X
Z0007  RCL R
Z0008  CMPLX1/x
Z0009  STO S      Real part in temporary storage
Z0010  x<>y
Z0011  STO T      Imaginary part in temporary storage
Z0012  INPUT R    Enter resistance of second line (R2)
Z0013  INPUT X    Enter reactance of second line  (X2)
Z0014  RCL X
Z0015  RCL R
Z0016  CMPLX1/x
Z0017  RCL T
Z0018  RCL S
Z0019  CMPLX+
Z0020  CMPLX1/x   (Req + j*Xeq) = (R1+ j*X1) || (R2 + j*X2)
Z0021  STO R
Z0022  x<>y
Z0023  STO X
Z0024  RCL B
Z0025  STO S
Z0026  INPUT B    Enter susceptance of second line (B2)
Z0027  RCL+ S
Z0028  STO B      Beq = B1 + B2
Z0029  CLx
Z0030  STO S      Clear S and T temporary registers
Z0031  STO T
Z0032  FS? 2      Is "Z" being run from AC transfer program?
Z0033  RTN        -- If yes, return without displaying results
Z0034  VIEW R     -- Else, display Req, Xeq, Beq in sequence
Z0035  VIEW X
Z0036  VIEW B
Z0037  RTN

Go back to the software library
Go back to the main exhibit hall