Shop OBEX P1 Docs P2 Docs Learn Events
Disabling Alarm system with Hex Keypad — Parallax Forums

Disabling Alarm system with Hex Keypad

Hello,

I am trying to figure out a way to disable an alarm system using a Hex (4x4) keypad. I am using two micro-controllers; one for the alarm itself, and a second one for the keypad. For the second micro-controller, i am looking for a code that will be able to not only disable the alarm using a set code, but also reset the entire system. The code used for this will be simply; "1, 2, 3, A"

Thank you
«1

Comments

  • kwinnkwinn Posts: 8,697
    Need a bit more info. Schematics or alarm model info would help. How is the alarm system reset now?
  • PublisonPublison Posts: 12,366
    edited 2017-09-11 13:31
    Welcome to the forums!

    It will be very hard to answer your question with the limited amount of information supplied.

    Which microcontroller(s) are you using? The code that yuo are using currentley would be helpful.
  • TJRyanTJRyan Posts: 18
    edited 2017-09-11 13:39
    I dont have any sample code/model so far. This is for a project and i need to figure it out before i actually do it. Would a step by step process of how the alarm works be more helpful? and I am using the Parallax Board of Education
  • kwinnkwinn Posts: 8,697
    Posting the step by step would be helpful as would an overview of the alarm functions. Also, are you using the Propeller Board of Education or the Basic Stamp Board of Education?
  • Basic Stamp. And by step by step, do you mean a generic list of how it is supposed to work?
  • kwinnkwinn Posts: 8,697
    TJRyan wrote: »
    Basic Stamp. And by step by step, do you mean a generic list of how it is supposed to work?

    I mean like the sample below.

    The system monitors:
    6 switch contacts on windows and doors.
    3 motion sensors on the main floor
    1 signal from the fire alarm system
    1 panic switch

    The system ccontacts:
    Monitoring company if switches or motion sensors are active
    Monitoring company and fire department if fire alarm is active
    Monitoring company and Police if panic switch is activated
  • alright. so its just like a small alarm that is only for detecting things right in front of it.

    It has:
    1 IR sensor
    1 Piezo buzzer
    2 Basic Stamp Board of Education micro-controllers
    1 Hex Keypad

    It is armed with an IR Beam that hits an IR sensor
    Once the beam is broken and the Sensor stops sensing IR light, the alarm (which is a simple piezo buzzer) will begin to sound at a set interval.
    Once the buzzer goes off, the second microcontroller will activate
    Once it is active, the proper keypad input must be put in (This input will be simply, 1,2,3,A-top left to top right)
    Once the code is properly sequenced, the ENTIRE system (both micro-controllers) will deactivate and will bring it back to the first micro-controllers first line of code (which simply looks for IR light at the sensor)

    I know how to write the code for the first micro-controller, what i dont know how to do is sequence the keypads inputs, and also how to reset the system once the proper sequence is put in
  • kwinnkwinn Posts: 8,697
    Is this the Parallax 27899-4x4-Matrix-Membrane-Keypad?
  • That is the plan, yes
  • kwinnkwinn Posts: 8,697
    edited 2017-09-12 14:18
    TJRyan wrote: »
    That is the plan, yes

    OK, then you can download the sample programs for the keypad as a starting point. The simplest interface between the two micros would be to use two pins on each.

    Alarm micro...............Keypad micro
    alarm_out->>>>>>alarm_in
    valid_code_in<<<<-valid_code_out

    When the alarm_out is high the keypad micro reads 4 digits from the keypad and if they are the correct code outputs a high on the valid_code_out pin. The alarm micro turns off the alarm when it receives that high.
  • so alarm_out, alarm_in, valid_code_in, and valid_code_out are all pins?

    and is this how i would write the code in the Basic Stamp Editor?

  • Also, where would i go to download some sample code?
  • kwinnkwinn Posts: 8,697
    Yes, all four are pins on the two micros, one input and one output on each micro.

    You can find the keypad code here.

    For safety you should put resistors between the pins rather than connecting them directly. 1K would be good. Same goes for the keypad. Page 3 of the keypad manual shows where they go. They prevent damage to the pins in case of a bug in the program.
  • TJRyanTJRyan Posts: 18
    edited 2017-09-12 15:20
    Awesome. Thank you, I'll take a look at the sample program.
  • The keypad code in the product page isn't reliable; you get false reads. Here is a link to a discussion I started some time ago. It points, in turn, to an old discussion that explains the problem.
  • TJRyanTJRyan Posts: 18
    edited 2017-09-13 12:12
    The keypad code in the product page isn't reliable; you get false reads. Here is a link to a discussion I started some time ago. It points, in turn, to an old discussion that explains the problem.

    So if I understand this correctly, I need to add in 10k pulldown resistors to the first four input pins?

  • kwinnkwinn Posts: 8,697
    edited 2017-09-13 13:45
    TJRyan wrote: »
    The keypad code in the product page isn't reliable; you get false reads. Here is a link to a discussion I started some time ago. It points, in turn, to an old discussion that explains the problem.

    So if I understand this correctly, I need to add in 10k pulldown resistors to the first four input pins?

    There are two concerns with this keypad if used directly.

    The first is possible damage to the I/O pins if a button is pressed and the code has the two pins connected to that button set to outputs with one pin high and the other low. Very easy to do when debugging code. Even if the code is perfect a short between pins can happen if two buttons are pressed at the same time. Series resistors between the pins and the keypad will prevent that.

    The second is floating input pins. This can lead to false readings. Since a button is connected between one row and one column only one input is connected to an output so three of the inputs are floating. Pull down or pull up resistors can solve that.
  • TJRyanTJRyan Posts: 18
    edited 2017-09-13 14:57
    kwinn wrote: »
    TJRyan wrote: »
    The keypad code in the product page isn't reliable; you get false reads. Here is a link to a discussion I started some time ago. It points, in turn, to an old discussion that explains the problem.

    So if I understand this correctly, I need to add in 10k pulldown resistors to the first four input pins?

    There are two concerns with this keypad if used directly.

    The first is possible damage to the I/O pins if a button is pressed and the code has the two pins connected to that button set to outputs with one pin high and the other low. Very easy to do when debugging code. Even if the code is perfect a short between pins can happen if two buttons are pressed at the same time. Series resistors between the pins and the keypad will prevent that.

    The second is floating input pins. This can lead to false readings. Since a button is connected between one row and one column only one input is connected to an output so three of the inputs are floating. Pull down or pull up resistors can solve that.

    So i would already be adding resistors to the connections between the pins and Keypad. Do i have to add 1K resistors to every single one of the pin connections? Or just to the ones shown on the data sheet? Also, would i now just have to add 10K resistors to each keypad connection and use them to connect to either ground or power?

  • kwinnkwinn Posts: 8,697
    edited 2017-09-14 00:03
    FYI, I don't have a Parallax 27899-4x4-Matrix-Membrane-Keypad. I have an old push button keypad that I have wired up for prototyping. Circuit wise it is identical to the Parallax keypad, including the wire numbering. It is wired as shown in the attached schematic.

  • kwinnkwinn Posts: 8,697
    One mistake on the schematic. The resistor network marked "4 X 1K" should be marked 4 X 10K. Can't believe I missed that when I was editing it to match the Parallax key symbols.
  • kwinnkwinn Posts: 8,697
    Corrected schematic attached.

    688 x 579 - 13K
  • kwinn wrote: »
    Corrected schematic attached.

    So, all of the wires are connected using 120 ohms, and connection 1 also has a 10k connection to ground?
  • Update also, as it turns out i will not be using the actual board of education, just the micro controller. i will be making all connections with a circuit board. will this affect how i hook up the keypad?
  • kwinnkwinn Posts: 8,697
    TJRyan wrote: »
    kwinn wrote: »
    Corrected schematic attached.

    So, all of the wires are connected using 120 ohms, and connection 1 also has a 10k connection to ground?

    All the wires have 120 ohms, but there are 4 wires ( 1, 2, 3, 4 ) with 10K resistors to ground.
  • kwinnkwinn Posts: 8,697
    TJRyan wrote: »
    Update also, as it turns out i will not be using the actual board of education, just the micro controller. i will be making all connections with a circuit board. will this affect how i hook up the keypad?

    Nope, it should connect to the same I/O port pins on the microcontroller.
  • Alright, I got it. What parts of the keypad code would i need for reading the proper sequence? Also, would i need IF-THEN statements for reading each input
    i.e.

    IF
    Keypad1 HIGH
    THEN (whatever would be done to move the sequence)
  • kwinnkwinn Posts: 8,697
    TJRyan wrote: »
    Alright, I got it. What parts of the keypad code would i need for reading the proper sequence? Also, would i need IF-THEN statements for reading each input
    i.e.

    IF
    Keypad1 HIGH
    THEN (whatever would be done to move the sequence)

    The is example code for reading the keypad is in the "4x4MatrixKeypad_Demo.bs2" file, although that is not necessarily the best way to do it for your use.

    If you are using a BS2 microcontroller you can use a FOR loop and a SELECT CASE statement to decode the keypresses, if you are using a BS1 there is no SELECT CASE so you would need IF THEN or some other way of decoding it. Do you need the decoded value to match the number/character on the keypad button?
  • kwinn wrote: »
    TJRyan wrote: »
    Alright, I got it. What parts of the keypad code would i need for reading the proper sequence? Also, would i need IF-THEN statements for reading each input
    i.e.

    IF
    Keypad1 HIGH
    THEN (whatever would be done to move the sequence)

    The is example code for reading the keypad is in the "4x4MatrixKeypad_Demo.bs2" file, although that is not necessarily the best way to do it for your use.

    If you are using a BS2 microcontroller you can use a FOR loop and a SELECT CASE statement to decode the keypresses, if you are using a BS1 there is no SELECT CASE so you would need IF THEN or some other way of decoding it. Do you need the decoded value to match the number/character on the keypad button?

    Yes, i need it to be able to read the inputs so when the correct buttons are pressed, the valid_code_out pin goes HIGH, resetting the whole system
  • kwinnkwinn Posts: 8,697
    What model of Basic Stamp are you using?
  • kwinn wrote: »
    What model of Basic Stamp are you using?

    BS2
Sign In or Register to comment.