Standalone ADC HX711, to measure milli volts.

Hi, wanted to use HX711 24-bit adc standalone to measure voltage range of 2mv - 20mv.
Problem is:

  1. I cannot interpret the adc readings as it is in 2’s compliment.
  2. What should i do in my code(code below) so that it prints voltages not decimal values.
    Tried with different values of voltages(shared below), and i am totally confused with the readings I am getting. I dont know how to convert these values in voltage. What is the logic behind. Please help!

Readings:
0mv — 5219
1.1mv — 5095
2.3mv — 4981
2.5mv — 4960
2.9mv — 4918
5mv — 4693
10.6mv — 4075
15.1mv — 3597
22.7mv — 2700
40.7mv — 562
5volts — -8388608
-5volts — -8388607

Board is arduino leonardo, and a simple voltage divider is used for voltage generation(for testing only).
A bogde/HX711 library is used: GitHub - bogde/HX711: An Arduino library to interface the Avia Semiconductor HX711 24-Bit Analog-to-Digital Converter (ADC) for Weight Scales.
Code:
#include “HX711.h”
#define DOUT 3
#define CLK 2
HX711 scale(DOUT, CLK);
void setup() {
Serial.begin(115200);
}
void loop() {
long avg = scale.get_value(60);
Serial.print("Digital Code = ");
Serial.println(avg);
}

Never did this with a HX711 breakout board. Curious how you did that voltage divider. Because the HX711 has a relatively small common mode and differential mode range. Post a diagram. Leo..

Hi Leo,

  1. Voltage divider is only used to provide input voltage to adc for testing(dont have expensive voltage supplies). I will use HX711 to measure voltage of some other circuit(not a wheatstone bridge). Now I am testing it with voltage divider.
  2. Dont have any idea about common mode and differential mode of HX711.
  3. Diagram is in attachments.

I think that the posted circuit won't work like that. It might if you remove the small black link between A- and E- And connect a high value resistor between A- and A+ I would also change the two half-bridge resistors to 1k. Connect the voltage you want to measure between A- and A+

Problem with this millivolt meter is that the Arduino or the device you're measuring can't share grounds. One of them has to fully "float" (e.g. battery power).

Read up about opamp common mode and differential mode, and read the HX711 datasheet. I think the HX711 breakout boards work with 4.3volt E+, so common mode range is 1.2volt to 3volt. That means the two inputs have to stay within that window (can't ground one). The differential mode (max difference between A- and A+) is +/- 16.8mV at a default gain of 128. Leo..

  • I know this equation: (Vmax−Vmin)/2Nbits. But its not working.[/li][/list] E.g: LSB = 4.7 nV, Multiplied by 562 dont give 40mV.[/li][/list]
  • Leo, I corrected the circuit still getting the same values. Not having any clue, help!, need the correct equation. :confused: [/list]

…read the value:
Instead og: Serial.println(avg);
do Serial.println((5219-avg)/114.4;

You should be able to find theese parameters based on your readings/numbers

knut_ny: ..read the value: Instead of: Serial.println(avg); do Serial.println((5219-avg)/114.4;

You should be able to find these parameters based on [u]your[/u] readings/numbers

Or, follow the "how to calibrate your scale" procedure in the bogde/HX711 library "README.md", except the initial calls (to establish the "tare") are with zero differential voltage, and the subsequent calls (to establish the "scale") are by applying a "known voltage" (not a "known weight").

Alternatively, you could ditch (not use) the bogde library and just use the code in the last post in this link. Then, to determine the equation you seek: - First, apply, say, 0 mV and note the "count" (as unsigned long). Take multiple readings and average them if you want... - Then apply, say, +15 mV and note the new count. - Use those two pairs of values to determine the equation of the straight line between those points (google it if you don't know how), where "voltage" is the ordinate value (vertical or "y" axis) and "count" is the abscissa (horizontal axis or "x" axis). The equation will be of the form y = m*x + b, where y = voltage, x = count, and m and b are constants that you determine from the two pairs of values. Then you can apply an arbitrary voltage, get the count, plug that count into the equation, and then you will know the voltage.

Or, you could keep the bogde library and just do the same process with the 0 mV and 15 mV values in your first post (assuming those are reliable counts...and they probably aren't, since you seem to have violated the common mode voltage limit of the hx711).

The above must be done keeping mind Wawa's warning about not sharing grounds.

And, as Wawa said, keep the differential input voltage less than 16.8mV if you are using the default gain of 128 (judging from your last post, you don't seem to be "listening" to him). The code in the above link is based on the 128 gain.

PS: For calibration, you could use more than two points and "fit" a line through the points, but judging from your questions thus far, it's probably best to keep it simple at first and use just two points... :)

PPS: When you get data you don't understand, it is often helpful to graph it. A good homework exercise would be to graph the data in your first post (except not the two huge values at +5v and -5v).

Also, if you applied + and - 5v to the inputs (as implied by your op), it is possible that you have damaged your hx711. I'd discard it and get a new one.

Okay, will try both the methods of bodge and graphical, will compare both results and share.
Thanks for guiding, Leo, knut_ny, DaveEvans.
Shiv

Hi all, now i can calibrate adc values. Used the line equation method, take 10 readings from 1mv to 10mv and fit the line equation in excel. Pass the scale and offset values in the code and get the approximate values. Now, How can i stabilize the adc values, came to know about moving average thing. Also, I still dont know the common and differential thing with HX711 mentioned by Leo and Dave evans. I know of opamp, common mode voltage: V(Inv)+V(NonInv)/2 & Diff Voltage: V(Inv)-V(NonInv) How you derived 16.8 mV at 128 gain.Dave and Leo

Thanks!

shivg: Also, I still dont know the common and differential thing with HX711 mentioned by Leo and Dave evans. I know of opamp, common mode voltage: V(Inv)+V(NonInv)/2 & Diff Voltage: V(Inv)-V(NonInv) How you derived 16.8 mV at 128 gain.Dave and Leo

The HX711 states on page 1 that the input voltage range at 128x gain is +/- 20mV. Page 3 states a common mode range (the inputs have to stay within) of "GND + 1.2volt" and "AVDD -1.3volt" So the working window is 5 - 1.2 - 1.3 = 2.5volt. Full scale at 128x gain is 2.5volt / 128 = 0.01953volt. Close to the stated 20mV. That's if AVDD is 5volt, but the boards/diagrams I have seen stabilise AVDD to 4.3volt. That leaves a range of 1.8volt and a full scale of +/- 14mV. (must have made a mistake posting 16.8mV before). Input range can be doubled by changing default amplification to 64x. Leo..

Hmmm... I think your post with 16.8 mV is correct.

According to the datasheet, the allowable differential is +/- 0.5 ( AVDD / gain); if AVDD = 4.3 v and gain = 128, that equals +/- 16.8 mV.

Also, if the excitation voltage (from AVDD) is 4.3 volts and the load is symmetric, then the common mode voltage would be 4.3v / 2 = 2.15v, which is within the stated allowable range.

Hi there, Now that I can work with HX711 ADC(thanks to Leo, Dave Evans & Knut_ny), for deeper knowledge, I have three quick questions. 1) Which is to select for input voltage range calculation.("full scale differential input range" or "common mode input") 2) Please somebody tell me the input resistance of HX711 (not given in the datasheet). 3) Also how to stabilize the output reading, they are very fluctuating.

BTW I recently heard that the avrgcc compiler supports 24 bit ints, allowing the 2-s complement issue to be finessed here I think. For instance:

__int24 foo = 0 ;
__uint24 bar = 0 ;

void setup()
{
  Serial.begin (115200) ;
}

void loop()
{
  Serial.print ((long)foo) ; Serial.print (", ");
  Serial.println ((unsigned long)bar) ;
  delay (100) ;
  foo += 0x100000 ;
  bar += 0x100000 ;
}

shivg: Which is to select for input voltage range calculation.("full scale differential input range" or "common mode input")

I think you don't fully understand common and differential.

Common is when both inputs stay the same, and the both go up or down in voltage. Both inputs have to stay in range of the capability of the opamp. Higher than 1.2volt and lower than 3volt in this case. Common is ignored by the chip.

Only differential voltage (the voltage difference between the two inputs) is used by the chip. Leo..