Shop OBEX P1 Docs P2 Docs Learn Events
Help reading keypad -- It's working,, no idea why. — Parallax Forums

Help reading keypad -- It's working,, no idea why.

mosquito56mosquito56 Posts: 387
edited 2009-05-13 21:05 in Propeller 1
· I bought a 4x4 keypad with serial output. It rides high and goes low with keypress. Unfortunately the only thing I know is that it is serial output at 9600baud.

simple serial has a way to setup for serial input. Heres what I have, any help is apreciated

pub start
· pin:=28
· outa[noparse][[/noparse]pin]~··· 'set pin to input
· start(-1, pin , 9600) also tried·· start(pin, -1, 9600)
· read
pub read
·repeat
··· info:=simple.rx···· 'since the simple has no recieve buffer, just print whatever is recieved.
··· debug.dec(info)

I have connected the keypad to the tx line on pin 30 or 31 with propterminal in echo and the keypad works.

How do I read the keypad. Any ideas ok. Don't need or want simple serial object. Thanks Much for all your help
Don

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·······

······· "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet


Post Edited (mosquito56) : 5/13/2009 9:25:47 PM GMT

Comments

  • James LongJames Long Posts: 1,181
    edited 2009-05-12 16:49
    mosquito56 said...
    I bought a 4x4 keypad with serial output. It rides high and goes low with keypress. Unfortunately the only thing I know is that it is serial output at 9600baud.


    simple serial has a way to setup for serial input. Heres what I have, any help is apreciated



    pub start

    pin:=28

    outa[noparse][[/noparse]pin]~ 'set pin to input

    start(-1, pin , 9600) also tried start(pin, -1, 9600)

    read

    pub read

    repeat

    info:=simple.rx 'since the simple has no recieve buffer, just print whatever is recieved.

    debug.dec(info)



    I have connected the keypad to the tx line on pin 30 or 31 with propterminal in echo and the keypad works.



    How do I read the keypad. Any ideas ok. Don't need or want simple serial object. Thanks Much for all your help

    Don

    Don,

    Your second iteration
    start(pin, -1, 9600)
    
    



    Would never work. You are disabling the receive pin.

    start(-1, pin , 9600)
    
    


    is only using the receive pin to get the information.

    You may also need to try the following:

    start(-1,pin,-9600)  <--- inverted baud
    
    



    Also make sure you are setting the freq of the Propeller to 80 Mhz. The simple serial is designed for the propeller to be running at 80 Mhz.

    I think you are on the right track. The keypad may need to be polled, but it is an unknown. Without some kind of data sheet you must hope the system just sends out values without some kind of interrogation.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer

    Lil Brother SMT Assembly Services
  • parts-man73parts-man73 Posts: 830
    edited 2009-05-12 17:25
    well.....I can say, he doesn't have a datasheet. This is a uController product.

    This is a 4x4 keypad with a serial backpack. It outputs an ascii value for the key that is pressed, at 9600 baud.

    The receive pin will have to monitored, or a serial object with a receive buffer be used, as the serial data is sent out right when the key is pressed, it doesn't wait for the receiver to be ready for it.

    At the time of release, I had never made documentation for it, thinking it was pretty self-explanatory. I had put it together to use for one of my own projects, as I didn't want to waste 8 Propeller pins to interface a keypad. Now upon reflection, I should write up some documentation with some code examples.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian

    uController.com - home of SpinStudio - the modular Development system for the Propeller

    PropNIC - Add ethernet ability to your Propeller! PropJoy - Plug in a joystick and play some games!

    SD card Adapter - mass storage for the masses Audio/Video adapter add composite video and sound to your Proto Board
  • James LongJames Long Posts: 1,181
    edited 2009-05-12 17:40
    parts-man73 said...
    well.....I can say, he doesn't have a datasheet. This is a uController product.

    This is a 4x4 keypad with a serial backpack. It outputs an ascii value for the key that is pressed, at 9600 baud.

    The receive pin will have to monitored, or a serial object with a receive buffer be used, as the serial data is sent out right when the key is pressed, it doesn't wait for the receiver to be ready for it.

    At the time of release, I had never made documentation for it, thinking it was pretty self-explanatory. I had put it together to use for one of my own projects, as I didn't want to waste 8 Propeller pins to interface a keypad. Now upon reflection, I should write up some documentation with some code examples.

    Well, that explains it.

    Pretty cool part, even though I do not have any current use for it.

    You do have a lot of other products that look real cool.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer

    Lil Brother SMT Assembly Services
  • mosquito56mosquito56 Posts: 387
    edited 2009-05-12 17:58
    Will wait for your code examples parts-man.



    I have attached the modified simple serial. But simple serial says "wait for start bit". Since there is no start bit, hmmm.

    ·I put in a "repeat while ina[noparse][[/noparse]pin]==1 since the voltage is high until u press a key. This is similiar to the adc code that waits until the sars pin goes high or low depending on lsb or msb. ·No luck.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
  • parts-man73parts-man73 Posts: 830
    edited 2009-05-13 04:00
    This little blurb of code will echo any keys pressed to pin 30, and thus if connected via PropPlug to a PC will relay the keys pressed to PST or any other serial terminal program.

    OBJ
    
      Term : "FullDuplexSerial"
      
    PUB Main
    
      Term.Start(0,30,0,9600)
      repeat                                   
          i:=Term.rx
          Term.tx(i)
    



    so simply "i := Term.rx" will get a value from the keypad. There is no need to use "repeat while ina[noparse][[/noparse]pin]==1" the rx command will pause the running cog until a key is pressed. Code that may be running in other cogs of course will not be affected.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian

    uController.com - home of SpinStudio - the modular Development system for the Propeller

    PropNIC - Add ethernet ability to your Propeller! PropJoy - Plug in a joystick and play some games!

    SD card Adapter - mass storage for the masses Audio/Video adapter add composite video and sound to your Proto Board
  • mosquito56mosquito56 Posts: 387
    edited 2009-05-13 05:18
    Sorry, I don't see how this would be different from just turning on the echo and connecting the keypad to pin 30.··

    I need something that reads the keypad directly on another pin as my project uses t.v.






    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • James LongJames Long Posts: 1,181
    edited 2009-05-13 06:23
    mosquito56 said...
    Sorry, I don't see how this would be different from just turning on the echo and connecting the keypad to pin 30.

    I need something that reads the keypad directly on another pin as my project uses t.v.

    Mosquito,

    I'm not sure I understand the problem.

    If you need to connect to a different pin, just change the following:

    OBJ
    
      Term : "FullDuplexSerial"
      
    PUB Main
    
      Term.Start(0,30,0,9600)  <-------change 30 to whatever pin you need it to be
      repeat                                   
          i:=Term.rx
          Term.tx(i)
    
    



    Now if you need to code to display this on a TV, that is a different beast all together.

    You would need to include a TV object in the "OBJ" section and use it alias to output the received information out to the TV.

    If you could clarify, we could help better.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer

    Lil Brother SMT Assembly Services
  • mosquito56mosquito56 Posts: 387
    edited 2009-05-13 06:26
    Aside from the fact that it doesn't work?

    When you connect the keypad to pin 30, the propterminal is reading the input and echoing it back. This is the code I first tried. Maybe I fried the keypad.

    Checked keypad it works.




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet


    Post Edited (mosquito56) : 5/13/2009 6:39:40 AM GMT
  • James LongJames Long Posts: 1,181
    edited 2009-05-13 07:41
    mosquito56 said...
    Aside from the fact that it doesn't work?

    When you connect the keypad to pin 30, the propterminal is reading the input and echoing it back. This is the code I first tried. Maybe I fried the keypad.

    Checked keypad it works.

    So as I read this, you have tried the keypad and it works. If you think the computer is reading the key pad (instead of the propeller), change 30 to a pin you have available, and try the keypad on that pin.

    If that works, we can continue with a TV object which will display the data.

    I figure from your edited post, you have checked the pad, and it is functioning.

    Let us know if additional assistance is needed to display the information on a TV.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer

    Lil Brother SMT Assembly Services
  • mosquito56mosquito56 Posts: 387
    edited 2009-05-13 09:32
    It worked with propterminal, switch pin, doesn't work. I have been using t.v. for about a year now but that's another story.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • parts-man73parts-man73 Posts: 830
    edited 2009-05-13 12:38
    " i := Term.rx" puts the key pressed into variable i

    now you can do what you need to with it. In my short program, I chose to output the value on pin 30. You could use a "case" statement and/or "if" statements to make your program do something when certain keys are pressed, just remember, the codes received from the keypad are ascii codes. The ascii codes for 0..9 is 48..57, A..D is 65..68, # is 35 and * is 42

    You can convert the keypress to a number if it makes easier to read code - if the ascii code is GREATER THAN 47 AND LESS THAN 58 than subtract 48 and you get the actual value of the key if it's a number

    If you have a specific idea you'd like you implement, I could give you ideas on how to accomplish them.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian

    uController.com - home of SpinStudio - the modular Development system for the Propeller

    PropNIC - Add ethernet ability to your Propeller! PropJoy - Plug in a joystick and play some games!

    SD card Adapter - mass storage for the masses Audio/Video adapter add composite video and sound to your Proto Board
  • James LongJames Long Posts: 1,181
    edited 2009-05-13 16:16
    mosquito56 said...
    It worked with propterminal, switch pin, doesn't work. I have been using t.v. for about a year now but that's another story.

    Now that is interesting.

    I have two questions. First what board are you using with the propeller? (Demo Board, etc)?

    Is there a pull up resistor on pin 30 of your board?

    It is really strange that the keypad works on one pin, but doesn't on another. There must be something different about the other pin. Can you try several different pins?

    Not saying you have a bad I/O, but something strange is going on.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer

    Lil Brother SMT Assembly Services
  • mosquito56mosquito56 Posts: 387
    edited 2009-05-13 20:43
    Absouletley agree with both of you, extremely weird situation going on here.

    i :=term.rx should work . That's why I put the repeat while ina[noparse][[/noparse]26]==1 statement in. To see if it would jump past that point until the pin went low. Kind of like a breakpoint. The program should hang there until a key is pressed. No luck.

    · Since I am using the sd card and reading one character at a time for settings, I really think I can use the info effectively once I get it into a variable. I am very familiar with ascii codes and the i-48 for decoding.

    I am using the education kit at this time for about a year now. I connected an led to the pin to see if I fried that pin and it works fine. Is it possible to fry the input of a pin and not the output?

    This problem makes no sense whatsoever, the i:=rx should be working.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • mosquito56mosquito56 Posts: 387
    edited 2009-05-13 21:00
    No idea how but it's working now. Inclosed find program. Works on pin 27 which·can be changed in const section.

    Thanks for the help guys.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet


    Post Edited (mosquito56) : 5/13/2009 9:09:08 PM GMT
  • James LongJames Long Posts: 1,181
    edited 2009-05-13 21:05
    mosquito56 said...
    Absouletley agree with both of you, extremely weird situation going on here.

    i :=term.rx should work . That's why I put the repeat while ina[noparse][[/noparse]26]==1 statement in. To see if it would jump past that point until the pin went low. Kind of like a breakpoint. The program should hang there until a key is pressed. No luck.

    Since I am using the sd card and reading one character at a time for settings, I really think I can use the info effectively once I get it into a variable. I am very familiar with ascii codes and the i-48 for decoding.

    I am using the education kit at this time for about a year now. I connected an led to the pin to see if I fried that pin and it works fine. Is it possible to fry the input of a pin and not the output?

    This problem makes no sense whatsoever, the i:=rx should be working.

    I don't understand why this would happen. If you are only changing the pin number in the program to match your hardware, it should work.

    No, usually you fry the output first.

    Not sure how to help further without looking at the code and hardware.

    Edit: Glad you got it working. Not sure if we helped, but we did try.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer

    Lil Brother SMT Assembly Services

    Post Edited (James Long) : 5/13/2009 9:12:15 PM GMT
Sign In or Register to comment.