I am designing a signal conditioning circuit which reads in data from 20 sensors and output it to the ADC of a microcontroller. My problem is I don't really understand how to connect these signals into the microcontroller due to the limited number of pins available (8 pins because the microcontroller comes with a 8 channel analog MUX).

Currently, my idea is to group the sensors into 5 groups, each containing 5,4,4,4,3 sensors respectively. Then, use connect each group of sensors to one pin of the 8-channel ADC. I'm not sure if this idea is feasible nor am I aware of the hardware available to do so. Please advice!

Some basic information of the microcontroller is listed below for your reference:

  1. 12-bit
  2. Sampling frequency: 200 ksamples/s
  3. Clock speed: 24MHz
  4. Conversion time: 50 clock cycles
  • \$\begingroup\$ Are your sensors already done? It may be a good idea to put those sensors on a bus system (e.g. I²C) especially when they are spread over a greater area of the machine. \$\endgroup\$
    – Janka
    Mar 21 '17 at 11:11
  • \$\begingroup\$ Sounds as if you need more muxes. \$\endgroup\$
    – CL.
    Mar 21 '17 at 11:12
  • \$\begingroup\$ Possible solutions: I2C sensors, several I2C ADCs, or MUXes. Three 74HC40518 could be the cheapest option. This supposes all sensors output a voltage compatible with the micro's ADC, of course. \$\endgroup\$
    – bobflux
    Mar 21 '17 at 11:15
  • \$\begingroup\$ @Janka Currently, I have 20 sensors, each connected to their own instrumentation amplifier and low pass filter. They are located quite close to each other (roughly 2cm on average). If I were to use I2C, does it mean that i will only need one amplifier, followed by 1 low pass filter which outputs to one pin of the ADC? \$\endgroup\$ Mar 21 '17 at 11:43
  • 1
    \$\begingroup\$ No. It would just mean you'd skip the µC's ADC all together and use multiple I²C ADCs instead, each one with it's own input multiplexer. How fast do you need to sample those sensors? That is because multiplexing will lower the sampling frequency you can use. \$\endgroup\$
    – Janka
    Mar 21 '17 at 13:51

Adding to 12Lappie's answer:

You can use 3x 74HC4051 for example (if the voltages you want to mux are compatible). So, each MUX has one analog output. Connect the MUX select inputs together, then to the micro.

Thus, you have 3 lines, which control all MUXes simultaneously (ie, if the value on these lines is 001, then the first input of each MUX is selected).

The decoder can be omitted. Simply direct the 3 MUX outputs to 3 analog inputs on your micro, and use this to select which MUX output you want to acquire. This uses 6 pins total.

Now... the filtering.

If all you want to do is amplify, you can share the amplifier between inputs, by putting it between the MUX and the micro, provided of course all inputs need the same amount of amplification. With this 3 MUX to 3 analog inputs scheme, you can use 3 amplifiers with different gains, if you want. Or you can use a single amplifier, but then you need to put the decoder back, as 12Lappie explained.

Now... the anti-alias filtering is another matter.

Remember, if you sample at (say) 1 ksps PER INPUT, then each input should have an antialias filter with decent cutoff at 0.5 ksps... and you cannot reuse it, of course. If you put the filter after the mux, and select each input in turn, then the output of the filter will be a jumbled mess of all inputs mashed together.

So, you need one filter per input. Not negotiable.

If your sensors are very high impedance (like, unable to drive the parasitic capacitance of your MUX and ADC), then you'll need the opamps anyway.

Otherwise, to keep costs down, the simplest solution is to use a dumb 1st-order RC filter, oversample like crazy, and apply the filtering in the digital domain, where instantiating 20 filters does not need 20x more parts, just a loop and some number-crunching. Simple IIR filters (ie, biquads) require little processing power provided your micro has a decent MUL instruction.

Now, the deciding factor will be the ADC sample rate, the sample rate you need to acquire after downsampling, and the highest frequency the analog signal can have that must be presevred. So, please provide this information.

Now... if your 20 sensors are measuring stuff like temperature... then why the hell aren't you using DS18B20 digital thermometers?

  • \$\begingroup\$ Thank you for the explanation about the filter. Just to clarify, the sensors are pressure sensors (ranges around 3 kOhms to 300kOhm). I estimated that the range of useful frequencies per sensor will be up to 500Hz. From Nyquist, this leads to a cut-off frequency of 1000 Hz for the filter. Currently, I'm aiming for to oversample the signal at 2000 Hz to account for imperfections of the circuit. The maximum sampling frequency which can be provided by the ADC is 200kHz. I also have a problem where I'm not sure how the sampling frequency will be affected by the number of sensors and MUX. \$\endgroup\$ Mar 21 '17 at 22:25
  • \$\begingroup\$ Well another thing you need to account for is how fast you need to switch between each sensor to acquire your data. As you may be aware, it will be impossible to acquire data at the same time from all sensors unless you have a type of memory element in there. But that would slow down your design quite a bit. In the end, I believe you will miss some valuable data since you will be constantly switching between sensors. \$\endgroup\$
    – 12Lappie
    Mar 22 '17 at 12:15
  • \$\begingroup\$ You would have to trigger your MUX very fast in order get satisfying results. I designed a Piezoelectric Vibration Sensor for Lunar Habitat back a few years ago and all the issues arising here are identical as what I saw in my design. Sampling rate, number of output, and how to mux them without missing crucial data. \$\endgroup\$
    – 12Lappie
    Mar 22 '17 at 12:18
  • \$\begingroup\$ How about simultaneous sampling ADCs? A bit expensive, though. ti.com/lit/ds/symlink/ads8528.pdf maximintegrated.com/en/products/analog/data-converters/… \$\endgroup\$
    – bobflux
    Mar 22 '17 at 13:09

There are multiple different options you could use to fix this issue. Grouping the sensors in 5 different groups is not a feasible solution unless you have multiplexers connected to each group before going to the microcontroller.

One option is to connect a MUX 8-to-3 channel to 8 sensors and 3 microcontroller pins. This way, you would be able to communicate with 16 sensors using 6 pins. This is not ideal since you want to communicate with 20 sensors and 8 pins. Just thinking about it, I came up with a solution using 3 MUXs and 1 decoder. This way, you can assign a sensor address and control which MUX you want the data from using the decoder. This could work but I am sure you could use multiple different ways:


simulate this circuit – Schematic created using CircuitLab

With the schematic shown above, you can connect 24 sensors on the "D" pins of the MUXs and you only need 7 pins of your microcontroller to get the signal. The output pins (Y and /Y) would be connected to your ADC on your microcontroller with the right sampling rate and so on. Nothing would change there. But what you would be reading would be dependent on what you set your decoder at.

Another way you could achieve this is to use a I2C bus and assign an address to every sensor in your array. This would be a bit more complicated communication/programming wise but it would be very efficient.

  • \$\begingroup\$ Thanks for the suggestion! I like this idea a lot. But, just to clarify, since I am obtaining analogue data from the sensors, is it necessary to have 2 data output pin as shown above? Could I just use one data output pin? Also, I will like to check with you whether I could place the amplifier and low pass filter across the connection to the output pin to save space and cost? \$\endgroup\$ Mar 21 '17 at 17:29
  • \$\begingroup\$ The 2 data outputs are not necessary. This is just a concept that I believe would make your life easier. One output pin is perfectly fine since the other one is simple attached to a NOT gate. Also, where else would you plan to put the low-pass filter and amplifier? \$\endgroup\$
    – 12Lappie
    Mar 21 '17 at 17:35
  • \$\begingroup\$ I'm thinking of placing the amplifier and the filter before the output pin. Will that work? \$\endgroup\$ Mar 21 '17 at 17:42
  • \$\begingroup\$ The filter is there to reduce the noise of the signal? And they have what's called analog multiplexers with low rds(on). That should help you determine what else is needed to your circuit. Personally, I would put the filter and amplifier before the mux since you may encounter some losses due to the mux connection. \$\endgroup\$
    – 12Lappie
    Mar 21 '17 at 17:47
  • \$\begingroup\$ I see. So, is there any other alternatives I could use if I want the signal from the different sensors to share the same amplifier and filter? Otherwise, I would have 20 amplifiers and 20 filters which makes the circuit less cost-efficient. UPDATE: The filters are there to reduce the noise of the signal and prevent aliasing in the digital domain \$\endgroup\$ Mar 21 '17 at 17:52

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.