This is only a preview of the March 2006 issue of Silicon Chip. You can view 35 of the 112 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "PC-Controlled Burglar Alarm System, Pt.2":
Items relevant to "AVR ISP SocketBoard":
Articles in this series:
Items relevant to "Phone/Fax Missed Call Alert":
Purchase a printed copy of this issue for $10.00. |
A PC-Controlled
Burglar Alarm
System
This month, we complete the construction,
describe the test procedure and give the
“driving instructions” for the software. We
also describe the optional keypad module
which can be used to arm & disarm the
system.
Pt.2: By TRENT JACKSON
H
AVING COMPLETED construction of the alarm unit, it’s time
for the test procedure. At this stage,
microcontroller IC1 should be out of
its socket and the SLA battery should
be disconnected.
It’s also a good idea to disconnect the
display board from the main control
board until the power supply has been
checked out.
Here’s the step-by-step test procedure:
Step 1: apply 16VAC power to the main
controller board (but leave SLA battery
disconnected).
Step 2: set your DMM to read DC volts
and check the output from the 12V
regulator (REG1). Anywhere from
11.5-12.5V is acceptable. Now, do the
same for the 5V regulator (REG2) – its
output should be very close to 5V.
If either of these readings is drastically low, switch off immediately and
check for shorts on the PC board and
for polarised components that may be
the wrong way around.
Step 3: check the voltage across the battery leads (ie, between ZD1’s cathode
and D7’s cathode). You should get a
reading of 13.6-14V (this is the charging voltage).
If this checks out, connect the bat30 Silicon Chip
tery and repeat the last step. Depending on the amount of charge in the
battery, you should get a reading in
the range of 13-13.6V (a flat battery
will give a lower reading).
Step 4: check that +5V is present on
both pins 11 & 32 of the microcontroller’s IC socket. If so, switch off,
connect the display board, re-apply
power and check that the mains power
LED is lit (the other LEDs should all be
off). Also, check for a +5V rail on the
three righthand pins of the key socket
connector on the display board.
Step 5: disconnect the power supply
and plug the PIC microcontroller (IC1)
into its socket. Take care to ensure
that pin 1 is at upper right – see Fig.5
in part 1.
Step 6: this step checks the basic operation of the two PC boards. First,
connect a sensor (PIR or reed switch)
to the input of zone 1. As a default, the
system assumes that N/O (normally
open) sensor contacts will be used.
When the sensor is triggered, you
should see the status LED for zone
1 illuminate. This LED should then
extinguish when the sensor is reset.
Repeat this test for the remaining
seven zones, checking that their allocated LEDs respond accordingly.
Step 7: it’s now time to interface the
system to your PC and test the various
features. Connect it to the PC via an
RS232 serial cable, then install and
run the software. Refer to the large
“Driving The Software” panel for
information on the various software
interfaces.
Step 8: click on the “Comms” setup
button and select the serial port that’s
to be used. Now click on the button
labelled “Test”. If you have selected
the correct port number, you should
see all the LEDs on the front of the
unit counting up in BCD (binary coded
decimal). You should also hear the
internal siren briefly chirping in synchronisation with the LEDs.
If this doesn’t occur, check that the
port is operational and valid. Doublecheck to ensure the integrity of your
serial port cable and that the RS232
IC is installed the right way around.
Step 9: before proceeding to secure
the system with passwords, check the
door strike outputs. These are operated
through the Arm/Disarm interface.
Using your DMM, you should be
able to measure 12V across their
terminals when activated. Don’t set
the duration time for any given strike
longer than it really needs to be. They
siliconchip.com.au
Fig.8: the complete circuit details for the optional keypad module. It’s based on a PIC16F84A microcontroller (IC1)
and a standard 3 x 4 matrix keypad.
draw high current and the power supply is quite modest.
Step 10: click on the arm button for
zone 1. The internal siren should
briefly chirp and the corresponding
“armed” LED should light. Click on
the disarm button and check that the
LED extinguishes.
Step 11: secure the system with passwords and configure the entry/exit
delays, siren duration times and autorearming features (if needed).
Step 12: this is the fun part – install the
alarm into your premises and run the
cables to all the sensors.
The keypad
The keypad is for those who don’t
wish to use a computer to arm and
disarm the main alarm system. That
way, you only need a PC for the initial
system set-up and to define parameters
and passwords.
A keypad is also useful if you want
to use the system as a domestic house
alarm and don’t need the versatility
offered by the Windows-based softsiliconchip.com.au
ware. Alternatively, you can build
the keypad for emergency use only
– ie, to arm and disarm the system in
the event of a blackout or computer
malfunction.
In the latter case, the keypad also
lets you do away with the “Hard-Wired
Key”, which can be rather inconvenient to use. If the power fails, just plug
the keypad in and you’re in business.
Furthermore, the keypad can both arm
and disarm the system, whereas the
“Hard-wired Key” can only disarm
the system
Up to four passwords can be defined
via the Windows software, as shown in
one of the screen grabs. However, you
don’t have to type in a password for
all four – just leave them blank if you
don’t require them. Note that to access
this feature, you need to be logged in
as either an Owner or Admin.
These passwords are stored in the
PIC microcontroller in the main alarm
unit (ie, in EEPROM) and must be four
digits in length (numerals only).
The star (*) and hash (#) keys are
used only to arm and disarm the system. To arm the system, just enter the
4-digit code and press *; to disarm
it, enter the 4-digit code and press
#. Easy!
If the code is correct, a short melody
is played. However, if the code is entered incorrectly, then a short series
of chirps will be heard. It’s then just a
matter of re-entering the correct code
but you only get five attempts, after
which the system locks you out for
30 minutes.
By the way, this unit is quite universal and could easily be adapted
to suit a host of other applications.
It’s not just suitable for used with the
PC-Controlled Alarm.
Another PIC
Inside the keypad module is – yes,
you’ve guessed it – another a PIC microcontroller. This time, it’s a 16F84A
and this is teamed with a standard
numerical keypad and a handful of
minor parts.
A vital ingredient is the software
March 2006 31
Driving The Software For The PC-Controlled
Burglar Alarm
T
HE SOFTWARE for the PC-Controlled Burglar Alarm has been tested with Windows XP and Windows 98SE but should
also work with Windows 95, Windows 98 and Windows 2000. It’s separated into seven main sections to make it easy
to drive: (1) Access Control; (2) Log On/Off; (3) Comms Setup; (4) Zone Configuration; (5) System Logging; (6) Entry/Exit
Delays and Arm/Disarm. The main GUI is shown immediately below.
The software assumes no security until an owner password is created. If you have just loaded the software and want
to test the unit before finalising access settings, you can just basically go straight to the Communications Setup window
to begin testing. Select the Comm port that you wish to use, then cover your ears and click on the relevant Test button
(see GUI below right). The internal siren should sound and all of the LEDs on the front panel should start counting up
in binary. If this occurs, then there’s a good chance that
your new alarm system is ready for installation. Before
doing so, however, it would be a good idea to check that
all the zones can be armed and disarmed.
THIS IS THE MAIN GUI for the Windows-base software.
It’s divided into seven sections (no confusing drop-down
menus to explore), which makes it really easy to drive.
Clicking on each of these sections brings up the various
other configuration panels shown on these pages but first
you have to define the various users and set-up access
control as shown in the GUI at the bottom of this page.
Once you have the system setup, you arm or disarm the
system by simply logging on and clicking the Arm/Disarm
section to bring up the GUI on the facing page. It’s then
just a matter of clicking the Arm or Disarm button for
each Zone, as appropriate – or you can arm or disarm
all zones simultaneously.
THE COMMUNICATIONS SETUP screen allows you to define
the RS232 ports that you wish to use to communicate with
the PC and the (optional) modem dialler. Make sure that
you don’t include any spaces in the phone number string.
The two Test buttons help you choose the correct serial ports
on the PC and to diagnose faults – see text.
PASSWORDS CAN BE alphanumeric
in which case you have to use a PC
keyboard to log on. Alternatively, if
the password has numerals only, you
can enter it by clicking the numbers
on the virtual keypad shown here.
THE FIRST STEP IN SETTING UP THE ACCESS CONTROL for the
system is to create an “Owner” user name & password.
This is done by keying in a name and password, then selecting
the “Owner” option and clicking the “Add” button. Doing that
gives you control over the entire system. However, you cannot
do much unless you log on. To do that, click the “Log ON” button
at bottom right and key in the password that you just set up.
If the password is valid you will be greeted with a MSG box
that says “Hi”.
You can create up to four Owners, eight Admins and 16 Users.
Owners can create or delete other Owners, Admins and
Users, while Admins can create and delete Users only. Users
have defined access level privileges, most of which are selfexplanatory.
32 Silicon Chip
siliconchip.com.au
ABOVE: THIS IS WHAT THE “ARMING & DISARMING” GUI looks like. You need to
have Owner or Admin access to modify these settings. Auto Rearm does exactly
what it states – after a preset time, a zone that’s been disarmed automatically
rearms itself. This could be useful for monitoring an entrance way, for example,
and keeping a log of people who have entered (or left) a building.
Note that you can give each zone a label value (eg, “Kitchen”, “Lounge Room”,
etc). There are lots to choose from, so that you can easily identify zones. Clicking
the “OK” button saves any new settings.
The virtual red LEDs next to the Disarm buttons clearly indicate which sectors have
been armed. When you arm or disarm a zone, you will hear the internal siren briefly
chirp to indicate success. You can also arm/disarm all zones simultaneously.
Finally, the Door Strikes buttons at the bottom allow Owners, Admins or Users
with defined access to operate the door strikes. Five seconds should be more than
ample time for the strike to be activated but you can adjust this value if you wish.
THE CONFIGURATION GUI allows you to
specify the sensors to be used for each
zone – ie, either normally open (N/O) or
normally closed (N/C). The status LEDs
indicate the condition of each zone. When
a zone is triggered, its corresponding
LED lights up.
This GUI also allows you to set up the
keypad codes and shows the config
uration for the “Hard Wired Key”. You
simply select the BCD code and the
number of inserts required and the
accompanying diagram shows the wiring
for the D9 connector.
Make sure that the system is plugged
into your PC’s serial port before clicking
the “OK” button, so that the settings are
saved to the PIC’s EEPROM.
siliconchip.com.au
THE ENTRY/EXIT DELAYS GUI lets
you customise the delay settings
for each zone (0-255s). As with
other settings, these delay times
are saved in the PIC, so that the
system can be operated without
a PC if necessary after set-up
(although you do lose features).
By default a tripped zone is
automat
i cally rearmed 30
seconds after the siren times
out. You can set the maximum
number of “rearms” to anywhere
between 0 and 9, so that a zone
will eventually be locked out after
repeated triggerings (eg, to guard
against a faulty sensor).
Check the noise pollution laws for
your state before implementing
this feature.
Set this value to 0 if you want each
zone to be locked out immediately
after it has been triggered.
THE WIRING DIAGRAM in the
Configuration GUI shows you how
to wire the Hard Wired Key for a
given BCD code and number of
inserts.
March 2006 33
The data logger records all activity from people logging onto the system, as well
as which zones have been triggered and the alarm conditions. To gain access to
this screen you must have Owner, Admin or set user level privileges. Each time
the software loads, the data log loads as well. It’s then automatically saved at a
specified interval. This arrangement means that you don’t have to worry about
power failures or having to manually save the logs each time you power down
the PC. However, you still have the freedom to manually load and save logs. Up
to 2000 samples can be stored which should be more than enough.
that’s programmed into the PIC. This
software monitors the key presses and
produces a serial data stream which
is then fed to the PIC microcontroller
inside the alarm unit. This in turn
scans its passwords database and if
it finds a match, allows access to the
system.
The keypad is perfectly standard –
you just press the digits, hit the hash
key and the PIC microcontroller spits
the digits out serially at 2400 baud.
Pressing the hash key inserts
CHR$(66) at the start of the data string,
while pressing the star key results in
CHR$(88) being sent first. This instructs the alarm to either disarm or
to arm, respectively.
After the function BYTE, the 4-digit
code follows in a plain ASCII format.
A few minutes of experimenting will
allow people with relatively modest
PICAXE experience to interface it to
their own projects.
Automatic resetting
Another feature of the keypad module includes automatic resetting if it’s
at idle. This simply means that if you
don’t press in each subsequent digit
There are just a few wire
links inside the “HardWired Key” and the
software shows you how
to wire it. Note that when
using this key, you must
allow at least a one second
time frame between each
insertion and withdrawal. If
the time frame is too great,
the system will lock out for
a short period.
34 Silicon Chip
in the code sequence within four seconds, the system resets and you have
to start over again.
This is done to ensure security – ie,
it ensures that you have to key in your
complete password every time you
want to arm or disarm the system.
A piezo transducer and a red LED
provide audible and visual indication
of keypad activity. Each time a digit
is pressed, a “chirp” is produced by
the transducer. Other sounds are also
produced by transducer, depending on
the status of the keypad (eg, to indicate
correct or incorrect codes).
In use, the unit plugs directly into
the D9 female socket on the alarm to
establish the communications link. In
addition, a +5V rail to power the unit
is also obtained from the D9 socket.
You can plug the unit into the D9
socket (and unplug it) with power applied. However, don’t swap between
the PC’s serial port and the keypad port
while the Windows-based software is
running, otherwise the alarm system
may lock up.
If it does, you’ll have to reset the
alarm by removing all power to it
(including the back-up battery). Note:
you can “hot-swap” from the keypad to
the PC and vice versa if the Windowsbased software is showing the main
menu GUI only, or is not running.
How it works
Fig.8 shows the complete circuit
details for the keypad module. As
stated, it’s based on a PIC16F84A
microcontroller (IC1) and a standard
3 x 4 matrix keypad. The keypad rows
are monitored via ports RA3, RB3, RB2
& RB0, while the columns connect to
ports RB1, RA2 & RA4.
The latter three ports (ie, to the
columns) are all set as outputs and
are switched at a rate of about 100Hz
“total cycle time” – ie, each port is
toggled from high to low about 33
times a second.
RA3, RB3, RB2 & RB0 (which
monitor the rows) are all configured as
inputs. These are all normally pulled
high to +5V via 100kW resistors, to
ensure they don’t “float”. In addition,
a 2.2kW resistor is connected to RA4
due to the fact that this pin can sink
but not source current.
In operation, IC1 pulls each of the
columns low in turn and checks for key
presses on the rows. For example, if
RA2 is low and digit 5 is pressed, the
RB3 will be pulled low. IC1 decodes
siliconchip.com.au
Fig.9: follow this diagram and the photo above to build the keypad unit. The external connections from the PC board
are all made via pin headers and connectors.
these key presses and produces a digital data stream at its RA1 port.
This information is then fed via the
D9 connector to port RC3 of the PIC
microcontroller inside the main alarm
unit. If the password is correct, RA0
on IC1 is briefly toggled high for about
200ms, LED1 flashes and the piezo
transducer plays a short “melody” to
acknowledge that the correct code has
been entered.
Note that there are two very distinct
“melodies” – one for a valid password
and one for an invalid one.
LED1 and the piezo transducer are
switched on and off via Q1, which is
in turn controlled by port RB5 on IC1
via a 4.7kW base resistor (this sets the
nector on the display board, inside
the main unit. This connects to pin 1
on the D9 socket (note: you will have
to make this connection inside the
main alarm unit). A 10mF electrolytic
capacitor and a 100nF MKT capacitor
provide a modest degree of filtering for
the supply rail.
Finally, IC1 is clocked at 4MHz, as
set by crystal X1. The two associated
base current to just under 1mA). Assuming that the beta gain of Q1 is 100
then the available collector current
will be close to 100mA.
When RB5 goes high, Q1 turns on
and so LED1 and the transducer also
turn on. A 330W resistor limits the current through the LED to about 10mA,
while a 15W resistor limits the volume
from the piezo transducer.
Reset line & power
Table 2: Capacitor Codes
The MCLR pin of IC1 is pulled to
the +5V supply rail by a 2.2kW resistor.
This ensures that the microcontroller
is reset when power is first applied.
The +5V supply itself is derived
from a +5V rail on the keysocket con-
Value μF Code EIA Code IEC Code
100nF 0.1µF
104
100nF
22pF NA
22
22p
Table 1: Resistor Colour Codes
o
o
o
o
o
o
siliconchip.com.au
No.
4
1
2
1
1
Value
100kW
4.7kW
2.2kW
330W
15W
4-Band Code (1%)
brown black yellow brown
yellow violet red brown
red red red brown
orange orange brown brown
brown green black brown
5-Band Code (1%)
brown black black orange brown
yellow violet black brown brown
red red black brown brown
orange orange black black brown
brown green black gold brown
March 2006 35
Par t s Lis t
Keypad Advantages & Disadvantages
1 PC board, code 07203061,
104 x 38mm
1 IP65 ABS case, 115 x 65 x
40mm (Jaycar Cat. HB-6122)
1 front panel label (download
from www.siliconchip.com.au)
1 4MHz crystal (X1)
1 3 x 4 matrix numerical keypad
1 piezo transducer (Jaycar Cat.
AB-3440)
1 D9 male connector
2 D9 female connectors
2 D9 backshells
6 M3 x 10mm screws & nuts
4 M3 x 5mm screws
1 18-pin IC socket (for IC1)
1 150mm length rainbow cable
1 1-metre length 4-core cable
2 small cable ties, 100mm
1 4-way SIL locking pin header
& connector, 2.54mm (CON1)
1 2-way SIL locking pin header
& connector, 2.54mm (CON2)
1 10-way SIL locking pin header
& connector, 2.54mm (CON3)
The keypad module was developed mainly to make it easier to disarm the
alarm system in the event of a mains or PC failure, as opposed to using the
hard-wired key. Unlike the hard-wired key though, it can also be used to arm
the system. That means that you can do away with the PC and just rely on the
keypad if that’s more convenient.
There are some drawbacks to relying solely on the keypad, though. Basically,
you lose the nifty access control features that the PC software has to offer.
Four codes can be defined for the keypad but they all provide full control over
the system – the keypad either turns the whole system (ie, all zones) on or off.
Note that the independent zone entry/exit delays and the siren duration time
are stored in the main system, so you don’t lose these settings if you decide
to rely on the use of the keypad after the initial set-up. There’s just one thing
to watch out for here – if you disarm the system using a PC and then rearm
it using the keypad, the auto rearm options will kick in (assuming they’re set).
This is because the PC sends a command to the alarm for auto-rearming when
you click on the disarm button.
This command also includes the time duration before auto-rearm is applied
(although this obviously only occurs if it’s enabled). This is something to watch
out for if you decide to use both the keypad and the PC.
Semiconductors
1 PIC16F84A microcontroller programmed with keypad.hex (IC1)
1 BC548 NPN transistors (Q1)
1 5mm red LED (LED1)
Capacitors
1 10mF 16V electrolytic
1 100nF MKT polyester (code 104)
2 22pF ceramic
Resistors (0.25W, 1%)
4 100kW
1 330W
1 4.7kW
1 15W
2 2.2kW
Where to buy parts
PC boards for this project are available from RCS Radio, phone (02)
9738 0330. In addition, RCS Radio
offers a programming service for
the PIC chips used in both the
keypad and the main alarm unit.
EXT
Siren
+
-
INT
Siren
+
-
Door S
A
+
-
Door S
B
+
-
22pF capacitors provide the correct
loading on the crystal, to ensure reliable starting.
Construction
All the parts except for the D9 connector, transducer and LED are installed on a PC board coded 07203061.
It measures just 104 x 38mm and fits
into a standard IP65 plastic case from
Jaycar.
Fig.9 shows the parts layout on the
PC board. It should only take you 10
minutes to assemble and you can install the parts in any order. Use a socket
for microcontroller IC1 and take care
to ensure that this IC and transistor Q1
are both oriented correctly.
Similarly, make sure that the 10mF
capacitor is installed correctly. Table 1
shows the resistor colour codes but it’s
also a good idea to check them using
a digital multimeter.
Don’t forget the wire link that’s adjacent to the 4MHz crystal (X1). The
Tamper
Switch 1
Com N/C
GND
RX TX
Alarm OUT
< ZONE INPUT >
2 3 4 5 6 7
+12V
8
~ ~
AC IN
Alarm OUT
Fig.10: these labels can be cutout and affixed to the main board in the alarm
system – ie, adjacent to the external wiring connectors.
36 Silicon Chip
crystal can go in either way around.
Once the board assembly is complete, mount the keypad on the lid
of the case – use the front panel label
as a template to mark the cutout and
the four mounting holes. The cutout
can then be made by drilling a series
of holes around the inside perimeter,
knocking out the centre piece and filing the job to a smooth finish.
That done, the kepad can be fastened
to the lid using four M3 x 10mm screws
and nuts. The PC board can then be
mounted in position. It’s secured to
the integral pillars in the case using for
M3 x 5mm screws – see photo.
Finally, complete the construction
by wiring the D9 connector, piezo
transducer, LED1 and the keypad to
their respective connectors and plugging them into the on-board headers.
Testing
Before testing, you need to open up
the main alarm unit and connect a link
between pin 1 of the D9 connector and
one of the +5V pins on the key socket
connector. This is necessary so that a
+5V rail is applied to pin 1 of the D9
connector on the keypad module.
After that, it’s simply a matter of
connecting the keypad module to the
alarm unit, setting up the password(s)
in the software (via the configuration
GUI) and trying it out.
That’s it – your new alarm system
SC
is ready for action.
siliconchip.com.au
|