+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 20 of 23

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

  1. #1

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

    Project was posted on Hackday on May 30 - http://hackaday.com/2014/05/30/homem...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:
    Code:
    This object uses the Interrupt-On-Change feature of the Microchip MCP23008 I/O Expander chip to interface a 4x4 Matrix Keypad (Parallax #27899) to a propeller MCU.See Microchip's Application Note AN1081 at http://ww1.microchip.com/downloads/en/AppNotes/01081a.pdf
    When a key on the keypad is pressed, the MCP23008 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.
    
    
    
                 ┌───┐   ┌───┐   ┌───┐   ┌───┐
            ┌────┫ 1 ┣───┫ 2 ┣───┫ 3 ┣───┫ A │
            │    └─┳─┘   └─┳─┘   └─┳─┘   └─┳─┘
            │    ┌─┻─┐   ┌─┻─┐   ┌─┻─┐   ┌─┻─┐  K
            │ ┌──┫ 4 ┣───┫ 5 ┣───┫ 6 ┣───┫ B │  E
            │ │  └─┳─┘   └─┳─┘   └─┳─┘   └─┳─┘  Y
            │ │  ┌─┻─┐   ┌─┻─┐   ┌─┻─┐   ┌─┻─┐  P
            │ │ ┌┫ 7 ┣───┫ 8 ┣───┫ 9 ┣───┫ C │  A
            │ │ │└─┬─┘   └─┬─┘   └─┬─┘   └─┬─┘  D
            │ │ │┌─┻─┐   ┌─┻─┐   ┌─┻─┐   ┌─┻─┐
            │ │ ││ * ┣───┫ 0 ┣─┳─┫ # ┣───┫ D │
            │ │ │└─┳─┘   └─┳─┘ │ └─┳─┘   └─┳─┘
            │ │ │  │       │   │   └─┐ ┌───┘
            │ │ │  │       └───┼───┐ │ │
            │ │ │  └───────────┼─┐ │ │ │
            │ │ └────────────┐ │ │ │ │ │
            │ └────────────┐ │ │ │ │ │ │
            └────────────┐ │ │ │ │ │ │ │
                         8 7 6 5 4 3 2 1
                ┌──────┫ │ │ │ │ │ │ │
                ┣──────┼─┫ │ │ │ │ │ │    
            10k ┣──────┼─┼─┫ │ │ │ │ │
                ┣──────┼─┼─┼─┫ │ │ │ │   
          VDD ──┻──────┐ │ │ │ │ │ │ │ │    
                     ┌─┴─┴─┴─┴─┴─┴─┴─┴─┴─┐   <─ GP7 thru GP0 (GP7 thru GP4 are pulled high to 3.3V with 10K resistors)
                     │                   │
                     │                   │
                     │    MCP23008      │
                     │                   │
                     │                   │
                     └─┬─┬─┬─┬─┬─┬─┬─┬─┬─┘
                       S S A A A R   I │
                       C D 2 1 0 E   N │
                       L A │ │ │ S   T │
                       │ │ └─┻─┻─┼───┼─┫
                       │ │       │   │ └────VSS
                       │ │       └───┼──────VDD
         Propeller     2 2           0
            Pins       8 9
    Last edited by Ron Czapala; 05-30-2014 at 11:03 PM.

  2. #2

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    Pretty neat Ron!

    Jim
    Infernal Machine

  3. #3

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    Quote Originally Posted by Publison View Post
    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.
    Last edited by Ron Czapala; 05-13-2014 at 02:02 AM.

  4. #4

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    Well done!! Great project and very well documented.

    This will go on my never ending list of things to build!
    MOV OUTA, PEACE

    ... Rick


    I've stopped using programming languages with Garbage Collection, they keep deleting my source code!!

    "Forth is FUN!"

    Introduction to TACHYON Forth


    PropFORTH Wiki

  5. #5

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    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.
    Last edited by Ron Czapala; 05-13-2014 at 12:35 PM.

  6. #6

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    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.




    Click image for larger version

Name:	Alarm panel.jpg
Views:	1663
Size:	87.9 KB
ID:	108807

  7. #7

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    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






    Click image for larger version

Name:	AlarmPanel.jpg
Views:	1604
Size:	89.3 KB
ID:	108877Click image for larger version

Name:	System parts.jpg
Views:	1609
Size:	158.1 KB
ID:	108886
    Last edited by Ron Czapala; 05-27-2014 at 08:09 PM.

  8. #8

    WBA Consulting's Avatar
    Location
    4.3 Light Years from Rigil Kentaurus
    Posts
    2,139
    Blog Entries
    26

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    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!
    Andrew Williams
    WBA Consulting

  9. #9

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    Quote Originally Posted by WBA Consulting View Post
    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.
    Last edited by Ron Czapala; 05-27-2014 at 02:29 AM.

  10. #10

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    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.
    Peter

  11. #11

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    Quote Originally Posted by LA6WNA View Post
    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.
    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.
    Last edited by Ron Czapala; 05-26-2014 at 10:38 PM.

  12. #12

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    Here is another video demonstrating the completed system.



  13. #13

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    Ron,

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

    Jim
    Infernal Machine

  14. #14

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    Quote Originally Posted by Publison View Post
    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!

  15. #15

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    Andrew (WBA Consulting) submitted my project to Hackaday and they decided to post it to their web site:

    http://hackaday.com/2014/05/30/homem...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.



    Click image for larger version

Name:	Code combinations.jpg
Views:	1224
Size:	40.7 KB
ID:	108917
    Last edited by Ron Czapala; 05-30-2014 at 01:09 PM.

  16. #16

    WBA Consulting's Avatar
    Location
    4.3 Light Years from Rigil Kentaurus
    Posts
    2,139
    Blog Entries
    26

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    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.
    Andrew Williams
    WBA Consulting

  17. #17

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    Quote Originally Posted by WBA Consulting View Post
    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...

  18. #18

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    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.

  19. #19

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    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.

  20. #20

    Default Re: Alarm System video - Propeller, keypad (w/MCP23008), LCD

    Quote Originally Posted by Duane Degn View Post
    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.
    Last edited by Ron Czapala; 06-02-2014 at 01:40 AM.

+ Reply to Thread

Similar Threads

  1. MCP23008 vs PCF8574 as 4x4 Keypad interface - interrupts
    By Ron Czapala in forum General Discussion
    Replies: 7
    Last Post: 04-23-2014, 09:18 PM
  2. MCP23008 Keypad Interrupt-On-Change demo
    By Ron Czapala in forum Propeller 1 Multicore Microcontroller
    Replies: 3
    Last Post: 04-23-2014, 08:19 PM
  3. Replies: 4
    Last Post: 01-29-2012, 03:35 PM
  4. Cheap Keypad for alarm system w/LEDs
    By kf4ixm in forum General Discussion
    Replies: 0
    Last Post: 09-25-2010, 01:58 PM
  5. Project: Propeller-powered video alarm clock
    By Andrey Demenev in forum Propeller 1 Multicore Microcontroller
    Replies: 5
    Last Post: 09-20-2010, 03:03 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts