Snippet needed for Prop and the MM74C922 keypad encoder
idbruce
Posts: 6,197
Hello Everyone
I need a snippet of code to interface the MM74C922 keypad encoder with the Propeller chip, or at least a little discussion about implementation.
As I understand it, the Data Available pin goes high when data is available. From there I am assuming that when a key is pressed, pins A, B, C, and D go high or low dependant upon which key is pressed and coinciding with the truth table in the data sheet. Providing that I am correct in my assumptions, how do you let the chip know that you have acquired the data and to reset.
As always, I have so kindly provided the datasheet for your viewing pleasure
Bruce
I need a snippet of code to interface the MM74C922 keypad encoder with the Propeller chip, or at least a little discussion about implementation.
As I understand it, the Data Available pin goes high when data is available. From there I am assuming that when a key is pressed, pins A, B, C, and D go high or low dependant upon which key is pressed and coinciding with the truth table in the data sheet. Providing that I am correct in my assumptions, how do you let the chip know that you have acquired the data and to reset.
As always, I have so kindly provided the datasheet for your viewing pleasure
Bruce
Comments
A snippet of code... how about.... one waitpeq, one out and one in ?... I'm sure you can do it yourself
have fun
Merry Christmas!
Thanks Jon -> Now that's a lot better. I have saved your snippet for future use and reference, however, by the time that I got your post, I had already created another snippet of my own. I am sure that I will use both yours and mine, because I have a very difficult user inteface to code. Each button will be able to perfom several different functions, being dependant upon which point in the program that the button is pressed. I like both of our snippets, because yours is free wheelin' and mine is confined within a cog. Thanks again Jon.
I have posted my snippet to the object exchange and attached it here for everyones viewing pleasure.
OBEX Link http://obex.parallax.com/objects/694/
Merry Christmas To All
Bruce
Edit: I found an error in the start() method and have corrected it (this is the problem with not having hardware to test with). Since I was getting creative, I added a couple more methods that I think may be useful and updated the demo program for the MM74C922 object. My apologies that to those that tried to use the version I posted yesterday -- it was Christmas and I was, perhaps, over-joyful!
Edit: I believe I found the error that was giving Bruce troubles; new version posted below.
Bruce
Well that was interesting, I learned something valuable from testing your code. After testing it, I had to update my code in OBEX.
Here is what I learned. I was outputting decimal to the serial terminal and you were outputting hex. You probably already know the difference in the output, but I will share it anyway just so that others may learn from it. Here are the results:
Hex Results: 0-9 + A-F
I would suggest inserting waitpeq and waitpne into your code like I did, because in your code the result is repeated while the button is held down. Since the data is latched, there should only be one character instead of a repeat. Besides that it works perfectly. Not bad for not having a chip at your disposal. Nice work!
Bruce
Updated file is posted above.
Now you got me wondering which one I tested. I thought I tested them both.
Okay, here is the situation now.
-- buffer empty
-- buffer empty
-- buffer empty
-- buffer empty
-- buffer empty
I don't understand your code completely, but at a glance it appears that you are writing this code for the 74C923, instead of the 74C922.
Bruce
Thanks for giving it a try.
Yea Jon I realize it is a matter of just removing one pin. Anyhow I like the fact that it can get data from the 74C922, as well as the 74C923, because it will give the end user more options. I was just thinking that your code should be more aptly named jm_mm74C922_or_mm74C923_test. May I suggest just adding a parameter to your start method which would specify which chip is being used, and then use a couple conditions to set your key mask.
You are welcome Jon. I am sure it will be a nice object once you get the chip and can test more easily.
Bruce
I am currently implementing to interface a 74C923 to the Propeller via a I2C interface chip!
In the mean time I have linked the 74C923 to a Basic Stamp (for testing purposes of the hardware). I currently have the OE (Output Enable) pin pulled high. My simple little program checks the DA pin and if high then pulls the OE pin low and then reads the data. This resets the DA pin (according to the data sheet -- and it works in my example).
My program then waits until the DA pin goes low and then loops back to wait for the DA pin to go high again. I found that this stops multiple keystrokes from holding a key down but will output the multiple keys if pressed after each other including the same key.
As for the truth table I ended up just outputting the binary codes until I set up my own truth table via a PBasic Lookup command.
At the moment I have a 4x4 keypad, but will be adding an extra row of pushbuttons for "command keys". One of these will debounce directly to a Propeller pin (like a ESC or Break key) to alert the Prop that the user wants to input via the keypad.
Regards,
More particularly, I was wondering if you had the chance to experiment with the debounce and scanning capacitors. There are times when an intended single button press acts like multiple button presses and bypasses sections of code because they both require the same button press for user input (e.g. - Yes or No).
I initially used 0.1uF capacitors for both debouncing and scanning, but then increased both of these to a larger value of 1uF in an attempt to eliminate the problem, but it still bypasses the same sections of code. Since I am able to read the button presses, I assume this is more an issue of scanning than of contact bounce. I am considering another increase in value of the scanning capacitor, perhaps 10 or 20uF.
Would you have any input on this issue?
With a value of 10uF, the scan rate should be approximately 10kHz, as compared to the approximate 70Hz that it is now.
Bruce
EDIT: Perhaps changing the existing code would help.
FROM:
TO:
Sorry, I thought you may have ordered it, because it seems like it would have fit into some of your projects. It is a nice chip if I can get it to work right. I think my suggested code change might work out well.
Bruce
Just in case you do use that chip in the future, the following code change resolved my problem. This change reduced capable key press speed, but it appears to be very reliable. Additionally, as previously mentioned, I am using 1uF for both the debounce and scanning capacitors.
FROM:
TO:
Bruce
Here is another modification that allows faster key press processing and appears to be just as reliable.
Bruce
Bruce