Hello,
I'm testing a HX711 module connected to 4 load cells. I'm using this library
In this 24-bit ADC I have observed that making repeated raw readings with scale.read_average(25) function the last bits are unstable, seeing the result with Serial.println(weight, BIN) its value varies from one reading to another, this happens with the last 8 bits. In short, I think I can only use 16-bit resolution. This is normal? Why this behavior is?
too bad the HX711 datasheet isn't this detailed Note that this 24-bit ADC has a peak-to-peak (noise free) resolution of 17 to 19 bits (see page 10) depending on gain, sample rate, and voltage used. And they're probably using a super clean power supply. Are you?
You can get somewhat better resolution using 10 Hz sampling with the HX711 (vs the other rate, 80Hz). Also, the shielded version might be better than the un-shielded version.
In the first tests I use the PC usb as a power source.
I will Increase the number of readings, and try using 10 Hz sampling.
I have another question: the load cells will be placed under a hive, FX711 and other modules above, under the top cover, connected by a cable (4-wire) of 1.5 meters. How far can there be between the FX711 module and load cells?
This is my design
It could improve the ADC if the HX711 put together the load cells?
For connections between the ADC and the load cells, use the shortest possible wires, and everything should be surrounded by a grounded conductive shield.
Take the rate pin low. See the datasheet. On some HX711s (like some of the shielded ones), there's a jumper you can close. On others, you might have to un-solder the pin, pry it up, and wire it to ground (if possible).
I try to connect to ground, although it will be hard work because my hand is not too steady I'm feeling lucky, because the adjacent pin, pin XI (pin 14) is connected to ground.
Are you sure it isn't already giving you 10Hz? My green HX711 does. If you're not sure, measure the voltage at the pin, or you can use the code below - it tells you the time it takes to get 80 samples.
#include <Wire.h> // for i2c lcd
#include <LiquidTWI2.h> // for i2c lcd
// default address #0
LiquidTWI2 lcd(0);
const int pinCLK = A1; // to HX711 clock
const int pinDAT = A2; // frm HX711 ready/data
unsigned long nowMs;
unsigned long prevMs=0;
unsigned long count; // ADC result
void setup() {
//*** LCD setup
lcd.setMCPType(LTI_TYPE_MCP23017);
lcd.begin(16, 2);
lcd.setBacklight(true);
// 0123456789012345
lcd.print("05 HX711 spd tst");
//*** Serial setup
Serial.begin(115200);
Serial.println(F("05 HX711 spd test"));
//*** ADC setup
pinMode(pinDAT,INPUT_PULLUP); // pull high (when shut down, ADC tri-states pin)
pinMode(pinCLK,OUTPUT);
digitalWrite(pinCLK,LOW);
//*** time 80 samples
prevMs = millis();
for(byte j=0;j<80;j++) {
readADC(); // get ADC count
}
nowMs = millis();
lcd.clear();
lcd.print(nowMs-prevMs);
Serial.println(nowMs-prevMs);
}
void loop() {
}
void readADC() {
count = 0;
while(digitalRead(pinDAT)); // wait until goes low (when data is ready)
// then get 24 bits, MSB first
for(byte i=0;i<24;i++)
{
digitalWrite(pinCLK, HIGH);
count=count<<1; // shift left, zero goes into LSB; 1st time thru just shifts all zeros
digitalWrite(pinCLK, LOW); // data ready to read...
if(digitalRead(pinDAT)) // read a bit; if high, change count LSB to 1
count++;
}
digitalWrite(pinCLK, HIGH); // channel A w/ 128 gain
count=count^0x800000; // convert two's comp (see notes below)
digitalWrite(pinCLK, LOW); // leave clock low
// two's comp min = 800000 = -8388608 converted = 0
// two's comp zero = 000000 = 0000000 converted = 2^23 = 8,388,608
// two's comp max = 7FFFFF = +8388607 converted = (2^24)-1 = 16,777,215
//
}