HX711 calibration variable possibilities

Hi all,

I am using an Arduino Nano (ATmega328P and CH340 chips). 1KG Load cell and no-ground-plane green HX711 ADC. I am using the HX711_ADC library.

I am trying to understand the Library mechanism for setting the Calibration Variable. Here is the snippet of code from their example file (Read_1x_load_cell.ino):

  float calibrationValue; // calibration value
  calibrationValue = 696.0; // uncomment this if you want to set this value in the sketch
#if defined(ESP8266) || defined(ESP32)
  //EEPROM.begin(512); // uncomment this if you use ESP8266 and want to fetch the value from eeprom
#endif
  //EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch the value from eeprom

It appears that the variable calibrationValue can be set 3 ways. First is a manual assignment (calibrationValue = 696.0;). I don't want to do this.

The second and third ways are to pop the value from the eeprom, which was populated by running the also-included calibration sketch.

The second option says: "uncomment this if you use ESP8266 and want to fetch the value from eeprom". I assume this is not for an Arduino Nano, so I should comment out this line.

I think the third option:

//EEPROM.get(calVal_eepromAdress, calibrationValue);

is what I should use for a Nano, correct?

I think using ANY canned calibration value will yield a pretty poor result. These things are VERY sensitive to supply voltage and, especially, temperature. The only reliable way to calibrate is to determine the calibration value EVERY time the system is powered on. Even then, it will drift until thermal equilibrium is reached, which can take as much as 10-15 minutes, or more. If you're trying to really accurately measure, to within a few grams, there is really no other way to do it. If you only care about being accurate to with perhaps some number of tens of grams, you might get away with a canned value.

Probably, you will have to test. I assume the calibration has two variables. Offset and Gain.

I suggest you hold the gain and offset in the EEPROM, however for the offset you should have a routine that runs if a button is pushed to redo the offset calibration.

Why?
Mechanical pressure sensors are known to have a an offset that drifts over time. So if you could tell the processor "there is no load on the sensor, please update the offset" you could compensate for this drift.

You could do the same with gain using a different button (aka digital input).

1 Like

Gain is far more a characteristic of the load cell itself - the mechanical design (beam dimensions and geometry, and strain placement), and the strain gauge itself, as well as the gain of the A/D, scaling of which is fixed in the electronic design. All of these factors are quite accurate and consistent, so generally requires only one-time calibration when the complete system is first constructed.

The offset calibration, which is not at all consistent, varies greatly over temperature, particularly the temperature of the A/D, which, in addition to being affected by ambient conditions, also suffers from significant self-heating once powered. It is also highly susceptible to electronic noise, particularly in the power source for the HX711. PCB design, and shielding, is also an important factor. Spending more on a better quality HX711 board makes a significant difference in system performance.

1 Like

Thanks Ray. My reading lead me to believe that once you calibrated an assembled device that it was pretty stable for that, which is why the fellow evidently created a library function to save the value in eeprom where it could be retrieved on startup.

Can you briefly explain the difference between offset and gain?

I found a thread that seems to go into some detail on this here:

Also:

In an industrial application I would agree, but with a "hobby" load cell I doubt it would make a difference.

And even in an industrial application, many devices have a Zero offset calibration but they hide it as "tare"

I am trying to get pretty good accuracy. I'm trying to build a device that will measure a batch of bullets, keeping a running average of the weight. Then I will re-load the hopper with the same batch of bullets, and the device will discard any that fall outside +/- some specified range. For 500 grain bullets, this range might be +/- 25 grains (+/- 1.6 grams). Or tighter still.

So I need to be able to have good repeatability of measuring an object - at least +/- .1 grams.

I think your load cell is the area most likely to give you errors. They are very process sensitive and a low cost device may not give you the accuracy you need.

no-ground-plane green HX711 ADC

While a ground plane will help you control noise, I'm not sure it is a limiting factor, at least initially. Curious, where did you get your board? All the boards I see on eBay have ground planes.

UPDATE: I looked through eBay again and apparently I was lucky in getting a board with a ground plane. I now see many don't.

Keep in mind the physical locations and lengths of your wires is likely more important than the ground plane.

1 Like

I bought the cell and HX711 as a kit here:

I have just ordered a 100g and 500g load cell as well as a grounded & filtered HX711 from Sparkfun:

HX711:
"We have separated the analog and digital supply, as well as added a 3.3uH inductor and a 0.1uF filter capacitor for digital supply."

100g cell:

500g cell:

I'm hopeful that since the items I'm weighing will weigh around 500 grains (32 grams) that a lower-capacity load cell with have better resolution over its range than the 1KG cell I started with.

The RCBS Chargemaser also uses a load cell. I have no idea how good the cell is but the entire device costs less than $200. It seems to do a good job consistently registering the same weight for the same object and returning to zero, but I have no idea what they might be doing in software to achieve that.

IME, as I said, gain is reasonably consistent, being largely a characteristic of the load cell geometry. Offset, not even close. It varies enormously with temperature.

A load cell and its associated A/D can be defined by a response "curve", which gives a graph of voltage vs applied force. For an ideal system, the "curve" will be a straight line. With no force applied, the voltage will be a certain value. With maximum load applied, the voltage will be a considerably larger value. All points in-between those two extremes will land on a perfectly straight line. So, the response can be expressed as a simple linear equation, of the form we all learned in school: y = m*x + b, where y is the voltage, x is the load, m is the slope of the line, and b is the zero offset of the line, or the voltage output when no load is applied. Gain is simply another name for the slope.

You can see for yourself how stable, or not, this is, by simply writing a program that does nothing but constantly read the A/D, and display the result. This will SHOW you the zero offset of the whole setup. What you will see is if you leave the system powered down for a while, then power it up, the A/D reading will jump, either up or down, as soon as power is applied. It will then change pretty quickly for some period of time, eventually start changing more slowly. It make take as much as 10-15 minutes before it really stabilizes. The eventual, more-or-less stable value you see is the zero offset you want to apply to future readings. Basically, just subtract this reading from future readings to get the net, or tare, reading. Over repeated test, you will likely find the offset value is not particularly stable.

Next, place a precisely known load on the load cell, ideally one near the maximum load you expect to use, and see what reading results. Let's just assume this is a 1000 gm weight, and yields a net reading, with zero offset subtracted, of 10,000. The gain of your setup is then 10000 / 1000gm, or 10 counts per gm. Over repeated tests, you should find this is a reasonably stable value.

So, the sensibly way to handle this is to carefully measure and store the gain value. But the offset value should be determined each time the system is powered up. I just provide a momentary pushbutton that causes a reasonable number of readings to be taken averaged, and stored in RAM as the current offset value. For accurate readings, you will have to wait as long as 10-15 minutes for things to thermally stabilize before you save the offset.

1 Like

Well, you would be wrong. There are numerous HX711 boards out there, and they vary wildly in performance. The HX711 is VERY sensitive to PCB layout, and shielding. The cheap boards are so noisy they never really settle down, so are incapable of precise performance. With some of these, just waving your hand near the board is enough to change the reading significantly. I tested a whole pile of these things a few years ago before finding a few that worked reasonably well. The bad ones might have been ok for coarse readings, but were incapable of even resolving even tens of grams reliably. Even then, careful filtering of the readings is essential to getting a decent result.

How you use the boards is also critical. Wires between the HX711 and the load cell must be kept as short as possible. Any electrical noise sources must be kept well away. Ideally, the HS711 should be powered by its own battery, and even the digital I/F lines should be electrically isolated. I ended up putting each board right next to its load cell, with very short wires, and the load cell and HX711 boards were completely enclosed in small metal boxes.

2 Likes

If you're weighing 500 grain bullets, you pretty much need a 500 grain load cell. Using a 100 grain load cell risks the beam deforming under the 500 grain weight. I would expect there is about zero chance of achieving 0.1 gram precision with these things. I think the noise level will be higher than that. At a minimum, good digital filtering will be critically important. At such tiny weights, even air movement anywhere near the load cell will likely change the reading significantly. I would think a good old fashioned mechanical balance scale would be a better way to go. That, or you will need a MUCH higher quality, precision commercial load cell and A/D, and likely a temperature-regulated enclosure.

You are mixing units, my friend. I am weight 500 grain bullets, so I purchased a 100 and 500 gram load cell. I have previously been using a 1 kg load cell (1000 grams).

500 grains = about 32 grams.

Either load cell should work here from the bullet's perspective, but I'm not sure how much my weighing platform will weigh so I bought the 100g and 500g cells in case my platform + bullet exceed 100 grams.

I recently purchased a new RCBS Chargemaster Lite after my Chargemaster 1500 LCD display died. I will take it apart again and take some pictures now that I have some understanding of what I'm looking at.

Hi Ray,

Thanks for the informative reply.

What is A/D?

If I am understanding correctly, it sounds like the Gain parameter set in eeprom should be fairly reliable, but the drift is not.

If I tare in between each measurement, will that largely solve the problem?

Question: If I weigh the same weight multiple times, and I tare each time I take the object off the scale, will I get the same weight when the item is back on the scale?

Years ago when I first got into reloading I bought a small, cheap ($25) digital scale. It worked fine for about a year, and then it would no longer return to zero when unloaded. I began to wonder if it was not returning to zero when unloaded, was it consistently giving me the correct measure when loaded to a known amount of powder?

I tossed it and bought an RCBS Chargemaster 1500 (about $200 item).

Misunderstood. Sorry. But, I still will be surprised if you can get useful precision at such a small weight. I'll be interested to hear what results you get. I believe the key will be doing everything possible to eliminate drift, and doing some serious digital filtering.

I took apart my dearly departed RCBS Chargemaster 1500. Turns out their load cell has a nice decal on it! :slight_smile: Anyway the cable from the load cell does not appear to be shielded, nor do the wires appear twisted. But there does appear to be a ferrite on the cable bundle where it terminates on their board.

Here is a link to the load cell manufacturer's page on this cell:

These devices dispense to within a tenth of a grain (.006 grams) with high repeatability. This is important when dispensing smokeless powder as even a tenth of a grain of difference can make a safe load an unsafe one.

Of course, I have no idea what kind of wizardry is going on with the electronics, but it seems that load cells are capable of this kind of work.

I can also tell that they have some kind of algorithm where they can tell when the weight is stable (at zero or when under load) as a little "STABLE" appears on the LCD screen.



I may just steal the load cell out of this unit and see if I can use it!

If you use the HX-711 board you should try the 10 SPS rate rather than the 80 SPS rate.

The type of A/D converter in the 711 is a ΔΣ which is much slower that a typical data acquisition device. The slower rate allows the converter to "integrate" out much of the noise that can be found in small signal circuits.

The HX711 is a 24 bit ADC, (HX711 datasheet) so if you can perfectly eliminate all of the noise, it would have a resolution of 100g/2^24 = 0.000006 grams. But a 0.006g resolution is only log(100/0.006)/log(2)=14 bits, which leaves a more reasonable budget for noise.

1 Like

I believe this is the default. I think you have to actually jumper something to get 80 SPS. Going from memory and a poor understanding of sampling.

understanding of sampling

That is the key to ΔΣ conversion, it doesn't sample like the Arduino A/Ds.

The Arduino A/D is like taking a "flash" photo. Whatever is there at that instant will come out on the other end. This type of conversion will "capture" the incoming signal + noise and convert it.

The ΔΣ converter "samples" over the complete conversion time.

So at 10 samples/second the input is converted over a period of 1/10 or 100 ms. (In actually the HX-711 conversion time will be slightly less than 100ms due to the need to do other things, I/O, input setup etc). But I'll stay with 100ms for ease in understanding.

During the 100ms conversion time any noise will be converted as well. However because noise is A/C each positive spike has a "matching" negative spike. The conversion process kind of adds the positive and negative spikes to result in a very low noise component.

2 Likes