# How to fix the reading wrong analog value?

I am trying to read analog values between 0V-24V via the circuit below. But as the analog input voltage changes my read error margin becomes bigger.

What am I doing wrong or how can I fix it?

• D1 = ZMM55-C3V3
• Analog input range = 0-24V
• MCU ADC read range = 0-3V3

Example Read Values:

• Changed R2 Value to the 1.1K

• Took out Zener from the circuit

• AVDD = 3.327V

• There is still error as if there is no linearity as the analog input changes error margin becomes bigger.

Analog Input --- MCU ADC PIN Value --- Read ADC Value

24V --- 2.836V --- 3430

12V --- 1.402V --- 1667

6V --- 0.692V --- 790

Solved: I notice solder issue with AGND pin of the MCU that was the main problem beside from Zener diode.

• What is D1????? Oct 20, 2021 at 15:30
• Please provide links to the manufacturer's datasheets for the Zener diode and the ADC. Oct 20, 2021 at 15:31
• Look at the current-voltage curve for that zener, and factor that into your calculation. It's almost certainly the cause of the error.
– user16324
Oct 20, 2021 at 15:33
• What's the expected ADC input range? 0V to 5V? Oct 20, 2021 at 15:34
• @kalyanwaroop "pretty inactive" is not technical parameter. It has V/A characteristic and differential resistance at high than nominal voltage. So it changes dividers. Oct 20, 2021 at 15:50

## 2 Answers

The first problem is that the resistor values do not allow measuring up to 24V, the divider would output 3.7V which is more than the maximum ADC input of 3.3V, and thus the resistors allow measuring only up to 21.3V.

The second problem is how the zener diode us used. It is rated to have nominally 3.3V voltage at 5mA current. So it will start to conduct much earlier than at 3.3V and it will have lower voltage over it at lower current as the divider can't prodvide 5mA into zener. Also the zener tolerance is from 3.1V to 3.5V at 5mA current so it can either limit the measurement or allow overvoltage.

Basically the zener is not an ideal component that is off at below 3.3V and turns fully on at 3.3V.

• If i change the 1.5k resistor to 1.1k so that zener will limit the voltage when input is 28V. Would that work out ? Oct 21, 2021 at 6:58
• @U.Sim that zener has a very soft knee. You can try it but it can start conducting at 2V already. Oct 21, 2021 at 8:52
• After i changed resistor value and took out zener from the circuit there is still some error, i added some measurements could you look at it ?. Oct 22, 2021 at 5:49
• There is not much to look at. You don't say which ADC or MCU you are using and how it is set up. There is no code. There is also no mention of resistor tolerances. The measurements can be perfect for 10% resistors. Oct 22, 2021 at 6:43

First of all: what's the precision of your resistor and more importantly of your 3.3V voltage reference?

But most importantly:

Your divider network has a gain of 0.155. So your 24V become 3.72. You are triggering your zener and overranging your ADC (in that order). Your ideal range with this divider would be 21.29V (with 3.3V output assuming the zener is not breaking down)

Your zener has a tolerance range of 3.1 to 3.5V so you can't rely on having more than 3.1V on the output anyway (that would reduce the range to 20V). Also that's at 5mA, if you look at the curve it will start to 'leak' before (that's the zener soft knee).

Other possible issues: your divider has an output impedance of about 1.2k. In itself it's not an issue but need to be considered. From the graph the zener will start to leak at about 2.1V and that current will do bad things to your reading (some calculation needed). You only need about 80µA to have 0.1V error in the output signal.

Your relatively high output impedence could also impair settling of the sampling in your ADC (but your huge 100nF filter capacitor mitigates if); check your datasheet for the maximum output impedance recommended on the analog input or use a bigger sampling time (it depends on the part, the datasheet usually has the full story since it varies with the ADC architecture). The typical multiplexed SAR inside an MCU should handle it without too much issues.

I'd try to raise your upper divider resistor to 10k to enable the full range you need and replace the zener diode with a schottky clamp to 3.3V (which is indeed the thing inside the ADC you don't want to trigger with and overvoltage)

• Precision of my resistors are %1, and my reference voltage is 3.327V. My actual problem was that there was not linearity at read values. I even took out the zener diode, error margin become smaller. But there is still error and as the voltage raises error margin becomes much bigger, i add some data about to the question. Oct 22, 2021 at 5:36