DECLARE SUB PAGER () 10 DIM I(200), E(200), T(200) pi = 4! * ATN(1!) REM ge copeland REM Dept of Physics REM Old Dominion University REM Norfolk VA 23529 REM 2/20/2001 40 REM 70 PRINT CHR$(12); 100 PRINT "PHASOR analysis of an LRC circuit." 130 PRINT 160 PRINT " This program does an analysis of an ac LRC circuit." 190 PRINT "The generator supplies voltage via E(t)=Emax Sin(2pift)" PRINT " Helpful values: E max = 100v, f = 60 Hz" 220 PRINT "Input the max Voltage and the frequency in Hz?" PRINT 250 INPUT Emax, F0 280 W0 = 2 * pi * F0 310 PRINT "Input the values of the inductance, resistance and capacitance?" PRINT "Helpful values: L=3H,R=200 Ohms, and C = 0.5uF" 340 PRINT "Input L(H),R(Ohms),C(Farads)?" 370 INPUT L, R, C 400 PRINT "The inductive reactance X(L) = W*L" 430 PRINT "where W is the angular frequency of the generator." 460 XL = W0 * L 490 PRINT " X(L) = "; XL; " Ohms."; "" 520 PRINT 550 PRINT " The capacitive reactance = X(C) = 1/(W*C)" 580 XC = 1 / (W0 * C) 610 PRINT " X(C) = "; XC; " Ohms." 640 PRINT 670 Z = SQR(R ^ 2 + (XL - XC) ^ 2) 700 PRINT "The impedance of the circuit Z = sqr( R^2 +(XL_XC)^2)"; "" 730 PRINT "For your values of LRC and W, Z ="; Z; " Ohms" 760 CALL PAGER 790 PRINT "The current and voltage change with time in this ac circuit." 820 PRINT "The current i(t) = i max sin(wt -phi)" 850 PRINT "where w = 2 Pi * frequency, i max = max current and phi is the phase" 880 PRINT "angle in radians. i max = E max/Z and phi is given by" 910 PRINT , "tan(phi) = [X(L)-X(C)]/R" 940 PRINT 970 PHI = ATN((XL - XC) / R) 1000 ANG = PHI * 180! / pi 1030 Imax = Emax / Z 1060 PRINT " The MAXIMUM CURRENT i max ="; Imax; " amperes." 1090 PRINT " The phase angle phi ="; ANG; " degrees" 1120 IF XL > XC THEN PRINT "E max LEADS i max." 1150 IF XC > XL THEN PRINT "E max LAGS i max." 1180 CALL PAGER 1210 PRINT " BELOW YOU WILL BE GIVEN SEVERAL OPTIONS:" 1240 PRINT " 1. Investigate the time evolution of the circuit." 1270 PRINT " 2. Investigate the evolution of the circuit as the driving" 1300 PRINT " frequency is varied." 1330 PRINT 1360 PRINT "Input the option you wish to continue study: 1 or 2?" 1390 INPUT ANS 1420 IF ANS = 1 THEN 1510 1450 IF ANS = 2 THEN 3040 1480 GOTO 1210 1510 REM TIME BEHAVIOR 1540 CALL PAGER 1570 PRINT "TIME BEHAVIOR:" 1600 PRINT " The voltage E(t) and current i(t) are functions of time." 1630 PRINT " E(t) = "; Emax; " * SIN("; W0; "* t ) " 1660 PRINT " i(t) = "; Imax; " * sin("; W0; " t - "; PHI; ")" 1690 PRINT 1720 PRINT "Want to see a plot of these functions vs time?(YES or NO)" 1750 INPUT ANSP$ 1780 IF ANSP$ = "YES" OR ANSP$ = "yes" OR ANSP$ = "Yes" THEN 1840 1810 IF ANSP$ = "NO" OR ANSP$ = "no" OR ANSP$ = "No" THEN STOP 1840 PRINT "After the plot return to PHASOR and study the variation with w." 2520 REM TEKTRONIX OUT PUT FOR TIME BEHAVIOR 2530 OPEN "PLTTEK.dat" FOR OUTPUT AS #2 2542 REM IF Imax < Emax THEN REM scale it up Imax = Emax ELSE Emax = Imax END IF NPTS = 0 2544 FOR T1 = 0 TO 5 * pi / W0 STEP 5 * pi / (W0 * 100) 2546 NPTS = NPTS + 1 2548 E(NPTS) = Emax * SIN(W0 * T1) 2600 T(NPTS) = T1 2610 I(NPTS) = Imax * SIN(W0 * T1 - PHI) 2612 NEXT T1 2620 PRINT #2, 1 2650 PRINT #2, 2 2680 PRINT #2, NPTS 2710 PRINT #2, " Voltage & Current Scaled same" 2740 PRINT #2, "TIME IN SECONDS" 2770 PRINT #2, "I(T) AND E(T) VS T FOR LRC CIRCUIT" 2800 PRINT #2, " AC BEHAVIOR FROM PROGRAM PHASOR" 2802 FOR I = 1 TO NPTS 2804 PRINT #2, T(I), E(I) 2806 NEXT I 2808 FOR I = 1 TO NPTS 2810 PRINT #2, T(I), I(I) 2812 NEXT I REM PRINT #2, T(NPTS - 1), I(NPTS - 1) REM statement above takes care of a one extra point on graph REM hope is 2816 PRINT "Now to the Plot using WPLOT." CLOSE #2 CHAIN "Tek2wplt.bas" 2818 STOP 3040 REM OPTION 2. BEHAVIOR IF FREQUENCY IS CHANGED. 3042 CALL PAGER 3044 PRINT "FREQUENCY BEHAVIOR of an LRC circuit." 3046 PRINT 3048 PRINT " Just as a mechanical system has a natural resonance frequency" 3050 PRINT "so does an electrical circuit. This is easily seen for our LRC" 3052 PRINT "circuit, if you recap that the maximum current i max is given as:" 3054 PRINT " i max = E max" 3055 PRINT " ------------" 3056 PRINT " [ R^2 +{ wL -1/wC}^2 ] ^.5" 3058 PRINT 3060 PRINT " Not this expression has a resonance demoninator. That is it" 3062 PRINT "does change its value as w changes. The current i max varies" 3063 PRINT "with the angular frequency w and has an absolute maximum when" 3064 PRINT " the inductive and capacitive reactances are equal. XL=XC." 3065 PRINT "For this circuit, this happens when w=1/sqrt(LC)." 3066 wr = 1 / SQR(L * C) 3067 PRINT " For your values of LRC, W resonance ="; wr; " radians per sec." PRINT "or "; wr / (2 * pi); " Hz" x0 = SQR(L / C) Q = x0 / R PRINT " The Q of this circuit is "; Q 3068 CALL PAGER 3070 PRINT "Now we will calculate i max vs w, and plot it." 3120 REM TEKTRONIX OUT PUT FOR TIME BEHAVIOR 3122 OPEN "PLTTEK.DAT" FOR OUTPUT AS #2 3124 NPTS = 0 3126 FOR w = .01 * wr TO 2! * wr STEP wr * .01 3128 NPTS = NPTS + 1 3130 E(NPTS) = Emax / (SQR(R ^ 2 + (w * L - 1 / (w * C)) ^ 2)) 3132 T(NPTS) = w 3136 NEXT w 3138 PRINT #2, 1 3140 PRINT #2, 1 3142 PRINT #2, NPTS 3144 PRINT #2, " CURRENT MAX"; "" 3146 PRINT #2, "ANGULAR FREQUENCY IN RADS/S"; "" 3148 PRINT #2, "I MAX VS W FOR LRC CIRCUIT"; "" 3150 PRINT #2, " Frequency behavior for Q ="; Q; " from PHASOR1" 3152 FOR I = 1 TO NPTS 3154 PRINT #2, T(I), E(I) 3156 NEXT I 3158 PRINT "Now do the PLOT." CLOSE #2 CHAIN "Tek2wplt.bas" 3160 STOP 3300 END 3199 SUB PAGER 3200 PRINT , "Push RETURN to continue." 3230 INPUT DUM$ 3260 PRINT CHR$(12); END SUB