Work with the Chinese chip ADC Hx711

The reason for writing this post is the desire to deal with the module 24 bit delta sigma ADC converter based on the Hx711 chip. The converter itself is assembled in the form of a ready-made module according to the switching circuit recommended by the manufacturer (????). There are also comments on the operation of this module on this website in Andrey Gerasimenko’s blog “ADC 711 from 3.3V- do not believe the Chinese documentation and not only ...” .

To test this module, a circuit based on the ATmega16 microcontroller, the ADC module, the BC1602 two-line LCD, on the basis of the HD44780 controller, four buttons was assembled. As the development environment, we used the Code Vision AVR program, version 1.25.9 professional, AVR Studio 4, Version 4.09.0.338, the AVR JTAG USB programmer, which allows not only programming the crystal, but also tracking step by step, if necessary, the program execution in the microcontroller, almost in real time.



A Chinese-made load cell with a maximum weight limit of 40 kg was chosen as the signal source for the ADC. and standard sensor insertion unit. It should be noted that the use of "native" integration units allows you to get all postulated output data from a single point strain gauge, model CZL A6. So, strain gauges of type Single Point, when using the size specified in the technical specifications of the platform for the location of the weighed load, are designed so that the imbalance signal of the strain gage does not depend on the position of the load on the platform. It is the MECHANICAL properties of the sensor body: geometric dimensions, the location of glued strain gauge films, especially the “bone” cutout in the middle of the sensor body, the size of the platform affecting the torque applied to the sensor body determines this independence.



Well, the last source is "GOST 29329-92. Scales for static weighing. General technical requirements. ” This GOST defines the properties of weight measuring instruments. It is also important to work with the EXCEL office program. I am using EXCEL 2003 XP3. This allows you to quickly process the results using ready-made methods.

I hope all the information necessary to repeat my experiments is given fully.

Now the program itself that I use to work with the module. The program is focused on CHECK, and hardly directly, i.e. without changes, it can be applied for some applied needs. Although, as they say, "depending on where to apply."

The program itself is a block structure. It consists of 4 routines and the fifth main main. The first subroutine: ReadCount, reads data from the ADC module and generates them into the Count variable.

CreatInput, generates an input array of conversion data from 32 values.

CreatOutput, generates an output array of ADC conversion data by organizing a moving average with a window size of 16 data.

Keys, a simple program for responding to keystrokes.

So that is all. The variables are basically all global, especially since mega resources allowed.



The main program starts by creating the CreatInput input array, then the input data is filtered using the moving average method. The selection of this filter is based on the following. When the program is running, the data on the display changes its value in a fairly large range. I have taken the values ​​of the ADC at zero effort on the platform and tabulated. The values ​​were obtained by using the JATAG USB debugger in the AVR Studio environment.



In the Excel file “Data Acquisition”, on the “Moving Average” tab, the result of filtering the fluctuating input data InputBuff (oscillation span 436 units) with an averaging window of 3.12.16 intervals is shown. The result is shown in A37-A40 cells. From which it is seen that the most effective, in this case, is a moving average with a window of 16 samples.

Built graphs show this clearly. The data is taken from a working controller, stopped at the moment of transition to the data display procedure. Illustrative examples of such data capture are shown in the pictures.



No methods of data filtering, through the use of various digital filters, could in any way “tame” the input fluctuations. If you look at the graph of the input data, then the Gaussian distribution here does not even “smell”. As confirmed by the user Nikopol_86 in the blog "... do not believe the Chinese documentation"

Nikopol_86 5 February 2019 at 09:27 0


To be honest, he has enough noise at all ratios. I did some research on the density distribution of the ADC codes issued with input circuits shorted, and so there is a spread of up to 1000 1_5V and nifiga is not a normal distribution law, which suggests that either the board wiring is in trouble, or with the ADC, or all taken together . I also noticed that he also does not have temperature stabilization, and the claimed operating temperature range does not correspond to reality. If only because when you connect a 5 kg strain gauge to the ADC, changing the temperature in the room by 1 degree will take readings by 2 grams, and if you warm the microcircuit with your finger, the readings will fly up to 5-7 grams. In general, I made conclusions for myself that only a cat food dispenser can be made on this device,where accuracy in one tram stop will be more than enough. And alas, normal solutions are not cheap, because you have to use high-quality ADCs from AO or T1.

As you can see, the conclusions were confirmed. True, the same is true:
jushabrauser February 4, 2019 at 12:52 p.m.
With a signal-to-noise ratio <1, this will never help.
Even with a bridge circuit.

Therefore, under normal conditions (without special mathematics and / or circuitry) at least 8 low-order bits give out nonsense (most likely).

24 honest Chinese bits for 350 rubles? Do not tell my slippers.
If the iron itself is "lying" - what can you do about it?
Here, even a third-order nonlinear filter will not help, because the source data is not a cake.

It was from this place that I wanted to see what this module is capable of as part of the scales. Searching the network for problems with the jitter of the last bits of the ADC, led to the forum kazus.ru/forums/showthread.php?t=105320&page=4. Here's a whole discussion about stabilizing readings. However, none of the proposed mathematical methods “calmed” the input data that I receive. From the “hardware” itself, to stabilize the readings, it was introduced: the connection of digital and analog ground, as well as the short circuit of input B to the ground. We used full shielding and powering the module from a 6v battery (followed by a stabilizer 7805) separately from the controller circuits. There is no result, the input data is swinging ...

So, the “clean” 24th category cannot be obtained and the reason here seems to me to be a poor-quality m / circuit. So you need to trim the resulting conversion range. For this, in the ReadCount program, a line was introduced with dividing data by 100. 100 is a little less than 2 to 8 degrees. T.O. AD conversion comes in 16 bits. However, even such a limitation did not make the testimony reliable. And the reason here is the strain gauge properties.

So, after applying the calibration process (linking the value of the ADC and the weight on the platform), the weight is displayed in grams. He displays 500 grams as the number 500, one kg as 1000. The division price is 1 gram. Those. we get with 40 kg sensor 40,000 divisions. According to the technical data for the load cell, we can get from the sensor only 3,000 divisions (symbol C3 in the name of the sensor). So the price of division should be (40000/3000) = 13.3 grams. However, according to GOST 29329, weight metrology does not operate with the number 3. Digits should be used:

2.1.3 The value of the calibration division value (e), scale division price (d) and reading resolution (dd) in mass units should be selected from the following: 1X10a; 2X10a; 5X10a, where a is a positive, negative integer or zero.

T.O. the division price for this sensor, guaranteed by the manufacturer 10 grams. That is, the output format should be 0.0x kg. where x = 1,2,3, ... .0. Let's try to make the division price of 5 grams. The relevant programmatic actions are listed. After such a restriction, we “take” from the sensor 40,000 / 5 = 8,000 divisions, which is 2.6 times more than the permissible. After these assumptions, the resulting scales work quite steadily.

The above remark on the applied load cell and its “resolution” do not allow us to conclusively state that this module cannot produce a 24-bit conversion. However, I have tested this sensor for operation with a resolution of 1 gram, on another device, with a different AD converter. On this device, the operation of the sensor and the conversion can be considered satisfactory, because the weight fluctuation was not more than 3 grams.

What does not allow the use of this ADC in commerce? Well, the first and most important thing is the dependence of the measurement on temperature. Second, using the division and multiplication operations built into ATMEGA, especially for 8 bits, it is difficult to calibrate the scales over the entire weight range under these conditions. It should be borne in mind that the program does not react in any way to the sensor overload.

How to overcome these inconveniences. First, enter the temperature sensor and adjust the weight reading from the temperature value. Which is pretty complicated. “Cheaper” is to introduce the calibration option, for different loads and depending on the error caused by the temperature, calibrate the weight used in the work.

The second is harder. Replace the procedure of multiplication and division by tabular and shear operations. I think this is the best way to use this module in practice of building weights.

To complete the description of the requirements for creating a program for scales, it is necessary to use the "Program of metrological (certification) calibration of scales" attached to each balance.

Conclusion:Creation of scales based on m / s Hx711 is possible subject to all metrological requirements for the scales. The introduction of corrections for the temperature dependence of the conversion must be provided for in a separate procedure. Using a module with a resolution of more than 16 bits requires a separate approach and control.

Source: https://habr.com/ru/post/undefined/


All Articles