10 REM System dependent stuff 20 ESC$=CHR$(27) 30 CL$=ESC$+"[2J" : REM clear screen 40 BL$=CHR$(7) 50 DEF FNC$(X)=RIGHT$(STR$(X),LEN(STR$(X))-1) 60 DEF FNXY$(X,Y)=ESC$+"["+FNC$(Y)+";"+FNC$(X)+"H" : REM cursor address 70 DIM V(48) 80 REM Now start the program 90 PRINT CL$ 100 RESTORE 110 PRINT " Ratio and potential divider program" 120 PRINT " -----------------------------------" 130 PRINT 140 PRINT " by Greg Trice 150 PRINT:PRINT:PRINT 160 PRINT " This program evaluates the optimum E12 and E24 resistor values" 170 PRINT " needed to realize a given ratio or potential divider and gives" 180 PRINT " the resultant percentage error." 190 PRINT " Input as ratio...........[1]" 200 PRINT " or potential divider.....[2]" 210 INPUT Q 220 ON Q GOTO 350,240 230 GOTO 90 240 PRINT CL$ 250 INPUT "Input voltage";VI 260 INPUT "Output voltage";VO 270 IF VI>VO THEN GOTO 330 280 PRINT:PRINT:PRINT 290 PRINT BL$;"Input must be greater than output" 300 PRINT:PRINT: 310 INPUT "Press any key to continue";A$ 320 GOTO 240 330 R=(VI-VO)/VO 340 GOTO 380 350 PRINT CL$ 360 INPUT "Ratio desired";R 370 REM Make ratio >1 380 IF R<1 THEN R=1/R 390 REM Shift decades if needed 400 D=1 410 IF R<10 THEN GOTO 450 420 R=R/10 430 D=D*10 440 GOTO 410 450 FOR I=1 TO 24 460 READ X 470 V(I)=X 480 V(I+24)=X*10 490 NEXT 500 N=1 510 GOSUB 750 520 E24A=V(VAL1) 530 E24B=V(VAL2) 540 E24E=ER 550 N=N+1 560 GOSUB 750 570 E12A=V(VAL1) 580 E12B=V(VAL2) 590 E12E=ER 600 E24B=E24B*D 610 E12B=E12B*D 620 E24E=E24E*100/R 630 E12E=E12E*100/R 640 PRINT CL$ 650 PRINT "The best E24 values are ";E24A;" and ";E24B 660 PRINT "The error is ";E24E;"%" 670 PRINT 680 PRINT "The best E12 values are ";E12A;" and ";E12B 690 PRINT "The error is ";E12E;"%" 700 PRINT:PRINT:PRINT 710 PRINT "Another run (y/n)?"; 720 INPUT A$ 730 IF A$="Y" OR A$="y" THEN GOTO 90 740 SYSTEM 750 ER=10 760 FOR I=1 TO 24 STEP N 770 X=V(I)*R 780 FOR J=I TO 48 STEP N 790 P=ABS(V(J)-X) 800 IF P>=ER THEN GOTO 840 810 VAL1=I 820 VAL2=J 830 ER=P 840 NEXT J 850 NEXT I 860 RETURN 870 DATA 1.0,1.1,1.2,1.3,1.5,1.6,1.8,2.0,2.2,2.4,2.7,3.0 880 DATA 3.3,3.6,3.9,4.3,4.7,5.1,5.6,6.2,6.8,7.5,8.2,9.1