Help reading keypad -- It's working,, no idea why.
mosquito56
Posts: 387
· 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
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
Don,
Your second iteration
Would never work. You are disabling the receive pin.
is only using the receive pin to get the information.
You may also need to try the following:
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
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
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
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
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
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
········
Mosquito,
I'm not sure I understand the problem.
If you need to connect to a different pin, just change the following:
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
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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·······
······· "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········
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
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
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
········
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
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