Multiplexing buttons using shift register – high impedance output

high-impedanceintegrated-circuitmultiplexer

I have experience with 74HC4094, and I believe the 74HC595 is essentially the same – the datasheet says they have "tristate output", but that is only when OE is low – then all pins are tristate.

What I'd want is that high would be high, and low would put the output pin in high impedance mode (aka tristate). It is intended for multiplexing buttons, in order to save IO pins on the micro.

How to achieve this, best?

  • Is there some other chip with this functionality – or maybe, how can I do it myself?
  • I thought of adding diodes to the output, but it'll probably not work good, because of the voltage drop.
  • Maybe there's some other solution, like chip specifically meant for multiplexing buttons?

With the diodes, it'd be something like:

--u--+           +-------------//--+
     |---data-->-|                 |->- to next shift reg.
  uc |--clock-->-|  shift register |->-
     |--store-->-|                 |->-
     |           +-------------//--+
     |             |    |    |
     |             V    V    V diodes
     |             |    |    |
     |              |-   |-   |-   buttons
     |             |    |    |
     |-<--sense----o----o----o---
-----+

I'd just send 1 to data, and then zeros, moving the 1 through all my buttons. The "sense" wire would have pull-down (or pull-up if the diodes were reversed).

Best Answer

Assuming you need 8 switches or fewer, you could use the same three port pins and a 74HC4051. Each switch goes to ground and to an input, and the output of the multiplexer goes to the micro using an internal pullup (in practice you may wish to add some stuff to deal with ESD from the switches, but that's outside the scope of this answer).

So you would simply put a 3-bit address on the three port pins and read off the state on the input- one part total.

Edit: if you really want to use shift registers you could use parallel-in serial out registers with a pull-up per switch or use one of the '595 variants that has open drain outputs (TI TPIC series such as this one). Most designers will put the switches in an XY matrix when there gets to be that many,to reduce parts count and minimize cost in a production situation, but you're free to make your own trade-offs.