Calculating Unknown Resistor with Arduino

Sounds Good :slight_smile:

This is a bit of a special case, because the goal is to measure the Ratio of the two resistors.

The 5V (Vcc) reference is good when you have a sensor that is proportional to its Vcc and both are the same. However the 5V reference is not very stable.

The 1.1v Internal is not very accurate but it is stable. So if you need to read voltage you are better off with the 1.1v. To resolve its inaccuracy if you can once measure it with a precision voltmeter or at least a good hand held then you can modify your code to use this "actual" value and be reasonably sure it will stay the same.

1 Like

If I understand this right the resistors have own power supply. Arduino Vcc is not their power supply and do the measurement is not ratiometric! Moreover the 16 resistors take about 5 A (!) total. Enough to introduce errors by voltage drop in the wires.

Smajdalf is right.
Supply and ground of the divider must have a solid/short connection to Arduino 5volt/GND.
If not, then ratiometric (correcting) behaviour between divider and A/D is compromised.

I never understood why "voltage" is used to calculate the unknown resistor.
It should be possible to convert directly from A/D value to resistor value.
Something like this (untested).

(float) R_unknown = (float) R_fixed * ((1024.0 / analogRead(A0)) - 1.0); // R_fixed to ground
// or
(float) R_unknown = (float) R_fixed * (1.0 / ((1024.0 / analogRead(A0)) - 1.0)); // R_fixed to VCC

Leo..

Edit: changed 1024 into 1024.0

If I understand this right the resistors have own power supply. Arduino Vcc is not their power supply and do the measurement is not ratiometric

I agree. If it is the same or could be the same then it is ratiometric. And if it is not, then one would have to measure it with the A/D of the measuring Arduino which brings it back to ratiometric again.

Regarding the logic of this test.... it escapes me why go through this amount of effort when a Fluke is nearby, however I've tried to answer the OP's question.

Wiring specifics, distances, 2 wire meas and a bunch of issues will have to be addressed. As does any calibration and R1 resistance verification.

(float) R_unknown = (float) R_fixed * ((1024 / analogRead(A0)) - 1.0); // R_fixed to ground
// or
(float) R_unknown = (float) R_fixed * (1.0 / ((1024 / analogRead(A0)) - 1.0)); // R_fixed to VCC

But isn't this the same approach? Basically the ratio of the ADC times R1. I'm not 100% sure but I think for the above eqn to work R1 and R2 have to be reversed.

I will have to admit I need to think more about where 1023 vs 1024 are used. I've never really done too much with the ADC.

Currently, one divider circuit is drawing 60 mA (so 1 A total).

They do. Soldered connections on the daughter board and the Arduino (I removed the dupont ports to rule out poor connections).

Ohms law. I'm not super well-versed in electronics (obviously), but I thought Ohms Law would be the best option to solve this. I will give your equations a try.

I am attempting to automate the fluke--hence the effort. We currently do use a fluke; however, it is not economical to do so. These parts are printed in sheet form with 16 parts per sheet. Every part, per the customer's direction, must be checked.

Everything I am doing came from here: Experiments and projects with an Arduino microcontroller (skillbank.co.uk)
I would definitely recommend this site. John Errington (site's owner) even responded to my first post about issues related to this project (see the link in my first post).

So almost every equation I have tried is returning the same numbers as the ones before it, including my original (I really do appreciate your suggestions thus far). This really stumps me because now I'm really unsure about where to go next without ripping everything apart and using something like an INA260 with a multiplexer.

The Arduino and fluke are measuring nearly the exact same voltages (i.e. 1.92 V on the Arduino vs 1.89 on the fluke). Would 0.03 V really cause 1 ohm difference?? If not, are the resistors I have the wrong ohmage? Should they be lower?

Your divider is 10 Ohm + (about) 6 Ohm = 16 Ohm and the supply voltage is about 5 V. This gives 5/16 ~ 0.3 A. How did you get 60 mA?

My bad. I was reading between the resistors. You are most likely correct. Everything is soldered down, so it would be hard to get the exact measurement without taking things apart.

Meaningless, because the Arduino A/D (default settings) does not measure voltage.
It returns the ratio between the two resistors.

Again,
If VCC is not exactly 5.000volt, then voltage measurements are meaningless.

And,
Exact voltage is not required when measuring ratio.
Leo..

Can you also measure voltage over the known 10R resistor? You assume it is 5.15 - "unknown resistor voltage" but what if its not?

Did you consider the possibility the values returned by Arduino are right and the resistance values measured by Fluke are wrong? What resistance Fluke shows when you connect the probes together? Are you using 4-wire (Kelvin) method?

2.725V across the known resistor.

I did. But this is unlikely. I have the known resistances written down on the parts I am testing which were measured with a different fluke than the one I have. My fluke returns the exact same measurement that I have written down; so this is highly unlikely.

After about 30 seconds, it flips between 0.0 and 0.1 ohms.

I'm not super familiar with that method, so I might be doing it unknowingly? If you see above, I provide the schematics for what this circuit looks like. Perhaps that will be a better answer than me taking a shot in the dark and answering wrong lol

Which VCC? The supply to the Arduino or the supply to the testing circuits? I have two (commonly grounded).

So, what would be your suggestion then to try and fix this issue? My apologies, but I am wholly confused by what you are trying to get me to understand.

Attempting both of these equations results in incorrect R_unknowns. What should my analogReference be? Changing it between INTERNAL2V56; INTERNAL1V1; and DEFAULT all return different, but incorrect, values.

Finally we found it! IIRC you have about 1.8 V across the unknown resistor. But 1.8 + 2.725 is not the assumed 5.15 supply voltage of the resistor divider. This needs to be fixed somehow.

So you are saying I have voltage drop somewhere in the line. Makes sense. But where that is (or multiple wheres for that matter) is going to be a pain. Would I instead be able to just correct for that voltage drop in software? I assume its not a constant though :confused:

It is also possible your power supply is unable to provide enough power. Use your DMM and try to find where the voltage "disappears".

So, after further testing, I believe I figured out where the drop is coming from. The wires that lead off of the daughter board with the divider circuits are kind of thin. There are likely other locations where the drop is coming from, but this is likely the biggest hitter.

That being said, as this circuit is already made and I'm just trying to fix it, it is not possible for me to replace these wires as they are epoxied at one end. Can I just provide a constant correction factor (like adding the missing ~0.5 volts to the reading from the pins) or is there a better option I'm not aware of?

Why are you asking this.
They must be exactly the same if you have shared ground and shared VCC.
A different testing circuit voltage and Arduino supply voltage won't work.

Try to Google something like "absolute vs. ratiometric A/D".
Basically, when supply voltage on the testing circuit goes down, A/D value goes down.
but when supply voltage on the Arduino goes down, A/D value goes up.
If both supplies are linked, then voltage variations cancel each other out.
So absolute voltage is irrelevant if you have connected things right.
Forget about measuring voltages with your DMM.

Remind me what value resistor you are trying to measure.
You get the highest resolution if the unknown resistor is is about the same as the fixed resistor.
Don't expect a high resolution if the resistance difference is more than 10 times.
Leo..

Anywhere from 6.5 ohms - 7.5 ohms. That is the nominal range (i.e. 99% of all parts should be within this range). There may be parts that fall below 6.5 ohms or are above 7.5 ohms; however, I am not worrying about those right now.

The fixed resistors are 10 ohms. They have a tolerance of +/- 1%.