Electrical – Multiplexer CD4051B gives strange readings

multiplexer

I'm trying to multiplex an analog input port on an Arduino Uno.

Datasheet

schematic

simulate this circuit – Schematic created using CircuitLab

I've connected the input to 5V for testing stability of the reading. I've programmed a small routine that checks for consistency of the signal reading.

I'm using a breadboard of questionable quality.

The CD4051B Output is grounded via a 500k resistor, so that unconnected ports read 0.

If I read only port 4 for 30 seconds, it starts to read correctly and stable.
If I start reading random ports (between 0 and 7), it reads correctly for about 10 seconds, then suddenly starts reading zero.

I've tried changing the pull-down resistor. It still goes to zero.
I've tried removing the pull-down resistor. The value then starts reading randomly.
I've also tried adding a 1uF capacitor.
But it changes nothing.

I'm using digitalWrite on three pins to select the input port, and then waiting (delay) for 30ms before doing an analogRead on A0. I've experimented with various delay times, and 30ms seemed to improve things a lot when reading sequantially (0, 1, 2, 3…), but when reading randomly, it doesn't work at all.

I'm a bit lost to what the problem could be. I imagine it could be something with capacitance on the ports, but I have the impression that the multiplexer is actually supposed to support very fast switching?

Update:

I saw a comment on the 'arduino' board which said that "the for loop repeatedly cycles count from 0 to 7, so [selector pins] will average 2.5 V". Is this realistic? Wouldn't the digital pins be able to sink fast enough that the IC would mux correctly?

The IC has internal protection circuits. Is it possible that they are getting triggered? But this happens even with 1k resistor on Input 4.

Best Answer

I'm using a breadboard of questionable quality.

That is what seems to be the source of your problems. Problematic breadboards cause loose connections within the board which you cannot see and hence lead to situations such as open connections etc. I'd try using a different board.

Also the pulldown resistor need not be that high. A 10K resistor works well in most cases. I'd also try switching the IN value from the Arduino instead of connecting it to VCC. I haven't seen the block diagram for the chip but it seems that you may be shorting something internally inside the chip which is why the input drops to 0V after a short time. At the very least, connect a pullup resistor of about 10K between IN and the 5V power source.

Though this may not be very relevant in this case, its important to note that the 4051B is a CMOS device and hence anything less than 1.5V on the input is 0V on the output and the lowermost threshold for a HIGH input is 3.5V. This means that this chip will not work with 3.3V devices without appropriate voltage level translations.