I am implementing a 6x6 matrix keypad scanner in CPLD. My requirment is i should detect multiple key presses also. What i am planning to do is , i will scan the rows (6 of them sequentially) , when all the 6 rows are scanned i will send the 36 bit output(each bit corresponds to each individual key .'0' indicates pressed)to the controller.The scan rate for each row is approximately
32 msec , so every 32x6=192 msec i will be sending the 36 bit code to controller(HCS12).
I want your comments on this implementation in CPLD.
Or four keys pressed along a diagonal. How does the chip determine which keys are pressed? Without diodes, it appears 16 are pressed.
With diode isolation, if the OP wants it to work!
The homework question is good, this (even with N-key rollover, or a bitmap of all keys pressed, generated fast enough, every 10 mS or so) is more easily done with a microcontroller with appropriate I/O, eliminating the CPLD. Some chips like the Motorola (er, Freescale) have input ports configurable so that any of the 8 lines going low can cause a processor-wakeup interrupt, giving very low overall power consumtion. Doing key scanning in a CPLD seems like a design exercise rather than a practical application.
Well, it might vary depending on how the output port feels about having shorted output, but let's assume, both for the simplest explanation and to prevent hardware damage, that the outputs going to the key matrix are open-collector (or thesedays, open-drain), meaning when the processor sets the output state high it can 'float' high or low, but wnen it's low it's pulled low. Suppose you have a 4x4 key matrix, and the four horizontal lines are driven by open-collector outputs, and pulled high by resistors. The vertical lines go to microcontroller port inputs. Now that I think about it, I posted too soon...the matrix would sense diagonally-pressed buttons just fine. I was imagining something that would short out the whole matrix, and that won't do it.
Quoting the first response
Here, if you press any three keys forming three corners of a rectangle (without diodes), the processor will also "see" the fourth corner pressed, as the wires to it will have an electical connection through the other three switches. This is the sort of problem I was thinking of.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.