Unexpected voltage divider ratio and analog reading

Hi everyone,

I'm doing a project where I want to read the voltage from a sensor. See Figure 1 below for a sketch of the premiss.
I simply want to read the voltage over the 40kΩ resistor "R1". I have no control over the resistance of R4 and R1, they're the ones I want to measure.

With the equipment I had at hand I came up with what I thought would be a solution, see Figure 2. Which brings me to my two questions:

  1. I thought that since the resistance of R3 is about 1/6th of R2 => that R3 would be about a 1/6th of R1. Resulting in a ratio of about 6.
    Multiplying the voltage read at A0 times that would give me the voltage of R1.

But instead I ended up having to multiply the voltage read at A0 with 7.94 to get back the voltage over R1, why is that? What am I missing?

  1. Using my multimeter I can measure that the voltage over R1 is 7,94 times greater than R3. But the voltage of A0 in the serial monitor isn't the same as the one shown on the multimeter.
    The analog input reads a voltage about 10% higher than the multimeter, and the arduinos read voltage varies up an down by a couple steps.
    Comparatibly when I connected one of the 3,3v pins to an anlog input it would give a stable and precise value.

Where is the 10% coming from and why is the voltage varying?

Code:

const int analogInputPins[] = {A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15};
float analogInputValues[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
const float voltPerUnit = 0.0049;
const float voltageScaling = 7.94;


void setup() {
  //Starts the serial comunication that will be used for debugging.
  pinMode(ledStatus, OUTPUT);
  Serial.begin(9600);
}

void loop() {
 
  //get the the analog values from the analog input pins, and scale it back to get the original voltage.
  for (int i = 0; i < 1; i++) {
    analogInputValues[i] = analogRead(analogInputPins[i]) * voltPerUnit * 0.893401 * voltageScaling;
    delay(40);
  }

  for (int i = 0; i < 16; i++) {
    Serial.print("Analog input ");
    Serial.print(i);
    Serial.print(" = ");
    Serial.print(analogInputValues[i]);
    Serial.print("\n");
  }
}

Arduino Mega 2560 Rev3

The voltage divider on the input of the Arduino ADC must have impedance less than about 10K. R2/R3 on the diagram are way out of bounds, but you can add a 0.1 uF cap to reduce the impedance and noise level.

R2 and R3 are loading the 40k R1.

R2 and R3 are in parallel with R1 so this throws your overall calculations into a turmoil.
:face_with_spiral_eyes:

Make R1 = 10k, adjust R4 so the top of R1 is 5v (don’t use R2 and R3).

Hi LarryD, thank you for your speedy reply!

When you say it's loading the 40k R1, what do you mean?

How does them being in parallel throw my calculations into turmoil? I apologise for my ignorance. Correct me if I'm wrong, but being in parallel the two branches will have the same voltage. Meaning that the voltage over R1 = the voltage over R2 + R3.

I should have made it clear in my initialpost, but I can't change the values of R1 and R4, they're part of the system I want to measure, and not something I can change.

Hello Jremington, thank you for taking your time to help me!

This definitly isn't my field of expertise and I unfortunately will have to ask why the impedance has to be less than 10k. Is that the origin of the mysterious extra 10 %?

I've heard that capacitators can be used to reduce noice levels, but I'm uncertain as for how to add it to my current setup in a way where it would help.

This is a specification of the manufacturer. The input has to charge a small sampling capacitor, and do that very quickly. The required RC time constant determines the R value.

If an external capacitor on the input (as I suggested to add) has time to charge, that takes care of the problem.

Note: the >10Meg impedance of R2 and R3 does not significantly load R1 and R4.

A voltage divider monitoring a second voltage divider can make things difficult.

You can try making R3 10k and R2 90k gives 100k but 100k will load the 40k.

Please tell us what R4 represents ?

R4 is a digital sensor. It's not an voltage divider, or its intended function isn't at least.

What do you mean with that and why is that desirable?

Post a link to it.

The value R3 should be ≈ 10k for the Arduino A/D converter to properly work.

Can you add a 1k at the bottom of R1 (in series with) ?

I went with the big resistors so that the extra current running through R4 is because of the parallel branch would be negligible. Is this in somehow detrimental to reading an accurate value?

My current understanding of your explanation is that having used resistors with really high resistance I've accidentally limited the current going into the analog input so much that the internal circuit is having troubles reading a correct value. Is that interpretation, correct?

This in turn is causing the variation and offset?

It’s worth mentioning that the solution according to figure 2 actually works okay. Im just having troubles understanding why. More precise the two questions I asked.

Yes, as I explained. 10 Meg is much greater than 10K.

If you add a 10 to 100 nF cap from the analog input to ground, as I suggested, that solves the problem.

Post a link to your sensor, so that we have some idea what you are really trying to do.

The analog input requires a certain amount of current into it to charge the sampling A/D capacitor.

When the load driving the input has high resistance, the capacitor charging is affected.

Great, I just wanted to make sure I had properly understood what you said, thank you for your patience!

@LarryD and @jremington you've both made me understand why the value is unstable and a bit offset. Thank you for your help with that, it has been really educational!

I’m curious as to why you’ve both noted that R1 and R4 isn’t loaded by the voltage divider, what’s the importance of this?

Maybe I’ve been to dense and missed it, but have anyone explained why I ended up with a factor of 7,94 instead 6?

It isn’t one specific sensor. Its digital sensors made for 24V. Normal capacitive or inductive sensors. But what I’m interested in is the voltage over the 40k resistor.

Good luck with your project.

In your circuit, V(R3) ≈ .14 * V(R1) when V(R3) is measured with a 10M DMM.

Yep, most beginners forget that a common DMM has an internal resistance of 10Megohm.
Try measuring a 9volt battery trough a 10Megohm resistor.
You will likely measure 4.5volt, because of the 1:1 voltage divider you made.

An Arduino pin, unlike a DMM, has an almost infinite impedance.
Don't forget that 'voltage' derived from an A/D value is also depending on reference voltage of the A/D. And in this case it is the supply of the Mega.
Leo..

The load resistor on a DMM in Volts mode, is in parallel with the input leads. So that configuration is a demonstration rather than something you would normally encounter. I realize you were supporting a different point, though.

You can take analog readings of extremely high impedance sources, it's just not very accurate. I know because I have some circuits that do that, 1M if I recall.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.