home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 1
/
HamRadio.cdr
/
misc
/
eepd2
/
convshyz.bas
< prev
next >
Wrap
BASIC Source File
|
1979-12-31
|
4KB
|
213 lines
1 REM *** S. NOVAK , OCT ,84 *****
10 REM " PARAM. CONV. ",8
20 PI=3.14159265#
30 PRINT " PARAM. CONVERSION PROGRAM "
40 DIM R(4),I(4),M(4),A(4),A$(4)
50 A$(1)=" INPUT PARAM. (11)="
60 A$(2)=" REVERSE PARAM. (12)="
70 A$(3)=" FORWARD PARAM. (21)="
80 A$(4)=" OUTPUT PARAM. (22)="
90 INPUT " PARAMETERS SUPPLIED ?(Z,Y,H,S,A)";P$
100 INPUT" POLAR FORM (P) OR RE. AND IM. PARTS (R)";R$
110 INPUT" PARAMETER REQUIRED (Z,Y,H,S,A)";S$
120 IF P$="S" OR S$="S" THEN GOSUB 1600
130 IF R$="P" THEN PRINT " ENTER MAGNITUDE AND ANGLE IN DEGREES"
140 IF R$="R" THEN PRINT " ENTER REAL AND IMAG. PART"
150 FOR K=1 TO 4
160 PRINT A$(K)
170 INPUT R(K),I(K)
180 IF R$="P" THEN GOSUB 1800
190 NEXT K
200 REM MULTIPLY BY Z0 **************
210 IF P$="Y" AND S$="S" THEN GOSUB 1960
220 REM CALC. P12*P21 AND DP**********
230 R1=R(2)
240 I1=I(2)
250 R2=R(3)
260 I2=I(3)
270 GOSUB 1700
280 P=RE
290 Q=IM
300 R1=R(1)
310 I1=I(1)
320 R2=R(4)
330 I2=I(4)
340 GOSUB 1700
350 R=RE-P
360 I=IM-Q
370 R1=R(1)
380 REM SELECT PARAM. ******************
390 IF P$="Z" AND S$="Y" OR P$="Y" AND S$="Z" THEN GOSUB 740
400 IF P$="A" AND S$="Z" OR P$="Z" AND S$="A" THEN GOSUB 960
410 IF P$="H" AND S$="Z" OR P$="Z" AND S$="H" THEN GOSUB 1160
420 IF P$="Y" AND S$="S" OR P$="S" AND S$="Y" THEN GOSUB 1360
430 IF P$="H" AND S$="Y" OR P$="Y" AND S$="H" THEN GOSUB 540
440 REM DUAL CONVERSIONS **************
450 IF P$="Y" AND S$="A" THEN 480
460 IF P$="A" AND S$="Y" THEN 510
470 GOTO 2100
480 P$="Z"
490 GOSUB 740
500 GOTO 200
510 P$="Z"
520 GOSUB 960
530 GOTO 200
540 REM CONV. Y TO H OR H TO Y *********
550 R2=R(1)
560 I2=I(1)
570 R1=1
580 I1=0
590 K=1
600 GOSUB 2000
610 R1=-R(2)
620 I1=-I(2)
630 K=2
640 GOSUB 2000
650 R1=R(3)
660 I1=I(3)
670 K=3
680 GOSUB 2000
690 R1=R
700 I1=I
710 K=4
720 GOSUB 2000
730 RETURN
740 REM CONV. Y TO Z OR Z TO Y *********
750 R3=R(1)
760 I3=I(1)
770 R1=R(4)
780 I1=I(4)
790 R2=R
800 I2=I
810 K=1
820 GOSUB 2000
830 R1=-R(2)
840 I1=-I(2)
850 K=2
860 GOSUB 2000
870 R1=-R(3)
880 I1=-I(3)
890 K=3
900 GOSUB 2000
910 R1=R3
920 I1=I3
930 K=4
940 GOSUB 2000
950 RETURN
960 REM CONV. A TO Z OR Z TO A ********
970 R2=R(3)
980 I2=I(3)
990 R1=R(1)
1000 I1=I(1)
1010 K=1
1020 GOSUB 2000
1030 R1=R
1040 I1=I
1050 K=2
1060 GOSUB 2000
1070 R1=1
1080 I1=0
1090 K=3
1100 GOSUB 2000
1110 R1=R(4)
1120 I1=I(4)
1130 K=4
1140 GOSUB 2000
1150 RETURN
1160 REM CONV. H TO Z OR Z TO H *******
1170 R2=R(4)
1180 I2=I(4)
1190 R1=R
1200 I1=I
1210 K=1
1220 GOSUB 2000
1230 R1=R(2)
1240 I2=I(2)
1250 K=2
1260 GOSUB 2000
1270 R1=-R(3)
1280 I1=-I(3)
1290 K=3
1300 GOSUB 2000
1310 R1=1
1320 I1=0
1330 K=4
1340 GOSUB 2000
1350 RETURN
1360 REM CONV. Y TO S OR S TO Y *******
1370 R3=R(1)
1380 I3=I(1)
1390 R1=1+R(4)-R(1)-R
1400 I1=I(4)-I(1)-I
1410 R2=1+R(4)+R(1)+R
1420 I2=I(4)+I(1)+I
1430 IF P$="S" AND S$="Y" THEN R2=R2*Z0
1440 IF P$="S" AND S$="Y" THEN I2=I2*Z0
1450 K=1
1460 GOSUB 2000
1470 R1=-2*R(2)
1480 I1=-2*I(2)
1490 K=2
1500 GOSUB 2000
1510 R1=-2*R(3)
1520 I1=-2*I(3)
1530 K=3
1540 GOSUB 2000
1550 R1=1+R3-R(4)-R
1560 I1=I3-I(4)-I
1570 K=4
1580 GOSUB 2000
1590 RETURN
1600 INPUT " CHAR. IMP. OF THE LINE (Z0)=",Z0
1610 RETURN
1700 REM COMPL. NO MULT. SUB ************
1710 RE=R1*R2-I1*I2
1720 IM=I1*R2+R1*I2
1730 RETURN
1750 REM COMP. NO. DIV. SUB *************
1760 D=R2*R2+I2*I2
1770 RE=(R1*R2+I1*I2)/D
1780 IM=(I1*R2-R1*I2)/D
1790 RETURN
1800 REM POLAR TO RECT. ***************
1810 A=I(K)
1820 M=R(K)
1830 A=A*PI/180
1840 RE=M*COS(A)
1850 IM=M*SIN(A)
1860 R(K)=RE
1870 I(K)=IM
1880 RETURN
1900 REM RECT. TO POLAR ***************
1910 M=SQR(RE*RE+IM*IM)
1920 A=90*(SGN(IM)+(IM=0))
1930 IF RE=0 THEN 1950
1940 A=ATN(IM/RE)*180/PI+A*(1-SGN(RE))
1950 RETURN
1960 FOR K=1 TO 4
1970 R(K)=R(K)*Z0:I(K)=I(K)*Z0
1980 NEXT K
1990 RETURN
2000 REM SUB. STORE RESULTS ***********
2010 GOSUB 1750
2020 R(K)=RE
2030 I(K)=IM
2040 GOSUB 1900
2050 M(K)=M
2060 A(K)=A
2070 RETURN
2100 REM SUB. PRINT *******************
2110 PRINT " CALCULATED PARAMETER ="S$
2120 E=1E+08
2130 FOR K=1 TO 4
2140 PRINT A$(K)
2150 PRINT "RE","IM","MAG","ANGLE"
2160 PRINT INT(R(K)*E)/E, INT(I(K)*E)/E, INT(M(K)*E)/E, INT(A(K)*E)/E
2170 NEXT K
2180 INPUT " ANOTHER CALCULATION (Y OR N)";C$
2190 IF C$<>"Y" THEN END
2200 GOTO 90
(M(K)*E)/E, INT(A(K)*E)/E
2170 NEXT K
2180 INPUT " ANOTHER CALCULATION (Y OR N)";C$
2190 IF C$<>"Y"