HX711 in use

For general Flowcode discussion that does not belong in the other sections.
Post Reply
chipfryer27
Valued Contributor
Posts: 1110
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 278 times
Been thanked: 397 times

HX711 in use

Post by chipfryer27 »

Hi

I know a lot of forum members (and Matrix staff) are very familiar with the HX711 and I've read most of the posts. My own experience until recently was a few years back before FC had a component, and "Pete Smart" kindly shared his code. I have vague memories of using a small red PCB and having reasonable results in some basic testing.

Having a potential need to use some load cells I bought a device off of a well known cheap module outlet which included a 20Kg cell too. Years back I bought some 20Kg cells and each individual cell was far, far in excess of what I paid for the HX711 + cell. However you do get what you pay for so my hopes weren't too high.

I expected random noise, a lot of noise..... 24 bit ADC is surely way too much for a gadget running at only a few volts. Who needs to measure in nano volts and if you did I think you would not be doing it under anything other than heavily screened lab conditions :)

I downloaded the example and changed target to a PIC16F1939 and a "combo board" moving the connections to Port C. Looking at the component properties I see the Clock Transition Delay at 25uS. The "tooltip" suggests a max of 1uS for 10Hz and 4uS for 80Hz. Why the discrepancy? I assume an oversight or typo (incidentally the board I'm using seems fixed at 10Hz unless I want to attack it).

I get the setting of scaling factors, channel/gain and sample count etc then the zeroing, but I was sceptical of getting stable readings (random noise etc). When running the example I get a variance of anything up to +/- 1000 or so between readings with no load on the cell. I did kind of expect as much. I don't think this would easily be averaged out unless you wished to wait forever per reading and I do appreciate using a lower gain would help too.

I found that to get any usable stability I need to shift the result right by 10. With this shift I could load the cell and get repeatable, stable results even without much averaging.

I would be keen to hear of anyone else's experience with this module. Do you have similar instability? It could just be that my module+cell is cheap for a reason and that is my issue. Any brands that you can recommend that work well?

Regards

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: HX711 in use

Post by stefan.erni »

Hi chipfryer

Many HX711 modules work very well with Flowcode. I use some. Depending on the application, a plug on the board and housing is practical, or a circuit board if you want to solder something additional. If you have a sensor with 4 wires then you really have a lot to choose from. But if you only have a single strain gauge with two wires then you need an additional 3 resistors. There are also 350 Ohm or 1k straingage and 350 Ohm resistors are not easy to find. With some modules you can choose 10Hz or 80Hz but some are fixed at 10Hz. With 10hz you have less noise because it is filtered a little more in the HX711. Work with 24-bit and you will soon notice that you have to reduce a few bits to display the measured values. If you want to build your own board with an HX711, soldering the HX711 is not a problem but none of the major distributors sell this chip.

regards

Stefan

distributor:
https://octopart.com/search?autosugg_id ... 11&specs=1
example:
hx711_2022-07-27_10-55-46.jpg
hx711_2022-07-27_10-55-46.jpg (39.41 KiB) Viewed 1600 times

chipfryer27
Valued Contributor
Posts: 1110
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 278 times
Been thanked: 397 times

Re: HX711 in use

Post by chipfryer27 »

Hi

Thanks for the reply and suggestions.

My module is similar to the Sparkfun one and I believe is quite generic, available from many sources. I was a bit dubious of what I'd get for the price I paid, but.....

The cell it came with is rated at 20Kg but I doubt it would take anything like that in the real world where it would be subjected to who knows what. It is a wheatstone bridge config but the wires are exposed.

I grabbed one of the 20Kg cells from years back, which is 350 Ohm and again wheatstone in design but fully screened and "professional" in nature. This made little or no difference to the fluctuating readings having still the need to shift 10 places to get any stability.

The screened lead made little difference nor did placing it inside shielding so that left power as the main suspect. It was being powered via an EB06 programmer which itself was powered by a plug in PSU. Powering the module by batteries immediately reduced the fluctuations to around +/- 200 or so (EB06 still running off PSU) which is a huge improvement (>>8 instead of >>10) and that was without any averaging techniques being employed so I'm quite impressed with its potential.

My intended application will be fully battery powered which hopefully will reduce the noise a bit further, and will most likely utilise an ESP32. Now that I see what even a "cheapo" module is capable of I'm happy to go look for a range of modules to compare.

I didn't find much either when searching for the chip with the major players, other than fully assembled modules, but you can get just the chip itself from Chinese sources starting at around USD 0.10 or so. Maybe something I'll look at further down the line.

Thanks again for the suggestions.
Regards

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: HX711 in use

Post by stefan.erni »

Hi chipfryer

You must load your straingage with 20kg or at least 1kg.
Then you can choose the gain. Add another 100g and look at the variation and the noise.
Maybe you don't need all those bits at all.

regards
Stefan

chipfryer27
Valued Contributor
Posts: 1110
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 278 times
Been thanked: 397 times

Re: HX711 in use

Post by chipfryer27 »

Hi Stefan

I sincerely doubt if I would need 24-bit for anything running at 5v or less :)

I've now ordered up a small set of calibrated weights to test further. Whilst these only cover up to 500g they do make my target weight of xyz grams. As long as this value (and multiples thereof) are read consistently, without any misrepresentation then I'll be good.

Definitely going to do as you suggest, checking at certain known values, and I'm quite sure that I'll be shifting right as a result...

Regards

chipfryer27
Valued Contributor
Posts: 1110
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 278 times
Been thanked: 397 times

Re: HX711 in use

Post by chipfryer27 »

Hi

Just a quick update.

Using batteries to power an ESP32, the module and the screened load cell, but still with jumpers, stability improved again. Powered by a PSU I have to shift > 10 to get stability but on batteries it's >7 and that is without any cool averaging.

I need to knock up a test frame to mount the cell, and once done I'll then see what happens with known weights.

Regards

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: HX711 in use

Post by stefan.erni »

Hi chipfryer

Do you use a Bar or Disc?

A little hint. There are already bars for measuring in the range of 0.5 kg.
Of course, they are much easier to load because you can only measure a maximum of 0.5 kg, but practical on the laboratory bench

regards

Stefan

https://www.sparkfun.com/products/14728
Load Cell_2022-08-09_11-31-59.jpg
Load Cell_2022-08-09_11-31-59.jpg (20.96 KiB) Viewed 1426 times

chipfryer27
Valued Contributor
Posts: 1110
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 278 times
Been thanked: 397 times

Re: HX711 in use

Post by chipfryer27 »

Hi Stefan

Thanks for the links.

I created a small frame and did some tests up to 500g using one of the intended 20Kg cells. I was more interested seeing the stability than anything else but I have to say the results were impressive.

Sample count was set to 20/10 and it just looped around updating itself and displaying results.

The frame is quite basic and it didn't matter where on the MDF bed the weight was placed, the reading was the same.

Frame_1.jpg
Frame_1.jpg (111.57 KiB) Viewed 1395 times
Frame_2.jpg
Frame_2.jpg (84.93 KiB) Viewed 1395 times
Frame_3.jpg
Frame_3.jpg (71.06 KiB) Viewed 1395 times

Using an ESP32 running off batteries, after zeroing I took Raw readings and shifted right >>7 to get stable readings. Temperature in the Evil Lab was a bit North of scorching (and up in my Ivory Tower it was even worse) but readings remained stable and repeatable even only being a breadboard creation.

Zero.JPG
Zero.JPG (129.17 KiB) Viewed 1395 times


After being zeroed, I took a series of readings from 10g to 100g at 10g intervals. This provided linear results as can be seen in the graph(s). A 10g weight gave a value of "17". I then took another set of readings from 100g to 200g at 20g intervals. Again results were linear. Finally I took readings from 200g to 500g at 50g intervals. Every result was a multiple of 17.


10g-100g.JPG
10g-100g.JPG (28.35 KiB) Viewed 1395 times
100g-200g.JPG
100g-200g.JPG (26.28 KiB) Viewed 1395 times
200g-500g.JPG
200g-500g.JPG (27.97 KiB) Viewed 1395 times

Next, I'm going to create a frame / container that is similar to the actual size in the target application and do some more tests. Hopefully the linear response will continue at an acceptable level.

Regards

Post Reply