# Dynamic range of voltages for ADC input controlled by software

I'm trying to build an interface that can take the readings from level sensors and provide a small enough voltage that a 3.3V microcontroller can read.

I've done this successfully using the following circuit, which will give me a reading in a fixed range of voltage inputs. The circuit is simply a voltage divider -> rail-to-rail buffer -> RC filter.

simulate this circuit – Schematic created using CircuitLab

BUT, I want to be able to interface with sensors with different voltage-output-ranges, without sacrificing resolution on my ADC. That is, I want different sensors to be compatible such that interfacing a different sensor only requires you to specify what the sensor's output range is in the microcontroller's software.

For example, some of the sensors I'm looking at have output ranges of:

• 0-2.5VDC
• 0-3.3VDC
• 0-5VDC
• 0-10VDC
• 0-12VDC
• 0-24VDC
• 4-20mA

My immediate thoughts were to replace one of the resistors in the voltage-divider network with a digi-pot, but high accuracy (low resistive tolerance) digi-pots are expensive. Are there any cheap ways to achieve this? (I'm not too concerned about circuit complexity, just cost.)

• As soon as you start precision voltage-division, the components will be expensive. How precise are your expectations? – analogsystemsrf Sep 18 '18 at 4:11
• Maybe an analog mux will be more appropriate since you don't need the resolution of the digital pot. – Mike Sep 18 '18 at 4:17
• @Mike How about MUX on input sending it to different dividers and then DEMUX to bring it to same DAC pin? Having said that, I feel there is XY problem lurking nearby – Maple Sep 18 '18 at 7:17
• As @Maple said, there's an XY issue. How would you feel about using an external ADC? – awjlogan Sep 19 '18 at 9:37
• Hi everyone and sorry for the late reply, been dealing with a lot of stuff these past few days. The mux and demux idea is certainly an option. I'm not opposed to using an external ADC as long as the cost isn't high. As far as precision goes, I believe +/- 0.5% in the output range would be acceptable. – Joe Sep 22 '18 at 8:02