2
\$\begingroup\$

I 'd like to control an analog multiplexer cd4051 as a 8-1 switch with buttons that will act as channel selector (1-8) I know how to do it with Arduino but is there any other way to read the state of 8 buttons and provide a 3 bit word as separate digital signals?

\$\endgroup\$
  • 1
    \$\begingroup\$ A CPLD would be one way to do it. \$\endgroup\$ – EE_socal Feb 13 '18 at 18:44
1
\$\begingroup\$

If you want to do it with momentary switches you could do it with a couple of IC packages (flip-flops or cross-coupled gates) to have a 3-bit S-R latch, and then drive the latches on and off with diodes or gates such that pressing any switch will force the 3-bit output to the desired state.

You would need 6 resistors total and 3 diodes per switch, for a total of 24 diodes, or you could use 6 8-input NAND gates cross-coupled and 8 resistors (and no diodes).

Eg. (about 1/3 of circuit partially shown)

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
2
\$\begingroup\$

Easiest solution - use a SPDT switch on each of the select inputs (A,B,C). This will let you manually select the channel, but you will need to do the selection using a combination of the 3 switches rather than as one button per channel.

Harder solution - Add an 8 to 3 priority encoder such as SN74HC148. If you use 8 SPDT switches as the inputs, as long as you only turn on one at a time, it should do what you want. However, it's a little more cumbersome than just pushing a button since you have to turn on the switch you want and turn off the one you don't.

Hardest solution - Add a flip flop to each input. This memory cell lets you use an instantaneous button press to "set" one of the 8 flip flops. You could use a 74HC574. If the 8 inputs are normally low, and pressing the button brings the input high, all you need is a "clock" signal which latches the 8 button states in. So, say you use an 8-way OR gate between the 8 buttons to generate the clock? Then, you get a rising clock edge every time any button is pressed, which latches in the new button state. If your OR gate propagation delay is longer than the set up time for the flip flop, the timing should work out OK. You may run into switch bounce issues and need an analog debounce circuit on each button, but I think it will kinda inherently debounce the signal.

\$\endgroup\$
2
\$\begingroup\$

Use a priority encoder like a 74xx148

enter image description here

Or if you prefer CMOS a CD4532

enter image description here

Only one switch should be active at a time so this worked best with ganged switches, either push buttons like the one below or a multi-position rotary one.

enter image description here

But then again, one has to wonder, if you have all those switches, why do you need the CD4051?

\$\endgroup\$
  • 1
    \$\begingroup\$ Do those buttons release the other 7 when one button is pressed? What's the part number? Rotary switch is a good idea! \$\endgroup\$ – Selvek Feb 13 '18 at 19:16
  • 1
    \$\begingroup\$ @Selvek they usually come in both variations. That particular one can be found here \$\endgroup\$ – Trevor_G Feb 13 '18 at 19:35
  • \$\begingroup\$ Ooh that's pretty slick! \$\endgroup\$ – Selvek Feb 13 '18 at 19:39
1
\$\begingroup\$

I don't know how many i/o lines you have to work with from your micro. But I've done this before using a remote control key board. The switches are wired in a matrix.

(photo)

If you can't program pull ups like you can with the MSP430, you would have to add those. The beauty of this is two fold. You don't need an external device. And you don't have to scan if a key is not pressed. Keep all your outputs low and set interrupts on your inputs. Let a low trigger on the inputs start a scan. First switch detected closed, wins. The you can stop scanning and let a high going triggered interrupt let you know when the switch is released.

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.