Reverse multiplexing

I want to use many (about 30) switches as inputs to my Arduino Uno. I've built a circuit using four 74LS30 (nine input NOR gates) to multiplex 15 switches down to 4 pins (16th state is when all switches are off, 0000) which works. However, expanding this to accept inputs from more switches will mean that the circuitry will get VERY complicated. :frowning: It's not just a matter of adding another 74LS30, as all the inputs on the current ones are in use. I'm limited in the number of available pins on the Arduino that I can use, as I'm also using a MotorSheild to control a DC motor and some servos.

Basically, what I need is a 32 line to 5 line (binary) multiplexer.
Is there an IC (or two) that will do this for me?

Yes, I believe the correct IC for this job is the 74HC165N: the parallel to serial shift register. Sparkfun sells them but probably for 1000% markup.

Basically, what I need is a 32 line to 5 line (binary) multiplexer.
Is there an IC (or two) that will do this for me?

There is no one IC to do this but you can cascade a number of 4051s to give you any number of inputs.
With each 4051 you get 8 inputs, so using 4 of them gives you 32 inputs going down to 4 outputs. You can feed those outputs into another 4051 to get one output. So five chips will do it.

Grumpy_Mike:
you can cascade a number of 4051s to give you any number of inputs.

Thanks for your reply. Looking at various circuit diags. it appears that I'll need 6 pins on the Arduino to select which switch I want to check and another pin for the input to the Arduino. Only one of the 30 switches will be on at any one time. They're magnetic reed switches to give positional information.

I'm thinking of making a second 4 * 74LS30 board and using the (4 bit binary) outputs of both these boards to input into a single 4051 so that I need only the control signals for one chip and one input line = 4 pins.

No to look at up to 32 inputs on one arduino input you only need 5 pins on the collection of 4051s. The number of inputs you can select is given by two to the power n, where n is the number of select lines you need to use. In your case four 4051s are connected to your inputs, those four outputs are connected into a second layer 4051. While this has three select lines as you only want to select one out of four you only need to wire up two of those select lines and ground the third. The select lines on the first layer of 4051s are common so that makes five lines in total.

Again, thanks for your help.
So that's 5 lines to select the input and one data line = 6 pins. Correct?

So that's 5 lines to select the input and one data line = 6 pins. Correct?

Yes. :slight_smile:

Could also use just two 16:1 chips.
Still need 4 address lines, 1 pin to select one chip or the other, and 1 pin for the data to come in on, but you do a lot less wiring for connecting it all up.

Well a bit less wiring up but the chip is more than twice the size.

True, the chip is bigger - but you only need 2 chips instead of 4 or 5.
All comes down to the tradeoffs one wants to make.

CrossRoads:
1 pin to select one chip or the other

How do you use one pin to select one of two chips, as both enables are active low? Taking that one pin low would enable both of them and taking it high would disable both of them. Or have I got it wrong?

Ah, you are correct - I had looked at several parts, was a little mixed up about the number of enable pins.
No problem, just add a transistor as an inverter, and enable one or the other.

Thanks for the info. I'm thinking of using 74HC4067Ns but I don't know if my local electronics store in London has them. Mail order will probably incur more shipping charges than the value of the parts :frowning:

That's one of the tradeoffs: what you can get vs what it costs vs how much room on the board vs how much code it takes vs ...

Mail order will probably incur more shipping charges than the value of the parts

Yes they are only £0.91 here:-
http://uk.farnell.com/texas-instruments/cd74hc4067e/logic-mux-demux-analog-hs-24dip/dp/1740160
The trick is to order other stuff to get you up to the free shipping total, which is about £25 or so here. Once you get into electronics you will find there is always stuff you want or need. Why they even sell Arduiunos and Raspberry Pis and lots of other stuff. It is a good excuse to get interesting things. You can justify it by saying to yourself, "well I had to get it to get me up to the free postage value so in effect it is free". :slight_smile:

CrossRoads:
That's one of the tradeoffs: what you can get vs what it costs vs how much room on the board vs how much code it takes vs ...

vs how much time it will take (although, being retired, that doesn't worry me much). :smiley: