Classic Computer Magazine Archive COMPUTE II ISSUE 3 / AUGUST/SEPTEMBER 1980 / PAGE 26

SYM-1 Home Warning System

A. M. MacKay
600 Sixth Avenue West
Owen Sound, Ontario N4K 5E7

If you have a C.R.T. hooked up to your SYM-1, this program and a couple of dollars worth of parts will let you experiment with a home warning system, and may help you learn a bit about your computer.

Once the hardware shown in figures 1 to 3 is connected, load the program and hit “RUN START” if you have an assembler or G 200 CR if you don't. Then as long as the old homestead is devoid of marauders, catastrophes and other unthinkables your screen will steadily and quietly tell you that everything is O.K. However, if one or more of the sensors detects any of the aforementioned nasties, a siren sounds and a message flashes on the screen telling you the nature and location of the problem(s).

The program starts by clearing the screen and displaying the “EVERYTHING IS O.K.” message. It then polls the sensors, one at a time, beginning with PB0. As soon as it finds an active sensor, it clears the “O.K.” message and displays the correct warning, then checks the remaining sensors. When all sensors have been checked and messages have been displayed for all active sensors, the siren sounds once and the polling process is repeated. The warnings and the siren will continue until all the sensors are turned off, at which time the “EVERYTHING IS O.K.” message re-appears and polling of the sensors resumes.

For this experiment four switches are used as input sensors. In practice, any sensor that will put out 5V under the appropriate conditions will do the job, and the program can be extended to handle any reasonable number of sensors.

The program as written uses PB0 to PB3 of U29 as inputs and PB7 with its buffer as the speaker output. Figure 1 shows how to hook up buffer B7 for this application. Although it looks complicated, changing B7 is easy. All you have to do is remove one jumper wire and add two resistors and one diode. However, if you prefer, you can forget about buffer B7 and construct a similar speaker system externally, Again, in real life, PB7 would be connected to a large amplifier and speaker.

Figure 2 shows how to attach the speaker, and figure 3 shows one way to use switches as simulated sensors. The speaker volume control, VR1, is optional, but it's a good idea to use it because without it the siren can shatter your wife's teeth.

The messages should, of course, be changed to suit your particular application. If you have an assembler such as RAE, this is easy. If not, you will have to get an ASCII code table and substitute the message code as required. The messages shown in the listing are for a 64x16 screen, so if yours is different, change the number of “0A”'s and “20”'s to suit your requirements.

Sound is produced by toggling the speaker on and off, with a delay between the toggles. The length of the delay determines the frequency. The siren sound is produced by shortening the delay slightly each time the speaker toggles, thus giving a steadily increasing frequency. For more information on sirens and other experiments read Rodnay Zak's “6502 Application Book” published by Sybex.

This program uses the SYM-1 as a dedicated con troller, so it can't be used for other purposes while the program is running. If you want the warning system working while you use your SYM-1 for other things, a new program using interrupts must be written. Bur that's another ballgame.


Parts List For SYM-1 Home Warning System.

R4 100KΩ Resistor
R17 10Ω Resistor
R18 1KΩ Resistor
VR1 100Ω Potentiometer (Optional)
C1 0.01 µF Capacitor
CR4 Diode, 1N4148, 1N914 Or Equivalent
SW1-4 Any SPDT Switches
SPK1 8Ω Speaker, Radio Shack 40-247 Or Equivalent








0010 ;      *********************************
0020 ;      *********************************
0030 ;      ***                           ***
0040 ;      ***    HOME WARNING SYSTEM    ***
0050 ;      ***    FOR SYM-1 COMPUTER     ***
0060 ;      ***                           ***
0070 ;      ***    BY A. M. MACKAY        ***
0080 ;      ***    600 SIXTH AVE. WEST    ***
0090 ;      ***    OWEN SOUND, ONTARIO    ***
0100 ;      ***    CANADA      N4K 5E7    ***
0110 ;      ***                           ***
0120 ;      *********************************
0130 ;      *********************************
0140 ;
0150 ;
0160 ;          * * * DEFINITIONS  * * *
0170 ;
0180 STATUS     .DE $AC00
0190 OUTVEC     .DE $A663
0200 ;
0210 ;          * * * INITIATE * * *
0220 ;
0230 START      LDA #$F0     ;SET DDRB		
0240            LDA STATUS+2 ;  FOR INPUT
0250            LDA #$00     ;TURN OFF
0260            STA STATUS   ;  SPEAKER
0270 ;
0280 ;          * * * SENSOR POLL ROUTINE * * *
0290 ;
0300 CLEAR      JMP OK       ;PRINT "ALL O.K." MESSAGE
0310 POLL       LDA STATUS   ;LOOK AT SENSORS	
0320            AND #$0F     ;  IF ONE IS ON
0330            BNE TEST1    ;    GO TO TEST1
0340            JMP POLL     ;ELSE GO TO POLL
0350 ;
0360 ;          * * * SIGNAL PROCESSING ROUTINE * * *
0370 ;
0380 TEST1      JSR POSIT    ;POSITION MESSAGE ON SCREEN
0390            LDA STATUS   ;LOOK AT SENSORS
0400            AND #$01     ;MASK OFF ALL BUT 1ST
0410            BEQ TEST2    ;NOT ON? GO TO TEST2	
0420            JSR SPACE    ;ON? PROCESS SIGNAL
0430            LDX #0       ;INDEX FOR MESSAGE #1
0440 MESS1      LDA TAB1,X   ;GET CHARACTERS
0450            JSR OUTVEC   ;WRITE ON CRT
0460            INX          ;NEXT CHARACTER
0470            CMP #$00     ;LAST ONE?
0480            BNE MESS1    ;NO? GET NEXT
0490 TEST2      LDA STATUS   ;YES? TEST FOR
0500            AND #$02     ;  SENSOR #2
0510            BEQ TEST3    ;    ETC.
0520            JSR SPACE
0530            LDX #0
0540 MESS2      LDA TAB2,X
0550            JSR OUTVEC
0560            INX
0570            CMP #$00
0580            BNE MESS2
0590 TEST3      LDA STATUS   ;TEST FOR	
0600            AND #$04     ;  SENSOR #3
0610            BEQ TEST4    ;    ETC.
0620            JSR SPACE
0630            LDX #0
0640 MESS3      LDA TAB3,X
0650            JSR OUTVEC
0660            INX
0670            CMP #$00
0680            BNE MESS3
0690 TEST4      LDA STATUS   ;TEST FOR

0700            AND #$08     ;  SENSOR #4
0710            BNE LAST     ;    ETC.
0720            JMP MESSX
0730 LAST       JSR SPACE
0740            LDX #0
0750 MESS4      LDA TAB4,X
0760            JSR OUTVEC
0770            INX
0780            CMP #$00
0790            BNE MESS4
0800            JMP SIREN
0810 MESSX      LDA STATUS   ;TEST FOR
0820            AND #$0F     ;  ANY SENSORS
0830            BEQ AGAIN    ;IF NONE, BACK TO POLL
0840            JMP SIREN    ;ELSE SOUND SIREN
0850 OK         JSR POSIT    ;POSITION
0860 AGAIN      LDX #0       ;  MESSAGE
0870 ALLOK      LDA TAB5,X   ;DISPLAY
0880            JSR OUTVEC   ;  "EVERYTHING O.K."
0890            INX          ;    MESSAGE
0900            CMP #$00
0910            BNE ALLOK
0920            LDA #$00     ;TURN OFF
0930            STA STATUS   ;  SPEAKER AND
0940            JMP POLL     ;    RESUME POLLING
0950 ;
0960 ;          * * * SIREN ROUTINE * * *
0970 ;
0980 SIREN      LDA STATUS   ;ANY SENSOR
0990            AND #$0F     ;  STILL ON?
1000            STA *$CB     ;IF YES, STORE IT
1010            BNE SCREAM   ;  AND START ALARM
1020            JMP CLEAR    ;ELSE POLL AGAIN
1030 SCREAM     LDA #$68     ;FREQUENCY CONSTANT
1040            STA *$CA     ;  AT LOCATION $CA
1050 YLOOP      LDY #$07     ;DELAY CONSTANT
1060 SHRIEK     JSR SPKR     ;TOGGLE SPEAKER
1070            DEY
1080            BNE SHRIEK
1090            INC *$CA     ;INCREMENT
1100            LDA *$CA     ;  FREQ. CONSTANT
1110            CMP #$B0     ;HIGHEST CONST.= $B0
1120            BNE YLOOP
1130            LDA STATUS   ;ANY
1140            AND #$0F     ;  SENSOR
1150            CMP *$CB     ;    CHANGE?
1160            BEQ SCREAM   ;NO? KEEP SIREN GOING
1170            LDA STATUS   ;YES? ANY MORE
1180            AND #$0F     ;  SENSORS ON?
1190            BEQ SCREEN   ;NO? PRINT O.K. MESSAGE
1200            JMP POLL     ;YES? PROCESS AGAIN	
1210 SCREEN     JMP CLEAR
1220 ;
1230 ;          * * * SUBROUTINES * * *
1240 ;
1250 SPKR       LDA #$80     ;RESET
1260            STA STATUS+2 ;  DDRB AND
1270            STA STATUS   ;    TOGGLE SPEAKER
1280            JSR DELAY    ;WAIT AND
1290            LDA #$00     ;  TOGGLE
1300            STA STATUS   ;    AGAIN
1310            JSR DELAY    ;WAIT AGAIN
1320            RTS
1330 DELAY      LDX *$CA     ;CHANGE
1340 XLOOP      INX          ;  FREQUENCY	
1350            CPX #$00
1360            BNE XLOOP
1370            RTS
1380 POSIT      LDX #0

1390 MOVE       LDA TAB6,X   ;POSITION
1400            JSR OUTVEC   ;  MESSAGE
1410            INX          ;    ON
1420            CMP #$00     ;      SCREEN
1430            BNE MOVE
1440            RTS
1450 SPACE      LDX #0       ;POSITION
1460 RIGHT      LDA TAB7,X   ;  WARNING
1470            JSR OUTVEC   ;    MESSAGES
1480            INX
1490            CMP #$00
1500            BNE RIGHT
1510            RTS
1520 ;
1530 ;          * * * MESSAGES * * *
1540 ;
1550 TAB1       .BY '[ [ [  WATER IN BASEMENT  ] ] ]' $00
1560 TAB2       .BY '+ + + DOG NEEDS TO GO OUT + + +' $00
1570 TAB3       .BY '# # # THIEF IN WINE CELLAR # # #' $00
1580 TAB4       .BY '* * * MILKMAN IN WIFE'S BEDROOM '
1590            .BY '* * *' $00
1600 TAB5       .BY '******************************'
1610            .BY '*******' $0D $0A $0A
1620            .BY '* * * SYM-1 HOME WARNING SYSTEM '
1630            .BY '* * *' $0D $0A $0A
1640            .BY '> > > >   EVERYTHING IS O.K.  < '
1650            .BY '< < <' $0D $0A $0A '*******'
1660            .BY '******************************' $00
1670 TAB6       .BY $0C $0D $0A $0A $0A $0A $00
1680 TAB7       .BY $0D $0A $0A $20 $20 $20 $20 $20
1690            .BY $20 $20 $00
1700            .EN