HX711: 24-bit Delta Sigma ADC interface for weight scale using PSoC

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Hi,

Provided below is custom component (HX711 v0.0) for interfacing HX711 24-bit Delta Sigma ADC for load scales.

HX711_02a.png

 

The HX711 component implements software interface to HX711 24-bit analog-to-digital converter by AVIA Semiconductor, designed for weigh scales and industrial control applications. Using this component in conjunction with external HX711 ADC, PSoC can detect small DC signals in the range of +/-20mV or +/-40mV at 10 Hz sampling rate, or +/-80 mV at 80 Hz. Component consume little to none hardware resources, and spares very little CPU clocks (0.01%). Multiple instances of the component can run asynchronously in the project.

 

Component features:

   Implements software interface for HX711 ADC

   Interfaces single HX711 sensor board

   Uses interrupt or polling methods

   Has selectable ADC gain

 

The component was tested using CY8KIT-059 PSoC5 prototyping kit and CY8KIT-042 PSoC4 Pioneer Kit. Demo projects are provided.

 

Attached archive contains component library, component datasheet and demo projects for PSoC5 and PSoC4. Please read installation instructions in the readme.txt.

 

The component provided as-is, no liabilities. It is free to use and modify.

/odissey1

 

 

P.S. Demo projects use optional annotation components (which are also provided here in Support_libs.zip):

   PSoC Annotation Library: PSoC Annotation Library v1.0

   KIT-042 annotation stub: KIT-042: annotation component for CY8CKIT-042 Pioneer Kit

   SerialPlot library: SerialPlot: interface to real-time data charts

   MedianFilter: MedianFilter: sliding window median filter component

   ButtonSw32: ButtonSw32: button switch debouncer component

 

SerialPlot open source charting tool for Linux/Windows can be downloaded here

   https://hasanyavuz.ozderya.net/?p=244

   https://bitbucket.org/hyOzd/serialplot

 

 

Figure 1. PSoC4 project schematic using HX711 component in polling mode.

HX711_P4_basic_01a_A.png

Figure 2. ADC raw data are being conditioned by the MedianFiler and streamed to the plotting software using SerialPlot custom components.

HX711_P4_basic_01a_D1.png

Figure 3. Load Cell response on 1-cent coin load/unload using SerialPlot software (program configuration Settings.ini is attached). Red line - ADC raw data, Blue line - ADC data after median filter.

HX711_P4_basic_01a_E1.png

Figure 4. Project annotation using KIT-042 stub and PSoC Annotation Library.

HX711_P4_basic_01a_C4.png

 

Message was edited by: odissey1 (4/4/2020)

Files updated: HX711_v0_0_B.pdf and HX711_lib.zip. The component datasheet was revised; the previous version incorrectly described the ADC gain and clock setting. Component library (HX711_lib.zip) has been updated to include latest datasheet. The component itself has not been modified.

6 Replies
DiBr_284171
Level 2
Level 2
First question asked 10 replies posted 5 replies posted

Hi,

HX711_P4_basic_01a compiled with Creator 4.2 produces a Build error: undefined reference to 'Button_1_Readpins" in Button_1.c  file line 136. HX711_P5_basic_01a builds fine. Is there a fix for this error?

Regards James

0 Likes

DiBr,

I can confirm that in Creator 4.2 the Button_1_ReadPins() does not compile. As a workaround I recommend to comment out (delete) the "__INLINE" statement in the Button_1.C file or in the ButtonSw32.C file of the ButtonSw32 component.

//==============================================================================
// Read pins status (fast inline code)
// returns current state: 32-bit word combining REG_3, REG_2, REG_1, REG_0
//==============================================================================

//__INLINE    // << comment out this statement
uint32 Button_1_ReadPins() 

....

0 Likes
PeSe_1509996
Level 3
Level 3
25 replies posted 10 sign-ins 5 questions asked

First of all: thanks for sharing your component.

May I have a question - what do you think ? : for the time critical application (we need the precise weight measurement as soon as possible, e.g. within 0,3 sec ) is it better to use 80 Hz mode with MedianFilter (instead of 10Hz mode) ?

 

Thanks in advance,

Peter 

 

0 Likes
PeSe_1509996
Level 3
Level 3
25 replies posted 10 sign-ins 5 questions asked

Another way to ask a question:

according HX711 data sheet: the Input noise is  50 nV(rms) at 10 SPS and 9nV(rms) at 80 SPS.

So noise is approx. 2x, but 8x more measurements in the same time window.

Is it worth to choose the 80 SPS: 2x raw noise but 8x raw measurement  combined with right parameter of MedianFilter.

Can we get more precise measurement in less time ? 

e.g.: 80 SPS (HX711 higher rate), 20 raw measurement (approx. 12,5 x 20 = 250 ms), MedianFilter N=15.

What  do you think ?

 

Thanks in advance,

Peter

0 Likes

Peter,

1.  Any filtering of the ADC data inevitably delays measurement results. Therefore, I recommend to run the demo project provided above without any data filtering  (simply comment out that line of code). Use SerialPlot software to visualize the data on the PC side (the SerialPlot is fast enough to plot >1000 points/sec), and see if any noise filtering is necessary at all. 

Note that the MedianFilter in the example provided was used for a specific purpose to eliminate a sharp spike from a coin dropping on the scale. I am not familiar with your application, it may happen that no such problem exist in your case. 

If you can post a screenshot of the data recorded, I could provide better recommendation regarding filtering techniques.

 2. I believe that the most accurate way of measurement is to use HX711 as-is (11Hz/24 bit). It returns result in ~100ms. There are several ways to speed it up: you can provide an external Clock (I believe up to 20MHz), so the data will come out at 22Hz, or, alternatively, configure HX711 to 80 Hz mode. I did not try any of that myself, but from what I read, 80Hz is more noisy than the native 11Hz. 

Note that  accuracy of the measurements is often affected by the electromagnetic interference or mechanical noise, and not related to the ADC directly. The wisdom is that a single experiment is worth  more than a thousand words.     

If you could post a data trace, it would be helpful.

/odissey1  

0 Likes

Peter,

One more thought about DelSig_ADC accuracy. Note that the is major distinction between DelSig_ADC and SAR_ADC operation, and how a digital filter may affect the result. Unlike SAR_ADC, the DelSig_ADC is continuously averaging input signal during entire sampling period (~100ms at 10Hz). If   sampling rate was increased to 100Hz, and then digitally average by 10 samples, the result should be be the same as at 10Hz sampling. The only advantage of faster sampling I see if noise distribution is not random (Gaussian), with some occasional spikes ("outliers"). Then a non-linear filter, such as a median filter, can (theoretically) improve the accuracy by dropping out those "outliers".

Therefore, I recommend recording and inspecting some data first.  

 

0 Likes