Stabilization of HX711 and Faster Sampling. Code improvements

Hello,
I am using load cells in my research project. I have 4 load cells and have connected 4 HX711 modules (one to each load cell) and have connected them to the arduino uno.

I have taken the example code given for 2 load cells and modified it for 4 load cells. My complete code is available here. The original HX711 2 load cell library example code is available here.

I have referred the source code but still have the following questions:
Q1) The following part of the code:

boolean _tare = false; //set this to false if you don't want tare to be performed in the next step
byte loadcell_1_rdy = 0;
byte loadcell_2_rdy = 0;
byte loadcell_3_rdy = 0;
byte loadcell_4_rdy = 0;
while ((loadcell_1_rdy + loadcell_2_rdy + loadcell_3_rdy + loadcell_4_rdy) < 4) { //run startup, stabilization and tare, both modules simultaniously
    if (!loadcell_1_rdy) loadcell_1_rdy = LoadCell_1.startMultiple(stabilizingtime, _tare);
    if (!loadcell_2_rdy) loadcell_2_rdy = LoadCell_2.startMultiple(stabilizingtime, _tare);
    if (!loadcell_3_rdy) loadcell_3_rdy = LoadCell_3.startMultiple(stabilizingtime, _tare);
    if (!loadcell_4_rdy) loadcell_4_rdy = LoadCell_4.startMultiple(stabilizingtime, _tare);
  }

Is this written correctly?
Can this be removed or is this part necessary?

Q2) I wish to increase the sampling rate so I am going to increase the baud rate to 115200 or higher. Does this have any affect on the previous question? Since, the source code seems to have been written for 10SPS.

Your call. Did you see this in the library: "tare precision can be improved by adding a few seconds of stabilizing time" Does improving the tare precision matter to you?

Do you know how to increase the sampling rate of the HX711?

Why do you think there is a relationship between sampling rate, baud rate, and the stabilizing procedure?

Why would you want to run Serial at anything less than 115200?

@DaveEvans I am not getting the tareoffset in the code. I calibrate separately and save the tareoffset on the eeprom.
In this case do I need the while loop?

Do you know how to increase the sampling rate of the HX711?

Well from what I have tried with other sensors (thermocouple MAX6675 module) is that if the baud rate is low you read data slowly whereas with a higher baud rate you simply read data faster.

Why would you want to run Serial at anything less than 115200?

The serial value in the example codes given in the library run at 56700 but I wish to go faster that is why.

I think you answered that yourself.

Regarding sampling rate: the HX711 can sample at either 10 sps (the usual default) or 80 sps. It has nothing to do with the Serial baud rate. To learn how to change the sample rate, google HX711 80 Hz

Regarding Serial baud rate: there's rarely a need to use less than 115200.

@DaveEvans I see. But what is happening when I change the baud rate? Does that just mean how fast I am printing to the serial monitor? But does a slower baud rate not control how fast the loop in arduino is run?

Yes.

You would have to do a lot of printing to have a noticeable effect. OTOH, even 80 sps is glacially slow and will probably control the loop speed.

Couple of points you may already understand, but I thought I would mention, based on some recent tests I did with a 10 Kg load cell and HX711:

You indicate you are saving the tare (offset) in in EEPROM. Long term use of the offset value only really works if you are in a well-controlled temperature environment. Otherwise, there can be large offset drifts. However, the scale factor typically will remain a constant within experimental error.

Second, although you can modify the HX711 to do 80Hz, according to the HX711 datasheet the error rate increases. It gets a bit messy statistically, but it turns out, based on the data in the datasheet you can expect that if you want the data to fall in the same 95% confidence interval at 80 Hz as that at 10Hz, you need to average more points, and the effective data rate increase is then not 8x, but only 2.7x.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.