0
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Your drawing does not correspond with the nomenclature of the chip. You show that you've got your "Signal" leads connected to the select inputs. \$\endgroup\$ – Lawrence NK1G Mar 15 '17 at 2:36
  • \$\begingroup\$ @LawrenceNK1G, Okay, I've updated the schematic for clarity \$\endgroup\$ – user95482301 Mar 15 '17 at 2:43
  • \$\begingroup\$ So - tell more about what is connected on the analog mux pins? What is the signal source that you're reading? \$\endgroup\$ – Lawrence NK1G Mar 15 '17 at 2:48
  • \$\begingroup\$ @LawrenceNK1G, I'm going to read a lot of things, like pots, voltage dividers etc., but right now it's just connected directly to 5V, and yet the multiplexer output reads at 0V, when switching fast between inputs. \$\endgroup\$ – user95482301 Mar 15 '17 at 3:01
  • \$\begingroup\$ For 3.3V analog try HC4051 instead \$\endgroup\$ – Phil W Mar 15 '17 at 3:54
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Hmm, that's disappointing. From the Arduino wiki page, it reads "Futhermore, the 4051 is able to work with analog values; in the case of the Arduino, you are able to use the analog inputs with a voltage between 0-5V and route them to an Analog-In Pin on your Arduino.". But the documentation on their website is generally incredibly poor, so I wouldn't be surprised. Is there a better alternative? Ideally something that would allow multiplexing without distorting the signal. \$\endgroup\$ – user95482301 Mar 15 '17 at 3:29
  • \$\begingroup\$ I did try to add a 10k resistor in series with the input, but it changed the output. The Arduino has about 10Mohm resistance on the input side, so it shouldn't make a difference, but the max reading was about 1010 instead of 1023. But perhaps I can calibrate it. Still, I was hoping for a method that wouldn't tamper with the input signal in any way :/ \$\endgroup\$ – user95482301 Mar 15 '17 at 4:08
  • \$\begingroup\$ The 4051 is an analog multiplexer - it can switch analog signals between Vee-0.5 and Vcc+.05 volts. However, the control inputs require CMOS digital levels. \$\endgroup\$ – Peter Bennett Mar 15 '17 at 6:28
  • \$\begingroup\$ I think something like the CD74HCT4051 would work. Note the HCT in the part # this means it would work with both TTL and CMOS levels allowing operability in mixed voltage environments. Look at page 4 of this guide. \$\endgroup\$ – electrophile Mar 15 '17 at 8:06

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.