Breach Alarm System

 

The purpose of this system is simple....detect a perimeter breach. It will be installed in a home with sensors on each door and window as well as PIR motion sensors. There will be two modes, 'Stay' and 'Away'. In the 'Stay' mode, only the door and window sensors would be armed. In 'Away' mode, all sensors would be armed. If a breach occurs, a siren will sound both inside and outside the home. A strobe may also be installed outside of the home.

The system will consist of a keypad panel, control panel, sensors, siren and strobe. The keypad panel will have a 16 button keypad with LCD. The control panel will house the master picaxe, control board, power supply and necessary relays. The sensors will consist of magnetic contacts on the doors and windows with the possibility of PIR sensors in key areas inside the home.

A later expansion is planned with the addition of  a GSM module and electric fence monitor. The GSM module will give the system the ability to call as well as text message the owner depending on the situation. The electric fence monitor will consist of a picaxe installed in the barn communicating to the control panel located inside the home via RF bridge. Its purpose will be to monitor the electric fences' status and text message the owner if the fence becomes inoperable.

As any project goes, one needs to know the overall system operation before you can begin building individual components. So lets figure it out. 

The alarm should be armed and disarmed via the keypad panel. As to how the keypad tells the control panel the alarm has been armed or disarmed is undecided. Monitoring the sensors and operation of the siren and strobe will be the responsibility of the control panel. In future expansions, the GSM module will be communicating directly with the control panel. The electric fence monitoring system will also communicate directly with the control panel.

The Keypad Panel

My belief was that the keypad panel would be the toughest part of the basic project to complete. therefore Ill attempt to tackle it first. My keypad had to have two basic abilities to be considered functional:

So I know what my keypad needs to do, now I need to figure out how to do it. Well I need a keypad, a display, a picaxe and a piezo sounder. The keypad will not be a conventional matrix keypad. It will be the ADC Keypad we've been working on. It allows me to use one input instead of 4 inputs and 4 outputs as a conventional matrix keypad would require.

The display will be an LCD. For testing, I am using the AXE033. The final display may change to a 20x4 display.

The picaxe used for testing the code is a 40X1. The final picaxe for the keypad will probably be an 18X because of the code volume.

A basic piezo sounder will be used.

The Code

eeprom 0,(1,2,3,4)                                               'Sets default PIN
serout 7,N2400,(254,1)                                       'Clear and initialize display
high 6                                                                   'Sets LED to disarmed state

keyscan:
let
b2=17                                                              'Sets key value to 17
readadc
0,b1                                                        'Reads current keypad value
pause 100
let
b2=b1+8/15                                                    'Calculates key value for b2
if
b2=17 then keyscan
if
b2>0 and b2<17 then gosub key_chirp              'Sends valid key values to chirp subroutine
if
b2>0 and b2<13 then store                                'Sends numeric key values to store routine
if
b2=13 and bit2=1 then return endif                     'Enter btn:If PIN valid, accepts new PIN
if b2=13 then validate                                            'Enter btn
if
b2=14 then res                                                   'Cancel btn
if
b2=15 and bit1=1 then status                             'Set btn:If PIN valid, triggers arming or disarming of alarm
if
b2=16 and bit1=1 then pin                                 'PIN btn:If PIN valid, triggers PIN change mode
goto
keyscan

key_chirp:
pulsout
4,10                                                         'Chirps piezo with button press
return

store:                                                                   'Stores key values to scratchpad
inc
b3                                                                  'Creates storage order
if b3>4 then let b3=0 endif
branch
b3,(filler,store1,store2,store3,store4)
filler:
store1:                                                                  'PIN first num storage
put 0,b2
serout
7,N2400,(254,198,"*")
goto
keyscan
store2:                                                                  'PIN second num storage
put 1,b2
serout
7,N2400,(254,199,"*")
goto
keyscan
store3:                                                                  'PIN third num storage
put 2,b2
serout
7,N2400,(254,200,"*")
goto
keyscan
store4:                                                                  'PIN fourth num storage
put 3,b2
serout
7,N2400,(254,201,"*")
goto
keyscan

validate:                                                                'Reads saved PIN and compares to keyed PIN
serout 7,N2400,(254,1)                                       'Validation display simply for visual effect
serout 7,N2400,(254,128,"Validating")
serout
7,N2400,(254,138,"..")
pause
500
serout
7,N2400,(254,140,"..")
pause
500
serout
7,N2400,(254,142,"..")
pause
300
ptr =0                                                                                                                                'Sets scratchpad pointer to 0
read
0,b4,b5,b6,b7                                                                                                            'Reads current PIN from EEPROM
if @ptrinc=b4 and @ptrinc=b5 and @ptrinc=b6 and @ptr=b7 then let bit1=1 endif            'Compares saved PIN to entered      
if bit1=1 then menu                                                                                                             'PIN and sets validation bit
serout 7,N2400,(254,128,"  PIN  Incorrect  ")
pause
2000
goto
res

menu:                                                                     'Displays menu options
serout
7,N2400,(254,128,"ARM   PIN   CNCL")
pause
10
goto
keyscan

status:                                                                     'Tests whether alarm is armed or disarmed
if bit0=0 then arm                                                   ' in order to execute correct routine
if
bit0=1 then disarm

arm:                                                                       
let bit0=1                                                                'Set status bit to disarmed
let pins=% 00100000                                              'Switch off unarmed LED, switch on armed LED
serout 7,N2400,(254,128,"  System ARMED  ")
high 4                                                                     'Sound piezo buzzer one time for one sec
pause 1000
low 4
goto
res

disarm:                                                                   
let bit0=0                                                                 'Set status bit to disarmed
let pins=%01000000                                                'Switch off armed LED, switch on unarmed LED
serout 7,N2400,(254,128,"System  DISARMED")
for b8=1 to 3                                                           'Sound piezo buzzer three times for one sec each
    high 4
    pause 1000
    low 4
    pause 750
next b8

let b8=0
goto res

pin:                                                                           'Asks for and writes to EEPROM the new PIN
let bit2=1                                                                  'Indicates to keyscan the PIN change routine is active
serout 7,N2400,(254,128," Enter New PIN  ")
let b3=0                                                                   'Sets store order to zero
gosub keyscan
ptr =0                                                                      'Sets scratchpad pointer to zero
write 0,@ptrinc,@ptrinc,@ptrinc,@ptr                     'Writes entered pin from scratchpad to EEPROM
pause 1000
serout 7,N2400,(254,129," PIN Accepted")
serout 7,N2400,(254,192," ")
pause 3000

res:                                                                           'Resets temp PIN storage, key# and key order
serout 7,N2400,(254,1)
let b0=0                                                                    'Resets 'PIN valid' and 'Change PIN Active' bit
let b3=0                                                                    'Resets Key Value and PIN storage order
let w2=0                                                                   'Resets b4 and b5 of PIN storage
let w3=0                                                                   'Resets b6 and b7 of PIN storage
put 0,0,0,0,0                                                             'Resets scratchpad variables
goto keyscan

 

Schools back in.... will continue next break.

Home