0
\$\begingroup\$

I am designing a circuit to read a large (500+) number of analog sensors. The goal was to do this on all one circuit and landed on using multiplexers. I started with the CD4051B which allowed me to read 8 sensors with four pins on my microcontroller. Cool, but not impressive. Doing some more digging I came across this figure in the datasheet (page 14).

24-to-1 MUX Addressing

This configuration, which only shows 3 4051s, can actually handle four now allows me to use 5 pins on a microcontroller to read 24 sensors. An improvement for sure, but I needed more.

Now hoping over to the CD4556 datasheet, I came across this figure (page 5).

1-of-16 decoder using CD4556 and CD4555

Then from this figure I was able to combine the CD4051 circuit and end up being able to read 256 sensors only using 8 pins on my microcontroller! This was perfect for my application.

Now for the actual question, I built a smaller version of this circuit which allows me to read 80 sensors on a breadboard to do some testing. This circuit works, but there is some weird stuff that I am hoping to mitigate.

For example, let’s say I interact with sensor one and the values move up and down as expected with the rest of the sensors remaining stable. However, the minimum value the sensor reaches is around 5000. Now, if I go over to sensor two and interact with it while also interacting with sensor one the minimum values will drop significantly (to around 1500). When interacting with the sensors without any multiplexers (or just one or two layers) the values get even lower.

Did I just hit the limitations of this system? Or am I experiencing something like leakage current that can be resolved. I will add that I am not using any type of resistors or capacitors and hooking everything up exactly as the datasheets show.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ No, there's something wrong, and not nearly enough information to help diagnose what. \$\endgroup\$
    – user16324
    May 21, 2021 at 14:02
  • \$\begingroup\$ If you add a counter, then all you need is two port pins. Works for any number of inputs. Nevertheless, 500 inputs muxed down to 1 is certainly possible, but probably not the most robust technique. \$\endgroup\$
    – Kartman
    May 21, 2021 at 15:57
  • \$\begingroup\$ What about EMC and physical size? How exactly can you have 500+ sensors on a single PCB? That doesn't make any sense. Nor does it make any sense to draw out CMOS logic outputs over long wires all over some large facility. \$\endgroup\$
    – Lundin
    May 24, 2021 at 8:22
  • \$\begingroup\$ It’s just the brains/control board. The sensors are not mounted on the board. They are separate and just the signal wires are connected to board. I do agree that having all those wires go to one board is not ideal. However, it’s what I’m trying out first. Curious if you had to read 500+ analog sensors, how would you do it? Also just to add that the physical size and length of wires is not really a factor in this question as I’m doing a relativity small test on a breadboard. \$\endgroup\$
    – Berchell
    May 25, 2021 at 11:14

2 Answers 2

1
\$\begingroup\$

You should look at the output of your multiplexer with a scope and tell the micro to switch between two sensors that are at different positions. You'll see how fast it jumps from one value to the other. If it is too slow, you'll want to adjust the delay between switching and sampling so the micro samples after it has settled.

I'll assume the sensors are pots, and if you have 500 pots you'll want low total supply current, which means high value pots. Combined with the capacitance of the switches, this can make for slow settling.

I'd put a small capacitor to ground on each input, like a 10-100nF. That will get rid of noise picked up by the wires, and it will be pre-charged to the correct value when the ADC is switched to that input, so the output will settle quicker.

Then, considering the quite high ON-resistance of the switches, you could put a buffer opamp between the switches and the ADC. If you use a single supply, a rail to rail input opamp will be necessary, and if source impedance is high it should have a FET input for low offset current. Check the datasheet for settling time.

\$\endgroup\$
2
  • \$\begingroup\$ Wow, thanks for this information. I am actually using phototransistors as my sensor, each one has a resistor connected to the emitter. If I make any breakthroughs I will update the post. \$\endgroup\$
    – Berchell
    May 22, 2021 at 18:28
  • \$\begingroup\$ OK, that's probably pretty high impedance too, like the pots I assumed you had, so the answer would still apply. \$\endgroup\$
    – bobflux
    May 22, 2021 at 20:01
0
\$\begingroup\$

Maybe this thread from the Arduino forum has posts relevant to your problem. Citing, for your convenience, some posts:

Mar '11 #7

...

The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less. If such a source is used, the sampling time will be negligible. If a source with higher impedance is used, the sampling time will depend on how long time the source needs to charge the S/H capacitor, with can vary widely. The user is recommended to only use low impedance sources with slowly varying signals, since this minimizes the required charge transfer to the S/H capacitor.

...

Your circuit adds the on resistance of CD4051B's transmission gates that may be as high as 500 Ω. Make sure that, with this added resistance, the signal value does not deteriorate through emergent voltage dividers and that the signal timing does not vary in the way described in the post. If this is the case and you cannot remove the problem in hardware, try to use the trick of the following post:

Apr '11 #8

...

The trick when using multiple analog sensors is to read them twice, with a small delay after each read (10ms is good), then discard the first reading. This is because the ADC multiplexer needs switching time and the voltage needs time to stabilize after switching.. Basically the first analogRead call causes the multiplexer to switch, the delay gives the voltage time to stabilize, then your second read should be much more accurate with less jitter.

...

Code excerpts of this thread implement this stabilization trick for ADC multiplexer operations. You can also try and apply this trick to switching operations of your multiplexer, if this S/H timing is your real problem.

\$\endgroup\$
1
  • \$\begingroup\$ The coding trick is interesting and will be easy to implement so I will give that a try \$\endgroup\$
    – Berchell
    May 22, 2021 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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