Single Element Antenna Program (for TS1000)

See all articles from QZX v8 n10
Author(s): Alex Burr (K5XY); Leslie Varnicle (WA3QLW)
Publication: QZX
Pub Details: QZX v8 n10 (Volume 8, Issue 10)
Date: September 1990
Pages: 5-7

WA3QLW has sent several simple useful ham programs for the TS1000 series of computers. This article is the first of several to be based on these programs. Comments have been added to the bare program to point out some programing techniques or to clarify some point of programing.

The first program helps calculate the length of simple single element antennas when the type of antenna and the frequency are known.

This program starts off by asking for the type of antenna desired. Then it asks for the frequency range to be covered. Lastly it asks for the intervals in that frequency range at which intermediate lengths are to be calculated. Although it is not explicitly stated, the program will only calculate 15 different frequencies at one time. The program does not consider bandwidth of the antenna or the input impedance of the antenna when operated off frequency.

In the program which follows, you might want to systematize the line numbering. Many people make it a practice to start a basic program with line 100 and to increment the line numbers in units of 10.

   2 PRINT "SINGLE ELEMENT ANTENNAS"
4 PRINT "DIPOLES, VERTICALS, ECT"
6 PRINT "SELECT FOLLOWING"
7 PRINT "1/4 W PRESS 1"
8 PRINT "1/2 W PRESS 2"
9 PRINT '5/8 W PRESS 3"
10 PRINT "3/4 W PRESS 4"
12 IF INKEY$ = "" THEN GOTO 12
13 LET A$ = INKEY$
15 IF A$ = "1" THEN LET K = 234000
18 IF A$ = "2" THEN LET K = 468000
20 IF A$ = "3" THEN LET K = 585000
25 IF A$ = "4" THEN LET K = 702000
30 PAUSE 50
35 CLS
40 PRINT "INPUT LOWER BAND EDGE IN KHZ"
50 INPUT F1
55 PRINT F1
60 PRINT "INPUT UPPER BAND EDGE IN KHZ"
70 INPUT F2
75 PRINT F2
80 PRINT "INPUT FREQ INCREMENT INKHZ"
90 INPUT F3
95 PRINT F3
120 PRINT "ARE ALL ENTRIES OK? Y/N"
125 IF INKEY$ = "" THEN GOTO 125
130 LET C$ = INKEY$
132 PAUSE 20
135 IF C$ = "Y" THEN GOTO 143
140 IF C$ = "N" THEN GOTO 35
143 CLS
145 FOR X = 1 TO 15
146 LET F = F1
150 LET L = K/F
160 PRINT F1;" KHZ = ";L;" FEET"
170 LET F1 = F1 + F3
180 IF F1 .= F2 + F3 THEN GOTO 300
190 LET X = X + 1
195 IF X <= 15 THEN GOTO 146
200 IF X >= 15 THEN GOTO 386
210 NEXT X
300 PRINT
305 PRINT "ADDITIONAL FREQS OUT OF"
310 PRINT "UPPER RANGE LIMIT"
340 PRINT
345 PRINT "PRESS 1 FOR NEW DESIGN"
350 PRINT "PRESS 2 TO STOP"
355 IF INKEY$ = "" THEN GOTO 355
360 LET B$ = INKEY$
365 IF B$ = "1" THEN GOTO 375
370 IF B$ = "2" THEN GOTO 390
375 CLS
380 GOTO 6
386 PRINT "MAX CALCULATION LIMIT REACHED"
387 GOTO 340
390 STOP
9998 SAVE "ANt"
9999 GOTO 2

Now let us look at a few of the lines in more detail.

The lines from 7 to 25 give you a menu of choices and act on your choice. Line 12 is particularly interesting. It uses a common technique. The INKEY$ command asks for a single character of keyboard input but it does not wait for it. This line repeats itself until a key, any key, is pressed.

Line 13 assignes the INKEY$ value to a variable for use in the program.

Line 35, of course, clears the screen.

Lines 40 to 45 ask for multicharacter input. The program waits for an ENTER before continuing. The program quite properly prints out your input so you can see that the correct values have been entered.

Line 150 is the key to the whole program. It is the line which calculates the desired result. All the other lines just get the data into the program and print the results out.

Lines 145 to 210 are a FOR NEXT loop. More about them later.

The last two lines are a common Sinclair way to semi-automatically save the program once it is typed in. Just command the computer to GOTO 9998.

There are several things, besides improving the output display, that can be done to improve this program. There are two places noted here which you can work on before some suggestions are made next month.

The first has to do with input error checking. When the program requests input in lines 12, 120, and 355 no attempt at error checking is made. Can you create an addition to the program that will reject unexpected input?

The FOR NEXT loop mentioned earlier has a number of ways to exit the loop. What is the purpose of lines 190 to 200. Can you think of other ways to carry out these purposes?

Work out solutions to these questions and compare your answers to the answers which will be given next month.