Hi,
I wanted to have an alarm system to work on three separate areas it was actually two separate buildings and a garage. Each zone (building) would be covered by N/C Normally closed switches reed magnetic ones but equally they could be changed for whatever fits the zone.
I wanted to have an lcd screen and I chose an OLED 16x2 lines screen the budget one from RevEd. I tried to get the program to fit on an 08M2 but there is just not enough pins to do the job so I splashed out for a 14M2 Which just works with a couple of input pins left over.
I wanted to be able to have two sirens. One that I could here inside and one that was external. I wanted the internal one to wake me but on a switch that I could turn off so I could hear my self think while dealt with the alarm. I wanted the external alarm to switch off after a set amount of time so as not to annoy the neighbours.
I wanted to be able to switch off one of the zone areas if I wanted to but still have the others alarmed and this to be shown on the OLED screen.
Now I am not saying I have achieved all this but it's pretty close. I have left the switching off of the external alarm after a certain amount of time because I haven't got around to it yet and I can't decide how best to do it. But hey, the rest seems to work so here it is.
Circuit diagram
Basic program in two halves because of limitations of forum.
I hope you enjoy dissecting it. Please tell me if you have other ways to do it.
Ken.
Subroutines in next message...
I wanted to have an alarm system to work on three separate areas it was actually two separate buildings and a garage. Each zone (building) would be covered by N/C Normally closed switches reed magnetic ones but equally they could be changed for whatever fits the zone.
I wanted to have an lcd screen and I chose an OLED 16x2 lines screen the budget one from RevEd. I tried to get the program to fit on an 08M2 but there is just not enough pins to do the job so I splashed out for a 14M2 Which just works with a couple of input pins left over.
I wanted to be able to have two sirens. One that I could here inside and one that was external. I wanted the internal one to wake me but on a switch that I could turn off so I could hear my self think while dealt with the alarm. I wanted the external alarm to switch off after a set amount of time so as not to annoy the neighbours.
I wanted to be able to switch off one of the zone areas if I wanted to but still have the others alarmed and this to be shown on the OLED screen.
Now I am not saying I have achieved all this but it's pretty close. I have left the switching off of the external alarm after a certain amount of time because I haven't got around to it yet and I can't decide how best to do it. But hey, the rest seems to work so here it is.
Circuit diagram
Basic program in two halves because of limitations of forum.
I hope you enjoy dissecting it. Please tell me if you have other ways to do it.
Ken.
Code:
;directives
#picaxe 14m2
;pinouts
; +V |¯¯¯|0V
; serial in ->c.5|===|b.0-> serial out *
; * <->c.4|===|b.1<-> *
; * ->c.3|===|b.2<-> *
; * <->c.2|===|b.3<-> *
; * <->c.1|===|b.4<-> *
; * <->c.0|___|b.5<-> *
; * = pin used (Interrupts only on pins c.0,c.1,and c.2)
;OLED 16x2 screen positions
; |¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|¯¯¯|
; |128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|
; |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
; |192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|
; |___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
;for information this is stored in the 18M2 chip on the OLED board by Axe133.bas file
;EEPROM $20, ("Entry in Zone 1 ") ;2 store msg in the EEPROM memory
;EEPROM $30, ("Entry in Zone 2 ") ;3 store msg in the EEPROM memory
;EEPROM $40, ("Entry in Zone 3 ") ;4 store msg in the EEPROM memory
;EEPROM $50, ("Code Not Correct") ;5 store msg in the EEPROM memory
;EEPROM $60, ("All Zones Secure") ;6 store msg in the EEPROM memory
;EEPROM $70, ("Monitoring Zones") ;7 store msg in the EEPROM memory
;EEPROM $80, (" Check Zones ") ;8 store msg in the EEPROM memory
;EEPROM $90, (" Alarm Disabled ") ;9 store msg in the EEPROM memory
;EEPROM $A0, (" Alarm Enabled ") ;10 store msg in the EEPROM memory
;EEPROM $B0, ("This is msg 11 ") ;11 store msg in the EEPROM memory
;EEPROM $C0, ("This is msg 12 ") ;12 store msg in the EEPROM memory
;EEPROM $D0, ("This is msg 13 ") ;13 store msg in the EEPROM memory
;EEPROM $E0, ("This is msg 14 ") ;14 store msg in the EEPROM memory
;EEPROM $F0, ("This is msg 15 ") ;15 store msg in the EEPROM memory
;constants
symbol oled = b.0 ;OLED out pin
symbol baud = N2400
symbol home = 128 ;leftmost position on topline OLED
symbol base = 192 ;leftmost position on bottom line OLED
symbol Siren= b.4 ;goes to internal siren speaker PWM out on this pin
symbol LED1 = b.5 ;insecure zones LED
symbol SirenSW = pinc.4 ;siren switch while dealing with alarm
symbol sirenX = b.3 ;Xternal siren on a relay
;variables
symbol Slct = b0 ;button selection
symbol nPos = b1 ;new position
symbol oPos = b2 ;old position
symbol Slct2= b3 ;enable/disable menu selection
symbol Up = pinb.1 ;input switch up button
symbol Down = pinb.2 ;input switch down button
symbol btnS = pinc.3 ;input switch select/enter button
symbol Z1 = pinc.0 ;input zone1 switches
symbol Z2 = pinc.1 ;input zone2 switches
symbol Z3 = pinc.2 ;input zone3 switches
symbol Z1f = b20 ; zone 1 tick or cross
symbol Z2f = b21 ; zone 2 tick or cross
symbol Z3f = b23 ; zone 3 tick or cross
symbol Z1disabled=b24 ;zone 1 has been disabled if true
symbol Z2disabled=b25 ;zone 2 has been disabled if true
symbol Z3disabled=b26 ;zone 3 has been disabled if true
;boolean
symbol true = 1
symbol false = 0
;initialise variables
nPos = 127
oPos = 143
;initialise CGRAM characters
pause 1000
; serout oled,baud, (254, 112, 33, 33, 33, 35, 51, 59, 46, 38);14 tick
pause 1000
; serout oled,baud, (254, 120, 49, 42, 36, 36, 36, 42, 49, 32);15 cross
pause 1000
init:
if Z1 = 0 and Z2 = 0 and Z3 = 0 then ;if zone switches are closed then zone ok
serout oled,baud, (254,1) ;clear display when reset
pause 30
serout oled,baud,(254,home) ;set position for eeprom message
serout oled,baud,(253,6) ;display message from eeprom in 18m2 to the oled
;or use this instead serout oled,baud, (254,home,"Hello Zone Alarm");show reset entry message
Pause 1000
setint or %00000111,%00000111 ;set interupt on c.0 or c.1 or c.2 high interrupt
serout oled,baud,(254,base) ;set position for eeprom message
serout oled,baud,(253,7) ;display message from eeprom in 18m2 to the oled
;or use this instead serout oled,baud, (254,home," Select menu > ")
else
;One of the Zones are Insecure
serout oled,baud,(254,home) ;set position for eeprom message
serout oled,baud,(253,4) ;display message from eeprom in 18m2 to the oled
;serout oled,baud, (254,home,"Zone/s Insecure ")
pause 5
serout oled,baud, (254,base) ;set position for eeprom message
serout oled,baud, (253,8) ;Check zones display message from eeprom in 18m2 to the oled
High LED1
pause 5000
reset
endif
gosub enabled ;tests whether zone switches are closed or open and stores result Z1f Z2f Z3f
gosub welcome ;displays the first zone menus
main:
; select button pressed
if down = 1 then
Slct = Slct + 1
if Slct > 2 then
Slct = 0
end if
gosub position
end if
if up = 1 then
Slct = Slct - 1
if Slct > 2 then
Slct = 2
end if
gosub position
end if
if btnS = 1 then
on Slct gosub Zone1, Zone2, Zone3
end if
goto main
end
Attachments
-
39.9 KB Views: 362