Chapter 2. Our Very First Alarm System
In this chapter we are going to design a single zone alarm system and learn how the basic components work. We will learn about comparators and how they are used in this case. We will also build and test a simple breadboard circuit that will simulate a single zone alarm. For example, the bell that rings when you enter a store.
A zone is an area that is being protected, and/or a collection of sensors that are protecting the zone. Zones can contain Passive Infrared Sensors (PIR sensors), glass break detectors, window contacts, or a combination of different sensors.
For example, "ground floor windows" could be a zone. Ground floor PIR sensors could be another zone. There are also "special" zones such as fire alarm zones. In commercial installations, the fire alarm zones and CO (carbon monoxide) detectors must have their own zone.
In the following chapters, you will see how we will use these zones to create a layered defense.
The alarm system, in this case the BeagleBone, must be able to monitor the world around it. It does this by using ICs called comparators. You can think of a comparator as an op-amp with extremely high gain. Like an op-amp, when the voltage on the positive (+) input is higher than the voltage on the negative (-) input, the output goes high. When the opposite is true, the output goes low.
We will be using an LM339 comparator. I chose the LM339 comparator because it has been around forever, and still comes in through-hole DIP packages. It is cheap and easy to source. Best of all, it is hard to blow up! The device has an open collector output. What this means is, a resistor is required to pull the output high. By connecting the output pull-up resistor to 3.3V, we now have a level converter that can be safely connected to the BeagleBone.
In the following diagram of the single zone comparator circuit, a 4.7K ohm resistor—R5 is used as a pull-up. The LM339 comparator...
The programming language that I chose was JavaScript. This is because it is already well supported on the BeagleBone as it comes to you from the supplier. You can access the Cloud9 integrated development environment (IDE) from the Start.html
link on the microSD card image.
There are plenty of very good tutorials and videos on how to use the Cloud9 IDE, so I have not included one here.
What the software does is, it watches an input pin waiting for it to go low. If the pin goes low, the software makes an output pin go high. This simulates an alarm panel monitoring a set of contacts, waiting for an alarm to occur.
In order to turn the alarm off, the software monitors another pin. If this pin goes low, it turns the alarm off. This is to simulate an alarm key switch being turned to the disarm position, but any type of contact closure will do.
Tip
Downloading the example code and image files
You can download the example code and image files for all Packt books you have purchased from...
In this chapter, we got our first introduction to the hardware and software that will be the heart of our alarm system.
We also learned how to stimulate the hardware using simple switches and an LED. We understood how comparators work and how to use them through this project. We briefly touched on EOL resistors and their significant use in this design.
In the next chapter, we will build the solid hardware that will be eventually connected to the BeagleBone.