This program performs 555 timer circuit calculations for both astable and monostable configurations. It draws schematic diagrams of each circuit using PLOT, DRAW, CIRCLE, and user-defined graphics (UDGs) to represent component symbols such as resistors and capacitors. For astable mode, it solves for R2, C1, or frequency given the other parameters using the standard formula F = 1.44 / ((R1 + 2·R2) · C1); for monostable mode, it uses T = 1.1 · R1 · C1. Seven UDG characters (c, s, a, b, d, e, f) are loaded from DATA statements at startup to render schematic symbols within the circuit diagrams. Results can be printed to a hard-copy device using the COPY command.
Program Structure
The program is organized into clearly separated sections:
- Lines 10–180: Title screen, mode selection (Astable / Monostable / Quit)
- Lines 190–570: Astable calculation menu and four subroutines (lines 330–570)
- Lines 580–860: Monostable calculation menu and three subroutines (lines 720–860)
- Lines 870–950: Shared result display and COPY prompt subroutine
- Lines 1000–1190: Astable schematic drawing subroutine
- Lines 1200–1400: Monostable schematic drawing subroutine
- Lines 3000–3300: UDG initialization subroutine
- Lines 3500–3560: DATA for seven UDG character bitmaps
Physics and Formulas
The program implements the standard 555 timer equations:
| Mode | Formula | Lines |
|---|---|---|
| Astable frequency | F = 1.44 / ((R1 + 2·R2) · C1 · 10⁻⁶) | 550 |
| Astable R2 | R2 = (1.44 / (F · C1 / 10⁶) − R1) / 2 | 360 |
| Astable C1 (two variants) | C1 = 1.44 / (F · (R1 + 2·R2)) · 10⁶ | 420, 480 |
| Monostable period | T = 1.1 · R1 · C1 · 10⁻⁶ | 750 |
| Monostable R | R1 = T / (1.1 · C1) · 10⁶ | 800 |
| Monostable C | C1 = T / (1.1 · R1) · 10⁻⁶ | 850 |
Capacitance values are stored and displayed in microfarads (µF), with conversion factors of 1e06 and 1e-06 applied throughout. The monostable period is displayed in milliseconds at line 690 by multiplying T by 1000.
UDG Character Setup
The subroutine at line 3000 loads seven UDGs using POKE USR "c"+i style addressing (iterating i from 0 to 7 for each character). The seven characters defined are c, s, a, b, d, e, and f, covering symbols used in the schematic diagrams such as resistor zig-zags, capacitor plates, wire junctions, and arrows. Notable DATA entries include:
- UDG
c: a “6” shape (line 3500) — likely the Vcc label glyph - UDG
s: a “G” shape (line 3510) — likely a ground symbol - UDG
a: a horizontal capacitor plate row (line 3520) - UDG
b: a cross/junction marker (line 3530) - UDG
d: a right-pointing arrow (line 3540) - UDG
e: a resistor zig-zag row (line 3550) - UDG
f: another junction or wire symbol (line 3560)
Schematic Drawing Technique
Both schematic subroutines (lines 1000 and 1200) use OVER 1 mode so that PLOT/DRAW lines XOR with existing screen content, avoiding overwriting the UDG text already placed. The IC chip body is drawn as a double-lined rectangle using paired PLOT/DRAW calls offset by one pixel, creating a thick-border effect. Pin numbers and labels (dsch, thr, trg, rst, bypass, Vcc, Vss) are printed using AT coordinates interleaved with graphics commands. CIRCLE is used at lines 1160 and 1360 to draw the output terminal symbol.
The astable schematic uses PAPER 4 (green) for the IC body at line 1045, while the monostable uses PAPER 5 (cyan) at line 1245, providing immediate visual differentiation between the two modes.
Menu and Input Handling
The string variable v$ (line 90) holds 32 spaces and is used at lines 285 and 645 to blank five rows of the lower screen after menu input, using repeated concatenation in a single PRINT statement. User menu selection is stored in the numeric variable IN and tested with successive IF IN=n THEN GO SUB lines rather than an ON...GO SUB construct. The top-level mode selector at line 140 accepts a single character string and tests for both upper and lower case.
Bugs and Anomalies
- Line 800 contains a precedence error:
LET R1=T/1.1*C1*1e06is evaluated left-to-right as(T/1.1)*C1*1e06, but the correct formula for monostable R isT/(1.1*R1*C1*1e-6)— specifically, it should beR1 = T / (1.1 * C1 * 1e-06). The current expression multiplies byC1instead of dividing, producing incorrect results. - Line 850 has a similar issue:
LET C1=T/1.1*R1*1e-06evaluates as(T/1.1)*R1*1e-06rather thanT/(1.1*R1)*1e06. Both the units and the division are wrong. - The monostable result display at line 690 references
C1andR1, but the monostable subroutines useR1andC1consistently, so the variable names are correct even though the calculations at lines 800 and 850 are erroneous. - Line 920 uses
INPUT ... "Z"with a string default, meaning pressing ENTER without typing accepts the default “Z” rather than returning — however the logic at lines 930–950 handles both “Z”/”z” for COPY and empty string for plain return, with line 940 catching the empty case and line 950 acting as a fallthrough return. - Line 3550 contains
BIN 1000000(seven digits), which is not a valid 8-bit binary literal — most interpreters will treat this as a syntax error or misparse it. The intended value is likelyBIN 10000000(128). - Lines 869 and 999 and 2999 contain unreachable
STOPstatements used as section separators, a common defensive coding practice.
Source Code
10 INK 0:PAPER 7:BORDER 7:CLS
90 LET v$=" "
100 REM 555 timer calculations
105 CLS :GO SUB 3000
110 FOR i=5 TO 15 STEP 2
120 PRINT PAPER i/2-2; INK 9; AT i,i-5;"555 timer calculations"
130 NEXT i
140 INPUT "Astable Monostable Quit A/M/Q ";a\{20}\{1}\{20}\{0}$
150 IF a$="q" OR a$="Q" OR a$="" THEN STOP
160 IF a$="m" OR a$="M" THEN GO TO 580
170 IF a$="a" OR a$="A" THEN GO TO 190
180 GO TO 100
190 REM Do astable calculations
200 GO SUB 1000
230 PRINT AT 16,0;"0 to quit "
240 PRINT "1 find R2 given R1=1K & input C1"
250 PRINT "2 find C1 given R1=1K & input R2"
260 PRINT "3 find C1 given input R1 & R2"
270 PRINT "4 find F given input R1, R2, C1"
280 INPUT "Choose a number. ";IN
285 OVER 0:PRINT AT 16,0;v$;v$;v$;v$;v$
290 IF IN=0 THEN CLS :GO TO 140
295 IF IN=1 THEN GO SUB 330
300 IF IN=2 THEN GO SUB 390
305 IF IN=3 THEN GO SUB 450
310 IF IN=4 THEN GO SUB 510
320 GO TO 220
330 REM find R2 given R1=1K, C1 entered
340 LET R1=1000
345 INPUT "Frequency= ";F
350 INPUT "Give value for C1 ";C1
360 LET R2=(1.44/(F*C1/1e06)-R1)/2
370 GO SUB 870
380 RETURN
390 REM find C1 given R1=1K, R2 entered
400 LET R1=1000
405 INPUT "Frequency= ";F
410 INPUT "R2= ";R2
420 LET C1=1.44/(F*(R1+2*R2))*1e06
430 GO SUB 870
440 RETURN
450 REM find C1 given R1, R2 input
455 INPUT "Frequency= ";F
460 INPUT "R1= ";R1
470 INPUT "R2= ";R2
480 LET C1=1.44/(F*(R1+2*R2))*1e06
490 GO SUB 870
500 RETURN
510 REM find F given C1, R1, R2
520 INPUT "C1= ";C1
530 INPUT "R1= ";R1
540 INPUT "R2= ";R2
550 LET F=1.44/(C1*.000001*(R1+2*R2))
560 GO SUB 870
570 RETURN
580 REM monostable calculations
590 GO SUB 1200
600 PRINT AT 16,0;"0 to quit "
610 PRINT "1 find T, given R & C"
620 PRINT "2 find R, given T & C"
630 PRINT "3 find C, given R & T"
640 INPUT "Choose a number. ";IN
645 OVER 0:PRINT AT 16,0;v$;v$;v$;v$;v$
650 IF IN=0 THEN CLS :GO TO 140
655 IF IN=1 THEN GO SUB 720
660 IF IN=2 THEN GO SUB 770
665 IF IN=3 THEN GO SUB 820
690 PRINT AT 16,10;"C= ";C1;" uf"; AT 17,10;"R= ";R1;" ohms"; AT 18,10;"T= ";T*1000;" msec"
700 GO SUB 920
710 GO TO 600
720 REM find T given R&C
730 INPUT "R1= ";R1
740 INPUT "C1= ";C1
750 LET T=1.1*R1*C1*1e-06
760 RETURN
770 REM find R given T & C
780 INPUT "T= ";T
790 INPUT "C1= ";C1
800 LET R1=T/1.1*C1*1e06
810 RETURN
820 REM find C1 given R & T
830 INPUT "R1= ";R1
840 INPUT "T= ";T
850 LET C1=T/1.1*R1*1e-06
860 RETURN
869 STOP
870 REM print astable variables
880 PRINT AT 16,5;"Freq= ";f;" Hz"
890 PRINT TAB 5;"C1= ";C1;" uf"
900 PRINT TAB 5;"R1= ";R1;" ohms"
910 PRINT TAB 5;"R2= ";R2;" ohms"
920 INPUT "Press any key to continue ""Z"" to COPY ";a$
930 IF a$="Z" OR a$="z" THEN COPY :RETURN
940 IF a$="" THEN RETURN
950 RETURN
999 STOP
1000 CLS :OVER 1
1010 PLOT 79,152:DRAW 96,0:PLOT 80,151:DRAW 94,0
1020 PLOT 176,152:DRAW 0,-73:PLOT 175,151:DRAW 0,-71
1030 PLOT 175,79:DRAW -95,0:PLOT 174,80:DRAW -93,0
1040 PLOT 79,79:DRAW 0,72:PLOT 80,80:DRAW 0,70
1045 FOR i=1 TO 9:PRINT PAPER 4; AT 2+i,10;" ":NEXT i
1050 PRINT AT 6,15;"IC1"; AT 6,19;"out"; AT 7,15;"555"
1060 PRINT AT 3,11;"V\c"; AT 3,15;"rst"; AT 5,10;"dsch"; AT 7,10;"thr"; AT 9,10;"trg"; AT 9,16;"bypass"; AT 11,13;"V\s"
1070 PLOT 136,153:DRAW 0,9:PRINT AT 2,16;4:PLOT 136,163:DRAW -16,0:PRINT AT 1,14;"\b"; AT 0,13;"+5V"
1080 PLOT 111,163:DRAW -7,0:PRINT AT 1,12;"\f"; AT 2,11;8:PLOT 100,159:DRAW 0,-6
1090 PLOT 95,163:DRAW -51,0:PLOT 44,162:DRAW 0,-10:PRINT AT 3,5;"\e"; AT 4,5;"\e"; AT 5,5;"\d"; AT 3,2;"R1"
1100 PLOT 48,131:DRAW 30,0:PRINT AT 4,9;7:PLOT 44,127:DRAW 0,-7:PRINT AT 7,5;"\e"; AT 8,5;"\e"; AT 9,5;"\d"
1110 PLOT 48,99:DRAW 7,0:PRINT AT 7,2;"R2"; AT 9,7;"\b":PLOT 60,104:DRAW 0,10:PLOT 61,114:DRAW 16,0:PLOT 64,99:DRAW 14,0:PRINT AT 6,9;6; AT 8,9;2
1120 PLOT 44,95:DRAW 0,-7:PRINT AT 11,5;"\a"; AT 11,3;"C1":PLOT 44,79:DRAW 0,-12
1130 PLOT 45,67:DRAW 66,0:PRINT AT 13,14;"\b":PLOT 116,72:DRAW 0,6:PRINT AT 12,13;1
1140 PLOT 120,67:DRAW 76,0:PLOT 196,68:DRAW 0,11:PRINT AT 11,24;"\a"; AT 12,26;".1"; AT 11,26;"C2"
1150 PLOT 196,88:DRAW 0,10:PLOT 196,99:DRAW -19,0:PRINT AT 8,22;5
1160 PRINT AT 5,22;3:PLOT 177,124:DRAW 14,0:CIRCLE 194,124,2:PRINT AT 5,25;"Astable"; AT 6,26;"Output"
1180 OVER 0
1190 RETURN
1200 CLS :OVER 1
1210 PLOT 87,152:DRAW 96,0:PLOT 88,151:DRAW 94,0
1220 PLOT 184,152:DRAW 0,-73:PLOT 183,151:DRAW 0,-71
1230 PLOT 183,79:DRAW -95,0:PLOT 182,80:DRAW -93,0
1240 PLOT 87,79:DRAW 0,72:PLOT 88,80:DRAW 0,70
1245 FOR i=1 TO 9:PRINT PAPER 5; AT 2+i,11;" ":NEXT i
1250 PRINT AT 6,16;"IC1"; AT 6,20;"out"; AT 7,16;"555"
1260 PRINT AT 3,12;"V\c"; AT 3,16;"rst"; AT 5,11;"dsch"; AT 7,11;"thr"; AT 9,11;"trg"; AT 9,17;"bypass"; AT 11,14;"V\s"
1270 PLOT 144,153:DRAW 0,9:PRINT AT 2,17;4:PLOT 144,163:DRAW -16,0:PRINT AT 1,15;"\b"; AT 0,14;"+5V"
1280 PLOT 119,163:DRAW -7,0:PRINT AT 1,13;"\f"; AT 2,12;8:PLOT 108,159:DRAW 0,-6
1290 PLOT 103,163:DRAW -35,0:PLOT 68,162:DRAW 0,-10:PRINT AT 3,8;"\e"; AT 4,8;"\e"; AT 5,8;"\d"; AT 3,6;"R1"
1300 PLOT 72,131:DRAW 14,0:PRINT AT 4,10;7:PLOT 68,127:DRAW 0,-7:PRINT AT 7,8;"\d"; AT 6,10;6;:PLOT 72,115:DRAW 14,0:PLOT 68,111:DRAW 0,-7:PRINT AT 9,8;"\d"; AT 8,10;2
1310 PLOT 66,99:DRAW -18,0:CIRCLE 45,99,2:PRINT AT 7,0;"Trigger"; AT 8,0;"Input":PLOT 72,99:DRAW 14,0
1320 PLOT 68,95:DRAW 0,-7:PRINT AT 11,8;"\a"; AT 11,6;"C1":PLOT 68,79:DRAW 0,-12
1330 PLOT 69,67:DRAW 50,0:PRINT AT 13,15;"\b":PLOT 124,72:DRAW 0,6:PRINT AT 12,14;1
1340 PLOT 128,67:DRAW 76,0:PLOT 204,68:DRAW 0,11:PRINT AT 11,25;"\a"; AT 12,27;".1"; AT 11,27;"C2"
1350 PLOT 204,88:DRAW 0,10:PLOT 204,99:DRAW -19,0:PRINT AT 8,23;5
1360 PRINT AT 5,23;3:PLOT 186,124:DRAW 14,0:CIRCLE 202,124,2:PRINT AT 6,27;"Pulse"; AT 7,26;"Output"
1399 OVER 0
1400 RETURN
2999 STOP
3000 RESTORE
3010 FOR i=0 TO 7
3020 READ a:POKE USR "c"+i,a
3030 NEXT i
3040 FOR i=0 TO 7
3050 READ a:POKE USR "s"+i,a
3060 NEXT i
3070 FOR i=0 TO 7
3080 READ a:POKE USR "a"+i,a
3090 NEXT i
3100 FOR i=0 TO 7
3110 READ a:POKE USR "b"+i,a
3120 NEXT i
3130 FOR i=0 TO 7
3140 READ a:POKE USR "d"+i,a
3150 NEXT i
3160 FOR i=0 TO 7
3170 READ a:POKE USR "e"+i,a
3180 NEXT i
3190 FOR i=0 TO 7
3200 READ a:POKE USR "f"+i,a
3210 NEXT i
3300 RETURN
3500 DATA 0,0, BIN 01100110, BIN 10001000, BIN 10001000, BIN 10001000, BIN 01100110,0
3510 DATA 0,0, BIN 01100110, BIN 10001000, BIN 01100110, BIN 00010001, BIN 01100110,0
3520 DATA 8,8, BIN 01111111,0, BIN 00011100, BIN 01101011,8,8
3530 DATA 8,8,8, BIN 00011100,255, BIN 00011100,0,0
3540 DATA 8,8,8, BIN 00011100, BIN 00011111, BIN 00011100,8,8
3550 DATA BIN 00011000, BIN 01100000, BIN 1000000, BIN 01100000, BIN 00011000, BIN 00000110,1,6
3560 DATA 0,0,0, BIN 00011100,255, BIN 00011100,8,8
9900 REM
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

