From: snarfy@cruzio.santa-cruz.ca.us
Newsgroups: sci.physics
Subject: Resonance BASIC program
Keywords: Snarfy's program to evaluate impedance changes
Date: Tue, 25 Aug 92 13:55:17 PDT
Reply-To: snarfy@cruzio.santa-cruz.ca.us


10 FOR I = 1 TO 12
20 PRINT
30 NEXT I
40 PRINT "                                  SNARFY'S "
50 PRINT "                Ohm's Law for Resonant Circuits Demo Program "
60 PRINT
70 PRINT "                        Press a Key run the program"
80 CASE=1
90 Z$=INKEY$:IF Z$="" THEN 90
100 CLS
110 SCREEN 2
120 RCOND=0
130 R=0
140 S=0
150 CUF=0
160 LMH=0
170 SEQ=0
180 PRINT "          CASE  1 "
190 PRINT
200 REM CASE 3
210 PRINT "     _____ SPACE ______  Distance between elements:";SPACE;" m"
220 PRINT "    |   -~- - -~- -~- -|- -.   "
230 PRINT "    v        |         v   .   "
240 PRINT "    *--------*---------*   .   "
250 PRINT "    |                  |   .   "
260 PRINT " ___|___              (_   s   "
270 PRINT "  _____               (_   .   "
280 PRINT "    |                 (_   .   "
290 PRINT "    | C1 ^             | L1.   C1=";CUF;" ufd L1=";LMH;"mH"
300 PRINT "    |    .       *-----*   .   "
310 PRINT "    |    .   Sw1 |     |   .   "
320 PRINT "    \  I(circ) . o   . \  VARS        VARS=";VARS
330 PRINT "    /    .     \     . /   .   "
340 PRINT "    \    .      \    . \   .   "
350 PRINT "    / R2 .       *   . / R1.  R2=";S;" Ohms  R1=";R;"Ohms"
360 PRINT "    \    `- -<- -| - ' \   .   "
370 PRINT "    |            |     |   s   "
380 PRINT "    *--------*---*-----*   .   "
390 PRINT "         ~-~-|- <-- - -~- -    "
400 PRINT "            (S) Freq           "
410 IF CASE=3 THEN 2900 ELSE 420
420 IF CASE=4 THEN 3190 ELSE 430
430 IF SEQ=0 THEN 490 ELSE 440
440 IF SEQ=1 THEN 540 ELSE 450
450 IF SEQ=2 THEN 590 ELSE 460
460 IF SEQ=3 THEN 630 ELSE 470
470 IF SEQ=4 THEN 670 ELSE 480
480 IF SEQ=5 THEN 710
490 INPUT " Ohms Value of R1 ";R
500 RCASE1=R
510 SEQ=1
520 CLS
530 GOTO 180
540 INPUT " Ohm's value of R2 ";S
550 SCASE1=S
560 SEQ=2
570 CLS
580 GOTO 180
590 INPUT " C1 Capacitance in Microfarads ";CUF
600 SEQ=3
610 CLS
620 GOTO 180
630 INPUT " L1 Inductance in Millihenries ";LMH
640 SEQ=4
650 CLS
660 GOTO 180
670 INPUT "VARS (Volt-Amps Reactive) value of circulating energy";VARS
680 SEQ=5
690 CLS
700 GOTO 180
710 INPUT "IS THIS CORRECT? If yes ,hit [PRTSCR] now for printer output.Y/N";YN$
720 IF YN$="Y" THEN 1030
730 IF YN$="y" THEN 1030
740 CLS
750 GOTO 130
760 Z$=INKEY$: IF Z$="" THEN 760
770 GOTO 1030
780 CLS:PRINT " These are the CASE 2 values.."
790 REM CASE 4
800 PRINT
810 PRINT "    |<- - -SPACE- - ->|   Distance between elements=";SPACE;"m"
820 PRINT "    V        | ~- - - - -~- -.  "
830 PRINT "    *--------*--------*      .  "
840 PRINT "    |                 |      .  "
850 PRINT " ___|___             (_      s  "
860 PRINT "  _____              (_      .  "
870 PRINT "    |    ^           (_      .  "
880 PRINT "    | C1 .     .--    | L1  ^.v C1=";CUF;" uf,L1= ";LMH;"MH"
890 PRINT "    |    .     v  ____|      .  "
900 PRINT "    \  I(circ) . |    \      .  "
910 PRINT "    /    .     . *    /    VARS        VARS=";VARS
920 PRINT "    \    .     . ^Sw1 \      .  "
930 PRINT "    /    .     v |    / R1   s  "
940 PRINT "    \ R2 .     . *    \      .  R2=";S;"   OHM,R1= .2 OHM"
950 PRINT "    |    `- <- ' |    |     ^.v "
960 PRINT "    *--------*---*----*      .  "
970 PRINT "        ~- - -~- - - - -~- - '  "
980 PRINT "             |                 I(circ)=";I;" AMPS Reactive)"
990 PRINT "             *                 "
1000 PRINT " Hit a key for Calculation Process.."
1010 Z$=INKEY$: IF Z$="" THEN 1010
1020 CLS:GOTO 1140
1030 PRINT "..Converting units: "
1040 C=CUF*.000001
1050 PRINT "Microfarads to farads C1 uF * (.000001)=";C;" Farads"
1060 L=LMH*.001
1070 PRINT "Millihenries to henries L1 mH * (.001)=";L;" Henries"
1080 F=1/(6.2831853#*SQR(L*C))
1090 XC=1/(6.2831853#*F*C):XL=XC
1100 PRINT "Calculating Resonant Frequency = 1/6.2831853*SQR(L*C)=";F
1110 PRINT "At Resonance X(l) = X(c) and Z = R. "
1120 PRINT
1130 PRINT "VARS (Volt-Amps Reactive) value of circulating energy ";VARS
1140 IF CASE=2 OR CASE=4 THEN 1150 ELSE 1180
1150 R=.2
1160 RT=R+S+XC+XL+RCOND:RTC2=RT
1170 GOTO 1190
1180 RT=R+S+XC+XL+RCOND:RTC1=RT
1190 PRINT "Calculating R(total) = R1+R2+Xl+Xc -> R(t) = ";RT;" Ohms."
1200 V=SQR(VARS*RT):I=V/RT
1210 PRINT "Calculating Reactive Current= ";I;" Amps."
1220 V=SQR(RT*VARS):PRINT "Reactive volts across circuit =";V
1230 WR1=(I^2)*R:WR2=(I^2)*S:WXC=(I^2)*XC:WXL=WXC:
1240 PRINT "Calculating VARS used by C1= ";WXC
1250 PRINT "Calculating VARS used by L1= ";WXL
1260 PRINT "Calculating VARS used by R1 = ";WR1;
1270 PRINT "Calculating VARS used by R2 = ";WR2;
1280 IF CASE=2 THEN 1410
1290 WR1A=WR1:WR2B=WR2
1300 PRINT:PRINT:PRINT "End of SW1 OPEN calculations."
1310 PRINT "Assuming floating current AC input at resonant frequency (as load"
1320 PRINT "resistance decreases current increases...)":PRINT
1330 PRINT "Setting R1 value to .2 ohms"
1340 PRINT "Press a key for sw1 CLOSED (R1 shorted) calculations ..."
1350 Z$=INKEY$:IF Z$="" THEN 1350
1360 CASE=2
1370 RCASE1=R
1380 R=.2
1390 PRINT "Setting R1 value to .2 ohms":RT=R+S+XC+XL+RCOND:VARS=V^2/RT:I=SQR(VARS/RT)
1400 GOTO 780
1410 I1=V/RTC1:I2=V/RTC2
1420 PRINT "Reactive Amps     -         Sw1  OPEN  =";I1
1430 PRINT "Reactive Amps     -         Sw1 CLOSED =";I2
1440 ICH=I2-I1
1450 PRINT "Change in Reactive Amps = ";ICH
1460 PRINT "Current Probe at R2 detects ";ICH;" Reactive amps change !"
1470 PRINT:PRINT "Press a key to continue."
1480 Z$=INKEY$:IF Z$="" THEN 1480
1490 CLS:PRINT:PRINT:PRINT
1500 PRINT "For those so inclined to mathematical manipulation , solve the "
1510 PRINT "following problem :"
1520 PRINT "What is the value of the net gain (or loss) in joules , as the "
1530 PRINT "capacitive leg of your circuit awaits news that Sw1 has opened "
1540 PRINT "across L1 ,which is separated from C1 by two wavelengths (B) of "
1550 PRINT "copper conductor of radius (A)? "
1560 PRINT:PRINT
1570 PRINT "Hint: don't forget the inductance of the wire which adds to L1,"
1580 PRINT "Also , remember to factor in the additional wire resistance. "
1590 PRINT
1600 PRINT "Relevant formulas- L(wire,in uH)=(.0002*B)*(((LOG(2*B/A))-.75))
1610 PRINT "                   R(ohms,per 1000 ft)=6.826*((2*A)^-2) (@ 25C)
1620 PRINT
1630 PRINT "For those who object to the conclusion that energy is either"
1640 PRINT "gained or lost - what factor should we use to modify ohm's law"
1650 PRINT "for the new value of VARs/T(delay) after the news of the "
1660 PRINT "impedance change is received at R2?"