0
\$\begingroup\$

I want to handle 8 and more buttons or switches with only a few MCU pins and receive interrupt whenever some of the buttons is pressed (even if some switches are active).

I'd like to use PISO shift register to read data from buttons and switches and place voltage dividers with different output voltages on each button (shown at image below). Output of all voltage dividers will be connected to the derivative amplifier which should register any voltage change whenever any button is pressed.

Because more then one button can be pressed at the same time and supply voltage for voltage dividers will be 3.3 V, I'll need to detect voltage change less then 0.3 V, but when I make derivative amplifier with bigger gain, I have a large noise (i have negative voltage source for op amp made by inversing charge pump - image below - is possible that the noise is generated here?).

I would like to help with choosing components values for derivative amplifier for the smallest noise and the bigger gain.

enter image description here

enter image description here

enter image description here

update:
Thank you all for your suggestions. You have right about circuit complexity, so continuous checking of buttons state will be the best way.

\$\endgroup\$
  • \$\begingroup\$ I don't understand why you'd use analog voltages to communicate something digital like button presses. Just concatenate enough PISOs to have one input for every button, and regularly read out as many bits serially as your PISOs have. What would be the problem with that? \$\endgroup\$ – Marcus Müller Jun 22 at 14:51
  • \$\begingroup\$ Because I need to get an interrupt whenever any of button is pressed. Otherwise I would have to read serial data from PISOs all the time, which will consume a lot of processing time. \$\endgroup\$ – LucasN Jun 22 at 14:58
  • 1
    \$\begingroup\$ Use an 8 input AND gate (or OR gate) to feed the interrupt pin. Then read the PISO to see which switch was pressed. \$\endgroup\$ – Brian Drummond Jun 22 at 15:08
  • \$\begingroup\$ I like Brian's approach. Also, all my microcontrollers have SPI units which I can simply ask to give me 8 or 16 bits of serial data, at zero CPU expense, and just compare the result to the previous one (typically, a single-cycle op). Also, if these are physical buttons, how often does it even make sense to know their state? It's not going to change on a millisecond scale. Are you sure this is going to use up any significant CPU time? \$\endgroup\$ – Marcus Müller Jun 22 at 15:09
  • \$\begingroup\$ I have thinked about OR gates too, but there will be problem if any of buttons will be pressed for a longer time and meantime other button will be pressed too. Then the second button will not be reported. \$\endgroup\$ – LucasN Jun 22 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.