Computerized security alarms. (the computer scientist) Forrest M. Mims III.
Computerized Security Alarms
Some personal computers can be programmed to outperform professional security alarm systems that cost hundreds of dollars. You can exploit this ability, and your computer can help earn its keep, if you put your machine to work as a security guard while you are asleep or away from your home or business.
In this article I'll describe how to connect a computer to an array of standard intruder sensor switches, even if they are already installed. I'll also describe a working system that will indicate which sensor switch has been actuated and then generate a predetermined number of alarm beeps before automatically resetting itself. The system can be easily programmed to activate itself immediately or at a preset time. It can be reset during an alarm cycle if the actuated sensor switch has been closed. The system even includes a delay feature that allows time for an occupant to enter the protected building and deactivate the alarm before it sounds.
Security Alarm Basics
Before discussing how to use a computer as the nerve center for a sophisticated security alarm system, let's review a few basics about electonic intruder detection devices. There are three principle categories of such devices: direct contact, indirect contact and noncontact.
Direct contact alarm systems employ sensor switches that must be physically touched or moved by an intruder. Concealed trip wires and floor switches are examples of direct contact sensors.
Indirect contact alarm systems use sensor switches that are attached to a door, window or other object likely to be moved by an intruder. They include magnet switches, vibration sensors, and window foil.
Noncontact alarm systems are actuated by the mere prescence of an intruder. Some detect the presence of a person by means of the infrared radiation the human body emits. Others detect intruders by means of a beam of microwaves, near-infrared, or ultrasound.
The high tech aspect of noncontact alarm systems is appealing, particularly since some of these systems are incredibly sensitive. For instance, I once tested an ultrasonic intrusion alarm that could be triggered by the movements of my chest caused by breathing. It is this high degree of sensitivity, however, that sometimes makes noncontact systems susceptible to false triggering. Moreover, noncontact systems are generally much more expensive than systems that use direct or indirect contact switches. Also, alarm systems that use switch sensors can protect the permeter of a building and provide a warning before an actual penetration has been completed. A noncontact system inside a room may provide a warning only after an intruder has broken into the protected area.
All three categories of alarm systems can be monitored by a central control box or by a personal computer. Two connection methods are possible: open and closed circuit.
Figure 1 shows a basic open circuit security alarm. The sensors are depicted as an array of parallel connected switches, each of which is normally open (off). When one or more of the switches are closed (on), the circuit between the battery and the bell is completed, and the bell sounds an alarm. Though the open circuit configuration is very simple, it can be easily disabled simply by cutting one of the wires between the bell and the sensors or the battery.
Figure 2 shows a basic closed circuit security alarm. In this circuit, the sensor switches, which are normally closed, are connected in series with one another. When S4 is pressed momentarily, the relay armature is pulled down. If one of the sensor switches is opened, the relay armature is pulled up, thereby switching on the alarm bell. The resistor limits the current through the relay coil to reduce the standby power consumption of the circuit to a minimum.
The closed circuit alarm requires a continuous source of current to activate the relay. Nevertheless, it is generally a better choice than the open circuit configuration. Both open and closed circuit alarm systems can be used in conjunction with a computer.
Selecting a Computer
With the proper interfacing, virtually any computer can be used as a controller for a security alarm system. Computers equipped with joystick ports, however, are the easiest to adapt for this purpose. Interfacing external circuits through joystick ports has been discussed in this column when it appeared in Computers and Electronics magazine.
Briefly, most personal computers use one of two basic kinds of joysticks. Absolute joysticks include a pair of mechamcally linked potentiometers that provide the input to an analog-to-digital converter that causes an on-screen cursor to follow the position of the joystick handle. Rate joysticks incorporate an array of four or more switches that cause an on-screen cursor to move in the direction the joystick handle is pushed.
Low-cost computers designed to work with rate joysticks include models made by Atari and Commodore. The discontinued TI 99/4 and Coleco Adam, both of which can be purchased at bargain prices, also use rate joysticks.
In the March 1984 installment of this column in Computers and Electronics, I described how to use the Adam as an open circuit intrusion alarm controller simply by connecting individual sensor switches directly to each of the four switches in the two joysticks. The driver program for this application was very brief. Presumably the techniques presented in that column can be applied directly to other computers that use switch-style rate joysticks.
An intrusion alarm system designed around arate joystick port requires separate wiring for each sensor switch. A much better approach is to use a computer with absolute joystick ports. This kind of computer can often be connected directly to an existing closed-circuit network of series-connected, normally-closed sensor switches.
An important advantage of an alarm system designed around a computer with absolute joystick ports is that the system can indicate which sensor switch has been triggered. This is accomplished simply by connecting an inexpensive resistor across each sensor switch. Normally, the joystick port "sees' a short circuit. When one of the sensor switches is opened (triggered), the resistor of that switch is connected across the joystick port. If each switch is connected to a resistor having different value, the computer can easily determine which switch has been opened. I don't know if this is a new idea, but it certainly works well.
Among the most economical computers that use absolute joysticks are Radio Shack's line of Color Computers. Other machines using absolute joysticks include the Apple II family, the IBM PC family, and IBM clones like the Tandy 1000. These machines utilize different methods to interface the potentiometers in the joysticks with the analog-to-digital conversion circuits in the computer. Therefore, there is no single method of implementing a security alarm system for all these machines.
A Closed Circuit Sensor Network
Figure 3 shows a basic sensor network for a closed circuit alarm system designed around a computer with absolute joystick ports. The only difference between this sensor network and the kind used by conventional security alarms is the presence of the resistors (R1-R5) across each sensor switch and the single resistor (R6) across the network.
When all the sensor switches are closed, the resistance appearing across the joystick port is only that of the sensor wires (perhaps a few ohms). If, say, S3 is opened, then the parallel resistance of R3 and R6 is placed across the joystick port.
The system will work without R6. But R6 permits it to detect when the wire to the sensors has been cut or disconnected. It should be placed as close as possible to the computer. Normally, R6 is shorted by the network of closed sensor switches. Should one of the sensor wires be cut, however, the short is removed, and R6 appears across the joystick port.
Figure 4 is a pictorial representation of a three-sensor version of Figure 3. The magnet switches are usually used to protect doors and windows. The switch is mounted in a fixed position on the door or window frame as shown in Figure 5. The magnet is installed on the moving door or window. When the door or window is closed, the magnet is adjacent to the switch and the switch is closed. When the magnet is moved away from the switch, the switch opens, thereby triggering the alarm.
The window foil shown in Figure 4 is self-adhesive aluminum foil tape that is attached around the perimeter of vulnerable windows. Contact with the foil is made by means of stick-on connectors that adhere to window glass.
It is important to know that several different methods are used for interfacing potentiometer-style joysticks with computers. In the method used by the Apple II and IBM PC, for instance, the joystick simply supplies a variable resistance to the computer. The joysticks used by Radio Shack's CoCo family, however, serve as variable voltage supplies. The joystick sockets on the computer supply + 5 volts and ground to the fixed (stator) terminals of each of the two potentiometers in the joysticks. This arrangement allows the pots to function as voltage dividers. As their wiper contact (rotor) is rotated, the voltage appearing at the center terminal of each pot ranges from near ground to near 5 volts.
Figure 6 shows how the sensor network in Figure 3 can be connected to the two basic kinds of potentiometer-style joystick ports. No change is required to connect the network to a PCjr-style variable resistance port. To connect the network to a variable voltage port like the one used in the CoCo family, it is necessary to add an additional resistor (R) to form a voltage divider. A suitable value for R would be the same value as the resistance of the joystick pots (100,000 ohms for the CoCo).
A Do-It-Yourself Computer Sentry System
For the purpose of this column, I have designed a closed circuit security alarm system around the IBM PCjr. This computer has a pair of absolute (potentiometer) joystick ports. It also has a built-in clock that can be used to activate the alarm system automatically at the present time. The basic principles of this system can be applied to other machines that use absolute joysticks, especially Radio Shack's CoCo family, Apple II family, and IBM-compatible clones.
Figure 7 identifies the connection pins of the non-standard, Berg-type joystick socket on the back of a PCjr. You can better understand how the potentiometers inside the joystick function by referring to the circuit diagram in Figure 8.
If you can't find a Berg-type plug at a computer store, you can make direct connections to the pins in the socket with a wire-wrapping tool. Or you can do as I did and install a miniature phone jack in a PCjr joystick and connect it across the leads to the x-axis potentiometer. Cut one of the wires to the potentiometer. Use a jack with a built-in switch, and wire the switch between the cut joystick connection and the potentiometer. This will allow the joystick to function normally when the plug to the alarm system sensors is removed.
To test the PCjr as an intrusion alarm controller, I connected a 100" extension cord to a joystick with a phone jack connected across the x-axis potentiometer (STICK (0) when the joystick connector is plugged into the left joystick connector on the back of the computer). I then connected a 100,000-ohm resistor across the joystick leads (R6 in Figure 3 or R1 in Figure 4). A resistance substitution box was connected across a switch installed at the far end of the extension cord. The cord was strung throughout my office and shop to pick up stray electrical noise that might be present in a real system.
This simple program in Listing 1 tells the PCjr to read the value of STICK (0).
When the sensor switch was opened, the resistance values I tried yielded the joystick values in Table 1 (values may differ for other PCjr's).
Once you know the joystick values given by various resistances, it is a simple matter to select resistors for each sensor switch in a working alarm system. For a simulated five-sensor alarm system, I selected resistors of 3300, 4700, 10000, 15000 and 22000 ohms. This leaves many unused values for additional sensors.
Listing 2 is PCjr Sentry System, a program that transforms the PCjr into a relatively sophisticated alarm system controller. The program assumes one sensor (1) is installed at the principle door of the protected area and asks if the alarm response to this sensor is immediate or delayed. Selecting a delayed response provides time for the occupant to open the door and deactivate the program before the beeper sounds.
The program then gives the current time and asks the user to select the time the alarm system is to become active. Selecting a time a few minutes ahead of the current time will give the occupant a chance to exit the building before the alarm system is activated. Alternatively, the system can be activated immediately, simply by pressing ENTER, if the occupants are not planning to leave.
When the system is activated, the screen displays:
SENTRY SYSTEM NOW ACTIVATED
PRESS R TO RESET
SYSTEM NORMAL. ALL SENSORS
When one of the sensor switches is opened, the screen displays the number of the triggered switch. If, for instance, sensor switch 5 is opened, the screen will display:
SENSOR 5 IS OPEN!
The computer will then begin beeping the number of times given in line 870. I used 10, but any number can be substituted. If the sensor switch is still open after the specified number of beeps, another cycle of beeping is begun. Momentarily pressing R (reset) will halt the beeping and cause the program to be resumed, but only if the sensor switch has been closed. If R is held down for a second or so, the beeping will stop and the program will reset even though the switch is open. However, running the program again without closing the triggered switch will cause another beep cycle.
Though the program might seem long, its operation is straightforward. Lines 10 through 390 comprise the main program, and the remaining lines are the subroutines.
The key portion of the main program is in lines 320 through 380. These lines sample the five sensor switches and call the relevant subroutine if an opened switch is detected. The "greater than/ less than' values in these lines were determined with the help of the table of joystick values for various resistances.
Lines 410 through 740 form the subroutines that respond to a broken sensor wire or triggered sensor switch and update the system status.
Lines 760 through 840 form the delay subroutine that determines the time before the beeper sounds after sensor 1 is triggered. For test purposes, use a two-second delay (see lines 790 and 800). To provide plenty of time to exit the protected building, use a delay of 60 seconds or so.
Finally, lines 860 through 930 form the beep subroutine. Line 880 determines the number of beeps per cycle the system generates when a sensor is triggered.
Designing Your Own System
The basic techniques given in this column can be adapted for many different computers. Sensor switches and other intrusion alarm devices can be purchased at most electronic parts and Radio Shack stores.
If your computer has a cassette tape interface, you can use the built-in relay to activate an external alarm device that produces considerably more sound than the built-in beeper of the computer. The PCjr and CoCo, for instance, include MOTOR commands to switch a cassette recorder on and off.
As for the program, depending upon the capabilities of your computer, you can easily expand Listing 2 to include many extra features. For example, many more sensor switches can be added to the five in the program. The computer can store in RAM or on disk the time a sensor switch is triggered and the time it is closed. Adding voice synthesis will permit the computer to announce which sensor has been triggered.
Here are a few pointers and precautions you should consider before you install a security alarm system. First, it is wise to read more about the subject before proceeding. Some companies that make security electronic devices publish brochures, and there are a number of helpful books on the subject. John E. Cunningham, for example, has written Security Electronics and Electronic Intrusion Alarms, both published by Howard W. Sams.
If you assemble a computerized alarm system, it is important to make sure stray electrical signals entering the sensor network don't cause false triggering. It is also important to make sure the sensor wires don't come in contact with live electrical wires. Incidentally, you should be aware that some computer companies might not honor the warranty on a machine that is connected to an "unauthorized' peripheral such as a homebrew security alarm.
Finally, remember that security alarms are installed for serious reasons. No electronic surveillance system is perfect, especially those that require a continuous power supply. As for reliability and immunity from embarrassing false alarms, a homebrew computer security system is only as reliable as your ability to design and install it. That is why Listing 2 is merely suggested as a model program which you should carefully test and evaluate before using it or a similar program to protect a home or office.
Table: Listing 1.
Table: Listing 2.
Photo: Figure 1. Basic open-circuit security alarm.
Photo: Figure 2. Basic closed-circuit security alarm.
Photo: Figure 4. Basic resistor-bypassed sensor system for computer security alarm.
Photo: Figure 5. How magnet sensor switches are installed.
Photo: Figure 6. How to connect sensor network to absolute joystick ports.
Photo: Figure 7. PCjr joystick connections.
Photo: Figure 8. Internal circuitry of PCjr joystick.