Ham Radio Programs

Date: 198x
Type: Cassette
Platform(s): TS 1000

Three programs of use to radio amateurs.

  • HASH TABLE: A program to keep track of calls during a contest
  • TB: A program to compute distance based on LAT / LONG of endpoints
  • CHIM: A program to compute cable impedance

“CHIM”, calculates the characteristic impedance (Z₀) of five transmission-line types—single coaxial, balanced shielded, two-wire, parallel strip, and two parallel lines with sheath return—using standard RF engineering formulae involving natural logarithms and square roots of the relative dielectric constant.

“HASH TABLE”, implements an open-addressing hash table for amateur radio contest duplicate-call detection, hashing six-character callsigns by summing their character codes modulo 1000 and using linear probing for collision resolution.

“TB”, computes the true bearing and great-circle distance between two geographic coordinates entered in decimal degrees, outputting results in nautical miles, statute miles, and kilometres using spherical trigonometry (ATN, ACS, SIN, COS, TAN).


Program 1: CHIM — Characteristic Impedance Calculator

The program prompts for a transmission-line type (1–5) and a relative dielectric constant, then dispatches via GOTO 100*A to one of five calculation blocks at lines 100, 200, 300, 400, and 500. This computed GOTO is a classic Sinclair BASIC dispatch idiom that avoids an explicit IFTHEN chain.

Transmission-Line Formulae

TypeLineFormula
Single coaxial150Z = (138/√E) × log₁₀(D/R)
Balanced shielded270Z = (276/√E) × log₁₀(2V(1−S²)/(1+S²))
Two-wire360Z = (276/√E) × log₁₀(S+√(S²−1))
Parallel strip480Z = 377×H/W/√E
2 par. lines, sheath return570Z = (69/√E) × log₁₀(V/2/S²×(1−S⁴))

Natural logarithms (LN) are converted to base-10 by dividing by LN 10, since the standard RF impedance constants (138, 276, 69) assume log₁₀. The subroutine at line 600 collects geometric parameters H, D, and R, with branching at lines 630 and 640 to skip inapplicable inputs for types 3 and 4.

Error handling stores the offending section’s starting line number in L and jumps to line 720, which prints “ERROR, REENTER” and then executes GOTO L to re-enter that section. After a successful calculation, control returns to line 25 to re-prompt for the dielectric constant, allowing repeated calculations of the same line type.

Notable Anomaly — CHIM

Line 37 validates that A is an integer between 1 and 5, but the check IF E>0 THEN GOTO 100*A at line 55 only verifies the dielectric constant is positive; it does not catch zero or negative-but-not-entered values that might have been left from a previous run, though in practice INPUT always replaces the variable.

Program 2: HASH TABLE — Contest Dupe Checker

This program maintains a 1000-element string array A$ of six-character callsigns, initialised to ****** as a sentinel, to detect duplicate (“dupe”) calls in an amateur radio contest. It uses FAST mode during the slow initialisation loop (lines 6–31) for speed, then returns to SLOW for interactive use.

Hash Function and Collision Resolution

The hash is computed by summing the CODE values of all characters in the padded six-character callsign (lines 55–65), then taking the result modulo MAX (1000) using H - INT(H/MAX)*MAX (line 70) — the standard Sinclair BASIC modulo idiom, since MOD is not a keyword. Collisions are resolved by linear probing: H is incremented (line 85) and wrapped (line 90) until either the callsign or an empty slot is found.

  • Input strings shorter than six characters are padded with spaces (lines 47–49) using a GOTO-based loop, since FOR over a dynamic length would require a variable already set.
  • The sentinel value ****** is safe because no valid amateur callsign consists solely of asterisks.
  • The array is printed in hash-table order (not insertion order) at termination (lines 120–135), so the output listing is not alphabetical.
  • There is no deletion mechanism; the table fills permanently for the duration of the contest session.

Program 3: TB — True Bearing and Great-Circle Distance

The program converts decimal-degree inputs to radians (multiplying by PI/180) and applies spherical trigonometry. Longitude difference L is normalised to the range (−π, π] at lines 130–140 to ensure correct quadrant handling.

Bearing Calculation

Lines 150–230 compute the true bearing using the four-quadrant arctangent method. Because Sinclair BASIC provides only single-argument ATN, quadrant correction is done manually:

  1. Compute a raw angle C = ATN(1/CC) (line 170).
  2. If L > 0 and C > 0, no adjustment is needed (line 180 → 230).
  3. If L < 0 and C < 0, add 2π (line 220).
  4. Otherwise, add π (line 200).

Distance Calculation

Line 250 uses ACS (SIN A*SIN B + COS A*COS B*COS L) — the spherical law of cosines — to find the angular separation, which is then converted to nautical miles (×60), statute miles (×1.1508), and kilometres (×1.852).

The FAST call at line 112 speeds up the trigonometric computations before displaying results. Convention is unusual: West longitudes are positive and East negative (opposite to the ISO standard), matching the comment at lines 14–16.

Potential Issue — TB

Line 160 computes CC = (1/TAN L) × COS(A+PHI) / SIN PHI. If L = 0 (same meridian) or SIN PHI = 0, a division-by-zero error will occur with no guard. Similarly, ATN(1/CC) at line 170 fails if CC = 0.

Content

Appears On

Related Products

Related Articles

Related Content

Image Gallery

Ham Radio Programs

Source Code

  10 REM "CHIM"
  15 CLS 
  20 PRINT "CHAR. IMPEDANCE"
  25 PRINT 
  27 PRINT "ENTER TYPE (1-5)?";
  30 INPUT A
  35 PRINT A
  37 IF A<>INT A OR A<1 OR A>5 THEN GOTO 60
  40 PRINT "ENTER REL. DIAL. CONSTANT?"; 
  45 INPUT E
  50 PRINT E
  55 IF E>0 THEN GOTO 100*A
  60 LET L=25
  65 GOTO 720
 100 PRINT "SINGLE COAX. LINE"
 110 GOSUB 650
 120 IF R>0 AND D>R THEN GOTO 150
 130 LET L=110
 140 GOTO 720
 150 LET Z=138/SQR E*LN (D/R)/LN 10
 160 GOTO 580
 200 PRINT "BAL. SHIELDED LINE"
 210 GOSUB 600
 220 IF R>0 AND H>R AND D>H+R THEN GOTO 250
 230 LET L=210
 240 GOTO 720
 250 LET V=H/R
 260 LET S=H/D
 270 LET Z=276/SQR E*LN (2*V*(1-S*S)/(1+S*S))/LN 10
 280 GOTO 580
 300 PRINT "2 WIRE LINE"
 310 GOSUB 600
 320 IF R>0 AND H>R THEN GOTO 350
 330 LET L=310
 340 GOTO 720
 350 LET S=H/R
 360 LET Z=276*LN (S+SQR (S*S-1))/LN 10/SQR E
 370 GOTO 580
 400 PRINT "PARALLEL STRIP LINE"
 410 PRINT "CONDUCTOR WIDTH W?";
 420 INPUT W
 430 PRINT W
 440 GOSUB 600
 450 IF H>0 AND W>0 THEN GOTO 480
 460 LET L=410
 470 GOTO 720
 480 LET Z=377*H/W/SQR E
 490 GOTO 580
 500 PRINT "2 PAR. LINES, SHEATH RET."
 510 GOSUB 600
 520 IF R>0 AND H>R AND D>H+R THEN GOTO 550
 530 LET L=510
 540 GOTO 720
 550 LET V=H/R
 560 LET S=H/D
 570 LET Z=69/SQR E*LN (V/2/S/S*(1-S**4))/LN 10
 580 PRINT "ZO=";Z;" OHM"
 590 GOTO 25
 600 PRINT "SPACING H?";
 610 INPUT H
 620 PRINT H
 630 IF A=3 THEN GOTO 680
 640 IF A=4 THEN RETURN 
 650 PRINT "OUTER DIAM. D?";
 660 INPUT D
 670 PRINT D
 680 PRINT "COND. DIAM. R?";
 690 INPUT R
 700 PRINT R
 710 RETURN 
 720 PRINT "ERROR, REENTER"
 730 GOTO L

   1 REM "HASH TABLE"
   2 PRINT AT 8,1;"THIS IS A PROGRAM TO KEEP TRACK"
   3 PRINT "   OF CALLS DURING A CONTEST."
   4 PRINT 
   5 PRINT "  TO STOP INPUT -1."
   6 FAST 
  10 LET MAX=1000
  15 DIM A$(MAX,6)
  20 FOR I=1 TO MAX
  25 LET A$(I)="******"
  30 NEXT I
  31 SLOW 
  35 PRINT AT 21,5;"INPUT CALL"
  40 INPUT I$
  41 CLS 
  45 IF I$="-1" THEN GOTO 120
  47 IF LEN (I$)=6 THEN GOTO 50
  48 LET I$=I$+" "
  49 GOTO 47
  50 LET H=0
  55 FOR J=1 TO LEN (I$)
  60 LET H=H+CODE I$(J)
  65 NEXT J
  70 LET H=H-INT (H/MAX)*MAX
  75 IF A$(H)=I$ THEN GOTO 100
  80 IF A$(H)="******" THEN GOTO 110
  85 LET H=H+1
  90 LET H=H-INT (H/MAX)*MAX
  95 GOTO 75
 100 PRINT AT 10,5;I$;"  IS A DUPE CALL"
 105 GOTO 35
 110 LET A$(H)=I$
 115 GOTO 35
 120 FOR L=1 TO MAX
 125 PRINT TAB (10);A$(L)
 130 PRINT 
 135 NEXT L

  10 REM "TB"
  12 SLOW 
  14 PRINT "N LATITUDES + / S LATITUDES -"
  16 PRINT "W LONGITUDES + / E LONGITUDES -"
  18 PRINT 
  20 PRINT "YOUR LATITUDE?"
  30 INPUT A
  40 LET A=A*PI/180
  50 PRINT "YOUR LONGITUDE?"
  60 INPUT L1
  65 LET L1=L1*PI/180
  70 PRINT "OTHER LATITUDE?"
  80 INPUT B
  90 LET B=B*PI/180
 100 PRINT "OTHER LONGITUDE?"
 110 INPUT L2
 112 FAST 
 115 LET L2=L2*PI/180
 120 LET L=L1-L2
 130 IF L>PI THEN LET L=L-2*PI
 140 IF L<-PI THEN LET L=L+2*PI
 150 LET PHI=ATN (COS L/TAN B)
 160 LET CC=((1/TAN L)*COS (A+PHI))/SIN PHI
 170 LET C=ATN (1/CC)
 180 IF L>0 AND C>0 THEN GOTO 230
 190 IF L<0 AND C<0 THEN GOTO 220
 200 LET TB=C+PI
 210 GOTO 230
 220 LET TB=C+2*PI
 230 LET TB=TB*180/PI
 240 PRINT "TRUE BEARING= ";TB;" DEGREES"
 250 LET D=ACS (SIN A*SIN B+COS A*COS B*COS L)
 255 LET D=D*180/PI
 260 LET DIS=D*60
 270 LET DIS1=DIS*1.1508
 280 LET DIS2=DIS*1.852
 285 PRINT 
 287 PRINT "DISTANCE="
 290 PRINT DIS;" NAUTICAL MILES"
 300 PRINT DIS1;" STATUTE MILES"
 310 PRINT DIS2;" KILOMETERS"

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top