Shop OBEX P1 Docs P2 Docs Learn Events
Hackaday, Alarm System - Propeller, keypad (w/MCP23008), LCD — Parallax Forums

Hackaday, Alarm System - Propeller, keypad (w/MCP23008), LCD

Ron CzapalaRon Czapala Posts: 2,418
edited 2015-07-15 16:52 in Robotics
Project was posted on Hackday on May 30 - http://hackaday.com/2014/05/30/homemade-alarm-system-doesnt-lack-features/

This project is an alarm system built for my garage.

It uses the Parallax 4x4 membrane keypad in conjunction with a Microchip MCP23008 I2C I/O Expander chip for controlling the system.


A cog is started to monitor the keypad. It uses the Interrupt-On-Change feature of the MCP23008.
When a key on the keypad is pressed, the MCP23008 interrupt pin goes LOW and the propeller scans the rows and columns to determine which key is pressed.
Then it clears the interrupt as the key is released.


The main cog maintains a circular buffer to hold the last four keypad characters.


Another cog is used to generate various indciator tones with a piezo speaker.


The system may be in one of several states:
Not Armed
Exit Delay (45 sec delay)
Armed
Window trigger (immediate alarm)
Door trigger (60 sec delay before alarm)


Features of the system include:


1. 45 second exit-delay when arming the system
piezo buzzer beeps each second and changes to a double beep for the last 15 seconds
2. Alarm siren will be triggered immediately if the window is opened
3. When the side door is opened, there is a 60 second delay to allow a 4 character disarm code to be entered
4. The siren will sound for 3 minutes or until the disarm code is entered.
If disarm code is not entered within 3 minutes, the alarm will cease and the system will return to the armed state
if the door/windows are properly closed.
However, if door or window is still ajar, the alert siren will sound for an additional 3 minutes.
5. LCD backlight turns off after specified delay if no key is pressed or status change occurs.
6. The master (disarm) code is stored in the second 32k of the 64k EEPROM and can be modified by entering a fixed "system code"


To arm the system (from Not Armed state), press the "A" key and the piezo buzzer will beep for the 45 second exit-delay.
To cancel the arming during the exit-delay, press the "C" key and the system will return to the "not armed" state.
To skip the 45 second exit-delay, press the "A" key a second time to immediately arm the system.


While in the armed state, the system will constantly be monitoring the window and door sensors.
It will also be checking to see if the disarm code has been entered, after which it will return to the "not armed" state.

NOTE: In order to see the LCD display clearly, the video is best viewed full screen from YouTube directly:
1080p HD video https://www.youtube.com/watch?v=plLQFZlsKHA

Here is the schematic for the kepad and MCP23008: 

Comments

  • PublisonPublison Posts: 12,366
    edited 2014-05-09 02:54
    Pretty neat Ron!

    Jim
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-09 06:54
    Publison wrote: »
    Pretty neat Ron!

    Jim

    Thanks Jim. I still have more programming and of course adding relays or mosfets to handle the 12V siren and strobe light.

    I also want to add some code to allow the disarm code to be modified and stored in the Propeller's EEPROM. (possibly the delay parameters as well)

    I am attaching a zip file with a demo program for the keypad/MCP23008 and piezo speaker objects (See post #5 for zip file)
    and the circular buffer code.

    It displays debugging info on the Parallax Serial Terminal.
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-05-09 07:22
    Well done!! Great project and very well documented.

    This will go on my never ending list of things to build!
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-12 18:37
    I made up a second MCP23008 PCB board/keypad and discovered that my diagram in the first post (and also in the I2CKeypad spin file) was incorrect.

    The INT pin is next to the VSS pin on the MCP23008 and the unused pin is between the RES and INT pins.

    I have corrected the diagram above and also in the I2CKeyPad.spin file attached zip file in this post.

    Sorry for any confusion!

    - Ron

    I am still working on the project and now the disarm code can be modified & stored in the 64K EEPROM on most Propeller boards.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-22 20:07
    Making some progress.

    I created a little PCB board with two IRF3708 MOSFETs which will be used to control the siren and strobe light.

    I also made another board which has two PS2501-1 Optoisolators which will be used to connect to my home security system (12V outputs).

    For example, this will allow the home system to tell the garage system to activate the strobe light only. (I have a buried multi-conductor cable between the garage and house).

    The boards are mounted to a piece of LEXAN with standoffs.

    I need to mount the LCD, keypad and piezo on the door and tweak the program some more but it is coming along.


    attachment.php?attachmentid=108807

    Alarm panel.jpg
    1024 x 768 - 88K
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-24 12:41
    Just a few more steps and I'll install it. I am using a DC-DC converter to supply 7V to the propeller boards and will add a battery charger/maintainer to keep the battery charged.

    Cutting the opening for the LCD was really fun - NOT.

    I used a piece of so-called isinglass (actually plastic - think flexible boat window) to protect the LCD.

    I used some very thin shielded cable (thanks to Tracy Allen's post) since I was getting some phantom keypad data from the I2C MCP23008.

    EDIT: The system draws 38mA at 12V (after the LCD backlight times out) and 83mA while the backlight is on.

    Haven't yet tried with the siren and strobe light activated.
    The siren is supposed to be 30 watts @12V and the strobe around 140mA


    attachment.php?attachmentid=108877
    attachment.php?attachmentid=108886


    AlarmPanel.jpg
    System parts.jpg
    1024 x 964 - 89K
    1024 x 768 - 158K
  • WBA ConsultingWBA Consulting Posts: 2,933
    edited 2014-05-25 22:31
    Very nice work! Been keeping an eye on this thread because this was a good idea for a project and I am very pleased with your finished setup. Good job!
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-26 06:28
    Very nice work! Been keeping an eye on this thread because this was a good idea for a project and I am very pleased with your finished setup. Good job!

    Thanks! It has been interesting. I still need to connect the battery charger/maintainer - I used a DPDT switch for the system power.
    It connects the charger to the battery only when the system is powered up.
    I also added a diode between the battery and the DC-DC converter to protect against a reverse polarity situation

    I also have some more programming to do regarding the optoisolator inputs but I am attaching the latest code archive.

    If the PS2501 optoisolator on pin27 is provided with 12V, pin27 goes low and the strobe light will turn on.
    My home alarm system has a latch output that I will connect to this optisolator so if the home system is triggered, the strobe light on the garage will flash until the home system is disarmed.

    I added a LED to the door panel which begins blinking when the siren sounds and continues after the siren stops. Entering the disarm code stops the LED blinking.
    This gives you a good visual indication that the alarm has been triggered at some point and then reset.

    I also added the number of minutes that the siren will sound to the EEPROM stored parameters.
    It is set in the same routine that prompts for setting or changing the disarm code.
  • LA6WNALA6WNA Posts: 138
    edited 2014-05-26 13:53
    Cool project, Ron. Very nice finish at that work, Seems like the alarm system got all the features you need to be a complete system, but I miss one thing; Sabotage-switch loop.
    What if somone breaks into the control-box or cut the wire to the siren? Simply add a "normally closed"-loop all over. (an extra pair of cables) If somone cuts a wire, the alarm trigs anyway.
    Just a suggestion. You could also take the sabotage-loop from your home security system into your garage system. That will trig your home security system if anybody should try to hack your garage system.
    Keep on the good work man.:smile:
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-26 15:13
    LA6WNA wrote: »
    Cool project, Ron. Very nice finish at that work, Seems like the alarm system got all the features you need to be a complete system, but I miss one thing; Sabotage-switch loop.
    What if somone breaks into the control-box or cut the wire to the siren? Simply add a "normally closed"-loop all over. (an extra pair of cables) If somone cuts a wire, the alarm trigs anyway.
    Just a suggestion. You could also take the sabotage-loop from your home security system into your garage system. That will trig your home security system if anybody should try to hack your garage system.
    Keep on the good work man.:smile:

    Thanks! I thought about some of those more elaborate protection features but I ran most of the wires inside conduit.

    My home system has end-of-line resistors and the system monitors for the specific resistance. If a sensor circuit is either shorted or cut, the system is triggered.

    My garage was broken into many years ago but I added a 1/8th thick steel angle iron the full height of the door frame and a deadbolt that goes into the angle iron.
    The window has an infrared beam sensor and is rather high up since the yard slopes. IR sensor thread

    Actually it is probably pretty secure even without the alarm system but after one bad experience, I'd rather be safe than sorry.

    The old system was acting flaky so I decided to build my own.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-28 08:55
    Here is another video demonstrating the completed system.

  • PublisonPublison Posts: 12,366
    edited 2014-05-28 09:22
    Ron,

    Again a well though out and well implemented project worthy of a Propeller! :)

    Jim
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-29 17:30
    Publison wrote: »
    Ron,

    Again a well though out and well implemented project worthy of a Propeller! :)

    Jim

    I guess is was pretty well thought out but, like so many DIY projects, I keep thinking of enhancements.

    For example, after the alarm sounds for the specified number of minutes, I was checking to see if the door and window were closed and either rearmed the system or disarmed it.

    In the latest version, if the door or window is open after the alarm times out, I keep checking until both are closed.
    If that occurs, I rearm the system and increment a counter.
    If the system is triggered again, I check the counter and repeat the attempt to rearm unless the counter reaches a certain limit, in which case I just disarm the system.

    In case of a faulty sensor, etc it might keep my neighbors from trying to lynch me! :smile:
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-30 05:03
    Andrew (WBA Consulting) submitted my project to Hackaday and they decided to post it to their web site:

    http://hackaday.com/2014/05/30/homemade-alarm-system-doesnt-lack-features/

    Thanks Andrew!One person's comment on Hackaday implied that the circular buffer made it easy to crack the disarm code with only 10 possible sequential codes.

    Of course there are 16 keypad buttons and characters can be repeated and don't have to be sequential.

    This Combinations and Permutations calculator shows the number of possible codes to be 65536.

    It even lets you download a text file with the results.

    attachment.php?attachmentid=108917

    Code combinations.jpg
    712 x 427 - 41K
  • WBA ConsultingWBA Consulting Posts: 2,933
    edited 2014-05-30 08:55
    Congrats Ron! Glad they posted it. I saw that comment as well and my first guess was 65536 (16*16*16*16) although I was unsure if that was the proper way to mathematically figure it out. Your code did not imply a circular buffer in the way the comment was assuming, so I was glad to see your comment to clear that up.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-30 10:57
    Congrats Ron! Glad they posted it. I saw that comment as well and my first guess was 65536 (16*16*16*16) although I was unsure if that was the proper way to mathematically figure it out. Your code did not imply a circular buffer in the way the comment was assuming, so I was glad to see your comment to clear that up.

    Yeah it's always interesting to hear off the cuff comments. Rather than researching how a circular buffer works or permutations of a number set, it's easier just to naysay...
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-06-01 04:48
    The alarm system is installed and the interface to the home system (using the optisolators) works great.

    I also added another feature.
    I added two event counters (for the door and window) which can be displayed on the LCD and optionally reset to zero.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-06-01 09:12
    Great project Ron. I've been following with interest.

    I've keep intending to make a project like this. I'm going to try to get something up and running before the next time we go out of town.

    In case you or anyone else is interested in adding RFID to their systems, the MFRC522 RFID modules are surprisingly inexpensive on ebay. I've translated most of the Arduino code to Spin but I still need to finish up getting the reading and writing to the cards' EEPROM finished.

    As usual, I admire how clean you make your projects look. I find myself thinking, while cutting an opening in a project box, "try to make look as good as Ron's projects".

    Thanks for taking the time to document your efforts.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-06-01 13:50
    Duane Degn wrote: »
    Great project Ron. I've been following with interest.

    I've keep intending to make a project like this. I'm going to try to get something up and running before the next time we go out of town.

    In case you or anyone else is interested in adding RFID to their systems, the MFRC522 RFID modules are surprisingly inexpensive on ebay. I've translated most of the Arduino code to Spin but I still need to finish up getting the reading and writing to the cards' EEPROM finished.

    As usual, I admire how clean you make your projects look. I find myself thinking, while cutting an opening in a project box, "try to make look as good as Ron's projects".

    Thanks for taking the time to document your efforts.

    Thanks Duane! Since I can't afford CNC machines, laser cutters, 3D printers etc, I have to make do with Dremel tools, Xacto knives, files etc but usually get decent results.

    I went on eBay to order some more PS2501-1 optoisolators and also ordered a couple of the RFID modules you mentioned http://www.ebay.com/itm/400426561641 since he sold them as well.

    I'll check out your latest code after I get them.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-06-04 09:47
    I wanted some warning device in the house in case the garage alarm goes off and I don't hear the siren.

    So I made a little PCB board with a PS2501 optisolator, a RadioShack pulsing piezo buzzer, 3 AAA bats, test switch and telephone jack.

    I connected 2 wires in the buried cable between the house and garage to the unused black/yellow telephone system jacks.

    The circuit draws no current unless the optoisolator LED receives current from the alarm system and I can plug it in any phone jack. The optoisolator can directly power the piezo buzzer.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-06-15 16:15
    I am still tweaking my alarm system - both hardware and software.

    I replaced the battery maintainer unit with a PB137 "Positive voltage regulator for battery charger". It keeps the battery at around 13.6V.

    I also added a MCP3002 10 bit ADC and a voltage divider (10K, 3k) to monitor the battery voltage and alert me if it drops too low.
    Still modifying the program for this so I can set the threshold voltage using the keypad and save to the EEprom.

    There is a separate cog monitoring the voltage. It checks the ADC value every 5 seconds and takes an average of six values which is compared to a threshold value of 875.
    If that average voltage is below the threshold, the piezo buzzer will beep every 30 seconds unless the average voltage recovers.

    I also modified the LCD menu to allow me to put the system into a TEST MODE. This reduces the prescribed siren timeout to 30 seconds and beeps the piezo rather than the siren.
    This lets me test sensors, etc without disturbing neighbors and eliminates my waiting for the long timeout.

    I've just about got it the way I want it now. (Good thing since I'm running out of real estate...)

    It is really neat to be able to customize it and add features!

    attachment.php?attachmentid=109168

    Parts layout2.jpg
    1024 x 768 - 134K
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2018-04-25 14:41
    ***deleted**


Sign In or Register to comment.