Here is a short program which will help you determine the values of resistance to use in attenuators. The program asks you for input impedance, the output impedance, and the attenuation desired. It then calculates the three resistors needed to construct either a pi or a T attenuator with the characteristics you desired.
As in previous programs, most of the lines deal with input and output requirements. But there are three areas of computation here. The first calculates a minimum loss for the impedances selected. This is done in lines 60 and 70. Two groups of lines, following line 120 and line 170, do the actual resistance calculations.
Pairs of lines at lines 30, 50, and 100 illustrate a good programing technique. The first line of the pair asks for some input. The second of the pair prints that input right back out so that you can check that the intended value got into the computer.
10 PRINT "T AND PI ATTENUATORS"
20 PRINT "ENTER INPUT IMPEDANCE IN OHMS"
30 INPUT Z1
35 PRINT Z1
40 PRINT "ENTER OUTPUT IMPEDANCE IN OHMS"
50 INPUT Z0
55 PRINT Z0
60 LET T=9SQR9Z1/Z0)+SQR(Z1/Z0-1))*2
70 LET M=10LN(T)/2.3025
80 PRINT "MINIMUM PAD LOSS IS ";M;"DB"
90 PRINT "WHAT PAD LOSS IN DB IS DESIRED?"
100 INPUT L
105 OUTPUT L
110 LET L=10*(L/10)
120 PRINT "t PAD ATTENUATOR"
130 LET R3=2*SQR(L*Z1*Z0)/(L-1)
140 LET R1=Z1*(L+1)/(L-1)-R3
150 LET R2=Z0*(L+1)/(L-1)-R3
160 GOSUB 250
170 PRINT "PI PAD ATTENUATOR"
180 LET R3=(L-1)/2*SQR(Z1*Z0/L)
190 LET T=(L+1)/(L-1)/Z1-1/R3
200 LET R1=1/T
210 LET T=(L+2)/(L-1)/Z0-1/R3
220 LET R2=1/T
230 GOSUB 250
240 PRINT "PRESS 1 TO CONTINUE"
242 IF INKEY$="" THEN GOTO 242
244 LET A$=INKEY$
246 IF A$="1" THEN CLS
248 GOTO 10
249 IF A$="" THEN GOTO 290
250 PRINT "R1=";R1;"OHMS"
260 PRINT "R2=";R2'"OHMS"
270 PRINT "R3=";R3;"OHMS"
280 RETURN
290 STOP
9998 SAVE "ATTn"
9999 GOTO 10


This is a good program that can save one a lot of calculation in both audio and RF work. However there are a couple of rough spots in it. See if you can figure them out and propose changes in the program before it is discussed in QZX again.