I have built a differential voltmeter with an ads1115 breakout board and the differential example sketch from Adafruit.
I have wired everything like in the picture below. The LM317 voltage regulator sends 10 mA through my resistor that I would like to measure (in this case 220 Ohm).
The aim of the ads1115 is to measure the voltage drop so I can calculate the value of the resistor via ohm's law.
This works really well for the following resistors: 1.47, 10, 47, 100 Ohm. When I use a resistor with a higher resistance, for example the 220 Ohm resistor in the picture, I see only 192 Ohm in the serial monitor.
I would be very grateful if anyone can explain me the limiting factor!
Thank you very much for your reply! I think I have changed the input voltage to +- 6.144 V:
This is my code:
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
//Adafruit_ADS1015 ads; /* Use thi for the 12-bit version */
void setup(void)
{
Serial.begin(9600);
Serial.println("Hello!");
Serial.println("Getting differential reading from AIN0 (P) and AIN1 (N)");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
// The ADC input range (or gain) can be changed via the following
// functions, but be careful never to exceed VDD +0.3V max, or to
// exceed the upper and lower limits if you adjust the input range!
// Setting these values incorrectly may destroy your ADC!
// ADS1015 ADS1115
// ------- -------
ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
//ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
// ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV
// ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV
// ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV
// ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV
ads.begin();
}
void loop(void)
{
int16_t results;
/* Be sure to update this value based on the IC and the gain settings! */
//float multiplier = 3.0F; /* ADS1015 @ +/- 6.144V gain (12-bit results) */
float multiplier = 0.1875F; /* ADS1115 @ +/- 6.144V gain (16-bit results) */
results = ads.readADC_Differential_0_1();
Serial.print("Differential: "); Serial.print(results); Serial.print("("); Serial.print(results * multiplier); Serial.println(" mV)");
delay(1000);
}
Well some measurements ought to confirm it works. I just noticed the closeness to 2.048V (which is
often used as a reference in ADCs) and checked the datasheet.
Does the LM317 have enough compliance to provide the proper current at 220 ohms?
Absolutely not, he's powering it from +5 rail of the Uno.
I'm surprised that 47 and 100 ohm read correctly. There may be other measurement factors in play as well but the lack of higher supply voltage for the constant current source is a show stopper at higher unknown resistances.
I explained this limitation to the OP in his original voltmeter thread that he abandoned, starting over rather than continuing this one:
It seems the bottlenack is the Arduino. I am now powering my Arduino via a 6 V / 600 mA powersupply and connected the LM317 to the VIN pin. Now I am able to measure the 220 Ohm resistor
Thank you all very much, I did not think about that!
@avr_fred: thanks for your reply, I did not get an email notification. I just saw my thread on page 2 or 3 yesterday so I did not reckon that there will be a reply. I will put the INA317 in series and report back in the other thread.
6v on the Vin pin will cause problems, that's out of spec and not enough margin for the 5v LDO regulator which needs at least 1.5 volts above output voltage. Plus, unless it's a authentic Arduino, you don't know what part number was used.
I would like to use a 4 wire circuit to eliminate the resistance of my wires, because they will be longer and exposed to varying temperature when everything is working.
This hand drawn circuit works but not perfect. When I use the differential example sketch I get the correct value for my resistor. But when I use the singleended example sketch I can see 672 for A0 and 0 for A1 so there is no real difference between the two inputs of my ADS1115 and therefor it seems I am not doing a 4 wire measurement.
I only see different values for A0 and A1 when I pull out the ground cable of my ADS1115. Then I get -976 and -448 whose difference is not 672.
I am not very experienced with electronics so I have no idea what is wrong.
My circuit got inspired from this website: differential voltmeter tutorial
the current from your 317 is 1.25/100 + Iregulator
the 317 requires Uinput-Uout>3V, and Imin 10mA, it may work with 5V but it is at the edge
A1 will measure aprox tens of uV. The resistance of the wire from A1 to GND could be say 0.01ohm. With 13mA current you may get say 130uV voltage on it.
If you pull your gnd wire (A1--GND) off the circuit you will measure a nonsense.
with resistors > 220 ohm you run into troubles, as the voltage on the resistor should be 0.013*220 = 2.86V. You cannot get such voltage, as you cannot source such current, as the 317 is powered by 5V only.
To use it as ohmmeter you most probably have to use much higher input voltage for the 317 current source, and, you have to be able to switch the currents to lower values for higher resistors (ie. 1mA, 100uA..).
The 4 wire method is usually used when you measure at 10A, where the voltage drops across the leads/wires are relevant.
pito:
The 4 wire method is usually used when you measure at 10A, where the voltage drops at wires are relevant.
4-wire is needed when the resistance measured is small, not when the current is large. The point is that
the resistance of the wire is no longer negligible compared to the resistor being measured, and that's true
whether you pass 10A or 10uA through the unknown resistance.