I am trying to create an ohmmeter I have attached the serial output and the schematic. i have used a 1 mega ohm resistor as my unknown however the voltage drop is the largest for the 220 ohms resistor and the ohm predictions are all way off.
The voltage output by a digital pin when HIGH, which is the voltage source for your resistive dividers, is lower than the Arduino supply voltage, or the ADC reference voltage.
Your formula to calculate the unknown resistance assumes that they are all the same.
Except for the one you are currently testing with, surely you should set all the reference resitor drive pins to be high impedance (i.e. as inputs) . Only the reference you are currently using needs to be set to high after first setting it to be an output.
P.S. there is no need to know the actual voltage measured.
jremington:
The voltage output by a digital pin when HIGH, which is the voltage source for your resistive dividers, is not the same as the Arduino supply voltage, or the ADC reference voltage.
I'm not quite sure what you are getting at there. Maybe just not how I would have explained it.
If what you mean is that the ~50 Ohm internal resistance of the output driver is added to the resistance in question, that is indeed the case and significant for all of the resistor values up to 1k. But not the major problem with the code as first quoted.
This can be compensated by connecting the reference resistors for these low values as a series chain with the "free" end connected to a second analog pin.
The ADC readings are ratiometric, so whether the actual Vcc is 5 V or not, the resistance calculation - if correctly formulated - will be determined and expressed as if it was in fact 5 V.
You do however need the modification - and new code to match - that I pointed out in #5.
flintloque:
I dont have enough analog pins to set for each resistor in circuit. if digital out is not 5V what is it?
You only need the one ADC which reads the value of the voltage at the junction of all the resistors. All the reference resistors need to go to digital pins. When a resistor is not active the pin needs to set to be a digital input so that it is high impedance and does not load the circuit. The pin on the active reference resistor needs to be set to be a digital output and initialised to HIGH to set it to Vcc (Approx 5V).
You don't need to change your circuit diagram. Just your code!
This a small piece of a masters project so I don't want to invest too much into this part however I would like to get it more accurate than it is currently.
Thanks for all the advice it has been very helpful I am actually getting meaningful returns from the analogue read.
output with a 10k unknown resistor:
Sensor value = 493
Known Resistor value = 10000
voltage = 2.41
Estimate resistor value = 10770 ohm
Have you had statistics and propagation of errors in your educational program? This is usually taught to first or second year science majors in college, and should be a given for a masters program. If so, time to apply that learning! If not, back to the books.
What are the specified accuracies of the resistor values in your setup? What is the overall accuracy of a voltage divider, given the individual resistor specifications (use propagation of errors)?
What is are the ACTUAL voltages involved? Measure them with your multimeter.
jremington:
Don't worry about it -- not your project!
And not yours either.
OK, here is the circuit to compensate for the driver resistance - albeit with a slight blunder that I can't be bothered to re-do given the time limit on CircuitLab.
R1 should be 4k7 or some other desired value, and there are of course, further values after R8.
The point is, when the lower resistances - comparable to the 50 Ohm approximate value of the output driver - are selected, Analog 1 measures the actual voltage driving the selected resistor, and can be used as the basis of the ratio on Analog 0 which is used to calculate the unknown resistor value using the correct formula. By the time you get to 4k7 or 10k, 50 Ohm is only 1% or less of the value so there is no need to compensate for it.
Note of course that the low value reference resistances are now the sum of the values except for the very first, the one here on D44.