Frequency Counter

See all articles from CATS v3 n9
Author(s): Roger Barker
Publication: CATS Newsletter
Pub Details: CATS v3 n9 (Volume 3, Issue 9)
Date: January 1986
Pages: 12

Frequency counter & alignment aid (Spectrum) – Roger, G4IDE

Now that more US hams are adding Spectrum ROM’s to their T/S 2068’s, the many programs in the newsletter of the Sinclair Anateur Radio User Group of Great Britain are becoming more useful. Here is an ingenious program which allows you to use your computer as an audio frequency meter.

For users of earlier T/S models see the article by KP4MD in the October 1984 issue of QZX.


This program displays the frequency of an audio tone input to the EAR socket of a 48K Spectrum. It uses the Spectrum interrupts as a timing reference & unless you have a poorly aligned Spectrum will give 0.1% or better accuracy!

The program also allows you to input a reference frequency & gives an audible indication of how near the reference frequency is to the input frequency. Be careful when entering the DATA statements – they must be EXACTLY as shown. A checksum is incorporated to trap errors.

When you RUN the program it will ask for a reference frequency; pressing ENTER at this point the program goes into counter-mode which displays the frequency input at the EAR socket, updated every second. If you input a reference frequency (line 30) then, besides displaying the frequency at the EAR socket, the program BEEPS according to the following rules. If your input is below reference frequency then it BEEPS a low tone; if above then it BEEPS a high tone. The length of the BEEP is proportional to the percentage error – if the error is 10% or greater then it’s about 1 second; the BEEP gets shorter as the %-age error decreases. When the frequency is within +/- 1 Hz of the reference, then 5 short BEEPS of a middle tone are given. This sounds complicated, but in practice is very simple to use. The great benefit is that when aligning TU’s, tone bursts, etc., you can keep your eyes on what you are doing & not have to keep looking at the screen. The Spectrum needs at least 500mv at the EAR socket for a reliable reading. The simple circuit below will amplify the input if needed.

Input amplifier circuit: CA3140 op amp, audio input to EAR socket, 3 to 5 volts
Input amplifier circuit: CA3140 op amp, audio input to EAR socket, 3 to 5 volts
   1 REM *** FREQUENCY COUNTER /
2 REM *** ALIGNMENT AID.
3 REM ***
4 REM *** G4IDE JANUARY 1985
5 REM ***
10 CLEAR 65278
15 LET TOTAL=0
17 FOR I=0 TO 84
20 READ A: LET TOTAL=TOTAL+A
22 POKE (65279+I),A
24 NEXT I
26 IF TOTAL<>11122 THEN PRINT "DATA ERROR!": STOP
30 INPUT "REFERENCE TONE IN HERTZ: "; LINE A$
40 IF A$="" THEN GO TO 500
50 FOR I=1 TO LEN A$
60 IF CODE A$(I)<48 OR CODE A$(I)>57 THEN GO TO 30
70 LET REF=VAL A$
80 IF REF<1 OR REF>30000 THEN GO TO 30
90 LET FREQ=INT ((USR 65298)/2)
100 PRINT AT 9,14;FREQ;" "
102 LET DIFF=FREQ-REF
103 IF DIFF>=-1 AND DIFF<=1 THEN GO TO 160
105 LET OFFSET=0
110 LET DIFF=10*DIFF/REF
120 IF DIFF<0 THEN LET DIFF=-DIFF: LET OFFSET=-50
130 IF DIFF>1 THEN LET DIFF=1
140 BEEP DIFF,40+OFFSET
150 GO TO 90
160 FOR I=1 TO 5
170 BEEP 1,20
180 NEXT I
190 GO TO 90
500 LET FREQ=INT ((USR 65298)/2)
510 PRINT AT 9,14;FREQ;" "
520 GO TO 500
1000 DATA 1,255,243,245,58,82,255,60,254,50
1010 DATA 32,1,175,50,82,255,241,251,201,243
1020 DATA 1,0,0,175,50,83,255,50,82,255
1030 DATA 111,62,254,237,71,237,94,251,58,82
1040 DATA 255,95,58,82,255,187,40,250,95,219
1050 DATA 254,230,64,87,173,40,2,3,106,58
1060 DATA 82,255,187,40,7,62,1,50,83,255
1070 DATA 24,233,58,83,255,167,40,227,243,237
1080 DATA 86,251,201,0,0

QZX 9/85
$12.00/yr
2025 O’Donnell Dr.
Las Cruces NM 88001


Perhaps this routine can be adapted to give a 3-d display of the mandelbrot set:

(MF)

ZX WORLD NEWS BULLETIN clipping: 3-D plot of SIN (X/13)*SIN (Y/6.5)*30 drawn by GRAPH
ZX WORLD NEWS BULLETIN clipping: 3-D plot of SIN (X/13)*SIN (Y/6.5)*30 drawn by GRAPH
  10 PRINT "INPUT AN EQUATION CO
NTAINING X OR Y OR BOTH"
20 DIM W(2,64)
30 INPUT Z$
40 CLS
50 FAST
60 FOR Y=0 TO 21
70 FOR X=0 TO 42
80 LET Z=VAL Z$+Y
90 IF Z<W(2,X+Y+1) OR NOT Y OR
X=42 THEN LET W(2,X+Y+1)=Z
100 IF Z>W(1,X+Y+1) OR NOT Y OR
X=42 THEN LET W(1,X+Y+1)=Z
110 IF W(2,X+Y+1)=Z OR W(1,X+Y+
1)=Z THEN IF Z<44 AND Z>-1 THEN
PLOT X+Y,Z
120 NEXT X
130 NEXT Y
140 SLOW
150 PRINT AT 0,0;Z$
160 GOTO 30

GRAPH – GRAPH for ZX81/TS1000

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