--- title: "A Precision Frequency-Generator Program" type: "article" slug: "a-precision-frequency-generator-program" url: "http://localhost/article/a-precision-frequency-generator-program/" markdown_url: "http://localhost/article/a-precision-frequency-generator-program.md" published_at: "2026-12-01T10:02:37+00:00" modified_at: "2026-12-01T10:02:37+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "A unique program which will be of great value to you! (T/S 1000/1500) Reprinted with permission from CTM Magazine, August 1986 For the electronics experimenter, a precise audio frequency generator has a variety of uses. It can be used to test active filters, to check the frequency response of amplifiers and speakers, to tune electronic…" post_tag: - name: "Full Text" slug: "fulltext" taxonomy: "post_tag" url: "http://localhost/tag/fulltext/" indiv: - name: "David A. Nordquest" slug: "david-a-nordquest" taxonomy: "indiv" url: "http://localhost/indiv/david-a-nordquest/" publication: "QZX" publication_r: id: 21219 title: "QZX" type: "periodical" url: "http://localhost/periodical/qzx/" authors: "David A. Nordquest" volume: "5" issue: "4" issues_articles: - id: 70133 title: "QZX v5 n4" type: "issue" url: "http://localhost/issue/qzx-v5-n4/" pages: "5-8" pubdate: "March 1987" archive_link: false volumeissue: "v5n4" --- # A Precision Frequency-Generator Program A unique program which will be of great value to you! (T/S 1000/1500) Reprinted with permission from CTM Magazine, August 1986 For the electronics experimenter, a precise audio frequency generator has a variety of uses. It can be used to test active filters, to check the frequency response of amplifiers and speakers, to tune electronic and other musical instruments, and even to check one’s hearing. Unfortunately, commercial audio generators are expensive and home-built models often lack accuracy. However, simple programs can turn home computers into highly precise tone generators. Although the Timex/Sinclair 1000 & 1500 lack a music chip, sounds can be produced through the MIC port. Because the Z-80 chip used in these computers runs at 3.23 MHz, tones accurate to a fraction of a microsecond are possible. Although filtered, the output will show signs of TV sync pulses when viewed on a scope. In most applications, this will present no problem, but extra filtering or use of a Schmidt trigger might be advisable when a pure waveform is needed. The program printed below asks for a frequency to be entered, calculates the number of clock cycles needed to produce it, and then creates B- and C- loops that are either exactly on target or not less than 7 or more than 24 cycles away from the target. Machine code commands are then poked in which, in this program, do absolutely nothing. By doing nothing for precisely the correct amount of time, they allow the period of the tone to be set to within a clock cycle. These commands are chosen from A$, which consists of sets of commands, each of which takes one clock cycle longer than the last. Using this technique is necessary for accuracy greater than the four-clock-cycle period of the shortest Z-80 command. Entering C$, which is used by the program to poke in part of the machine code needed to generate tones, is tricky. It contains three commands which must be entered with the cursor in the keyword mode. Ordinarily, it leaves this mode after the first command is entered. The simplest procedure is to enter the last command first, then to move the cursor to the left of it and enter the next-to-the-last, and so on. The other elements of the string can then be entered by moving the cursor appropriately. Be absolutely sure to enter one space and one space only between the colon and the dollar sign. This space may not be noticeable in the printed version of the program, but MUST be included. There are no other spaces in C$. Table A must be poked into memory locations 16514 and 16534 before the program can be executed. Lines 5 and 11 through 17 should be deleted and the program should be started with a GOTO 10 command. RUN should not be used. I hope you enjoy this article and get frequent use of this project. I would appreciate any suggestions, comments and modifications you may feel warranted. Also, if you modify the program to work on another computer, please let me or Chet know so we may tell others. Please write or call me at: David A. Nordquest [address omitted] [phone number omitted] ### TABLE A ``` 33 0 0 17 1 0 219 254 6 0 14 0 13 32 -3 16 -7 6 0 248 127 ``` ### Precision Frequency Generator PROGRAM LISTING (spaces added for clarity) ``` 5 REM "PRECISION FREQUENCY GENERATOR By D. NORDQUEST" 10 REM (Any 50 characters, No quotes or brackets needed.) 11 FOR X= 16514 TO 16534 12 INPUT Y 13 POKE X, Y 14 NEXT X 15 STOP 16 REM "DELETE LINE 5 AND EXECUTE PROGRAM TO HERE, POKING IN TABLE A." 17 REM "AFTER ENTERING TABLE A, DELETE LINES 11 TO 17." 20 LET A$+ "056000009009127127009009127248009009 248248009009127056000009024000009009 (REM: "No spaces.") 248127127009248248127009248248248009 024000127009024000248009127127248248 127248248248024000127127024000127248 024000248248024000127078024000024000" 30 LET C$= "PEEK COPY : $ 4 CLEAR (RAND ;" (see text for C$ details) 40 PRINT "INPUT FREQUENCY IN HERTZ" 50 INPUT F 60 LET P= 1/F 70 PRINT "INPUT LENGTH IN SECONDS" 80 INPUT L 90 CLS 100 FAST 110 IF L>P*65535 THEN PRINT "OUT OF RANGE FOR FREQUENCY" 120 LET E= 65535- L/P 130 LET T= P*3231200 140 LET K= INT ((T- 120)/2)+ .5) 150 FOR B= 0 TO 255 160 IF K> (B*4111 + 4104) THEN GOTO 230 170 IF B= 0 THEN LET C= INT (K/16) 180 IF B> 0 THEN LET C= INT ((K- B* 31)/(B* 16+ 16)) 190 LET D= (C* 16 AND B= 0) + (B* (31+ C* 16)+ 16* C AND B>0) 200 IF C= 255 THEN GOTO 230 210 LET M= K- D 220 IF M< 25 AND M> 6 OR F> 16000 OR M= 0 THEN GOTO 240 230 NEXT B 240 POKE 16515,E- (256* INT (E/256)) 250 POKE 16516,INT (E/256) 260 POKE 16523,B+ 1 270 POKE 16525,C+ 1 280 POKE 16532,B+ 1 290 LET J= 0 300 LET B$= A$ (((M- 7)*12)+ 1) TO (((M- 7)*12)+ 12) 310 FOR V= 1 TO 2 320 FOR R= 1 TO 4 330 LET S= VAL B$ (R* 3- 2 TO R* 3) 340 IF S<> 9 THEN LET J= J+ 1 350 IF S<> 9 THEN POKE 16534+ J,S 360 NEXT R 370 LET J= J+ 10 380 NEXT V 390 LET I= (J- 20)/2 400 FOR W= 1 TO 10 410 LET Y= CODE C$ (W) 420 POKE 16534+ W+ I, Y 430 NEXT W 440 POKE 16535+ I+ 3, C+ 1 450 POKE 16545+ 2* I,48 460 POKE 16546+ 2*I, -27 -2*I 470 POKE 16547+ 2* I, 201 480 IF ((T- 120)/2- K)> .25 THEN POKE 16534, 248 490 IF PEEK 16534= 248 THEN LET M= M+ .5 500 IF K- ((T- 120)/2 )> .25 THEN POKE 16533, 127 510 IF PEEK 16533= 127 THEN LET M= M- .5 520 RAND USR 16514 530 PRINT "ACTUAL FREQUENCY WAS ", 1615600/ (D+ M+ 60) 540 PRINT 550 PRINT "ENTER R TO REPEAT TONE OR N FOR NEW TONE" 560 PRINT 570 INPUT Z$ 580 IF Z$= "N" THEN GOTO 40 590 IF Z$= "R" THEN GOTO 520 600 STOP ```