I am trying to use 5 hx711 load cells for a project and everything works using following library when I use 3 load cells but I get strange readings when I use 4 load cells.
I am guessing there's a problem with not being able to read 5 cells fast enough.
Here is the function that I think needs to be changed in HX711-multi.cpp:
void HX711MULTI::readRaw(long *result) {
int i,j;
// wait for all the chips to become ready
while (!is_ready());
// pulse the clock pin 24 times to read the data
for (i = 0; i < 24; ++i) {
digitalWrite(PD_SCK, HIGH);
if (NULL!=result) {
for (j = 0; j < COUNT; ++j) {
bitWrite(result[j], 23-i, digitalRead(DOUT[j]));
}
}
digitalWrite(PD_SCK, LOW);
}
// set the channel and the gain factor for the next reading using the clock pin
for (i = 0; i < GAIN; ++i) {
digitalWrite(PD_SCK, HIGH);
digitalWrite(PD_SCK, LOW);
}
// Datasheet indicates the value is returned as a two's complement value, so 'stretch' the 24th bit to fit into 32 bits.
if (NULL!=result) {
for (j = 0; j < COUNT; ++j) {
if ( ( result[j] & 0x00800000 ) ) {
result[j] |= 0xFF000000;
} else {
result[j] &= 0x00FFFFFF; //required in lieu of re-setting the value to zero before shifting bits in.
}
}
}
}
I mean if it works for 3 but not 5, it could that your Vcc supply which powers ALL the load cells may not be able to drive more than 3 load cells at a time...
milador:
It's the actual code. There is no point posting the entire code if it's %90 the same.
Quite the contrary, there's no point posting anything but the exact code that is failing. Trust us on this,
the problem can be anywhere, a single misplaced comma, anything, having something that's not genuine
leads to confusion and wasted time.
Can't see anything obvious with the code. I had a look at the HX711-multi library and I think its fast enough
for the timing constraints in the HX711 datasheet - putting a 'scope on the pins is the only sure way to check this.
You have a millis() roll-over bug in your tare() function but that's not the issue here. My guess is this is
hardware related, either too much load capacitance on the clock pin (long cables?), or power issue (not so
likely) or a faulty HX711.
So I am using a separate power supply for load cells. It could be hardware issues for sure but I did a test by using the same DOUT pin 5 times and I run to same issue.
I was wondering if anyone has ran to this problem otherwise I will need to make my own read function or use Hx711 library instead but there will be too many wires which can cause noise.
I have a feeling it's a formatting issue with the array. So I do some few more tests before going toward my own implementation.