1
\$\begingroup\$

I am (as a hobby) looking into making a keypad with independently scanned keys. I am going with a row-column matrix approach (due to limited GPIO). And would like to utilize MCUs low power modes. Now to achieve both criteria I need to keep rows low unless I detect a button press, which I can do with a wakeup pin on MCU.

However, my layman knowledge of circuits only comes up with a head-on solution by using mosfets like below (it is overly simplified, but I hope delivers the point):

enter image description here

Now, this will be awful lot of mosfets for any reasonable number of keys (think a 104-keyboard). While sure this solution would work, I can't help but ask whether there is a better solution to this problem (preferably using only simple electrical components since 1 MCU is already enough to blow my brain).

\$\endgroup\$
4
  • \$\begingroup\$ It looks like you are expecting the gates of the transistors to be low when the switch is not pressed, but you may want to add a pulldown resistor to make sure this is the case. You could consider making a big OR-gate tree instead of the wake-up MOSFETS. I think you could make a 104-input OR gate using 18 of CD4072B (dual 4-input OR gates). \$\endgroup\$ Commented Oct 21, 2019 at 18:15
  • \$\begingroup\$ Well, you might be able to find some small packages with multiple MOSFETs in them to cut down on the component count. But I think most keyboards use steering diodes and pull resistors to matrix. \$\endgroup\$ Commented Oct 21, 2019 at 18:36
  • \$\begingroup\$ @ReinstateMonica like I mentioned the schematic is only to deliver the message. The pull-up/pull-down resistors are omitted for simplicity:) On-topic - does this remove then mosfets on data line? Because if that would only reduce the count by half without simplifying circuit by much then I’d rather go with mosfets as these are easier to understand and thus less error prone. I think the question is more towards whether I missed some other obvious solutions that uses same simple components while making it less complex. \$\endgroup\$ Commented Oct 21, 2019 at 18:38
  • \$\begingroup\$ @rdtsc I did see a few schematics with either rows or columns being permanently pulled up. Though that means no individual button selection but a complex matrix allocation to deal with ghosting and no NKRO. \$\endgroup\$ Commented Oct 21, 2019 at 18:41

1 Answer 1

3
\$\begingroup\$

The best way to solve this problem is to use a microcontroller that has interrupt/wake support on a group of its GPIO input pins. These would be programmed to generate the wakeup interrupt when any of the pins detects a state change.

You connect this group of input pins to the MCU input side of the keypad matrix. Pullup resistors on these inputs keep all the input lines inactive. Before going into the low power state you program all the MCU outputs that are connected to the other side of the keypad matrix to a low level. When in the low power state any key press on the keypad will pull down one of the inputs to the MCU and initiate the wake event.

The scenario I describe is just for the duration of the time going into the low power state and while in that state. After the MCU wakes back up you reconfigure the GPIOs to normal scanning operation. If you want one particular switch to perform the wakeup then scan for that one as soon as you wake up. If not seen then just immediately return to the low power state. Depending on how programmable your GPIO inputs are it may be necessary to poll for the switch release once you have begun the re-entry process for the low power state.

\$\endgroup\$
5
  • \$\begingroup\$ From what I see (I might be wrong) this solves the wake up part only but then prevents individual switch selection. I didn’t specify it clearly (my bad) but in the diagram in question both sides (GPIO_IN and GPIO_OUT) are low “at rest”. Pulsing rows to high one by one and reading a column (via PISO) allows for individual switch selection. If I misunderstood, then can you please highlight how would the approach you describe allow for this? \$\endgroup\$ Commented Oct 21, 2019 at 19:15
  • \$\begingroup\$ Actually this made me think of a pure MCU programming solution. Just as in your answer to bring GPIO_OUT high before going to low power state and setup interrupts. When wake up - inhibit interrupts and bring them low before iterating over them. Since I only need to go to low power state when no button is pressed that should be doable. \$\endgroup\$ Commented Oct 21, 2019 at 19:54
  • \$\begingroup\$ Though I still would prefer a circuit solution to that (the one that would not involve such number of mosfets \$\endgroup\$ Commented Oct 21, 2019 at 19:56
  • \$\begingroup\$ @AlexeyKamenskiy - The scenario I described is just for the duration of the time going into the low power state and while in that state. After the MCU wakes back up you reconfigure the GPIOs to normal scanning operation. If you want one particular switch to perform the wakeup then scan for that one as soon as you wake up. If not seen then just immediately return to the low power state. Depending on how programmable your GPIO inputs are it may be necessary to poll for the switch release once you have begun the re-entry process for the low power state. \$\endgroup\$ Commented Oct 21, 2019 at 20:27
  • \$\begingroup\$ Yes. That seems more feasible solution, actually using one extra pin I can use just that pin for wake up interrupt and connect to it right after the switch(es) and before PISO (perhaps over a resistor and diodes (times number of lanes). \$\endgroup\$ Commented Oct 21, 2019 at 20:39

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.