weighing device based on hx711 - web of proceedings 2019/d026.pdfweighing device based on hx711 ....

5
Weighing Device based on Hx711 Jian Huang XiJing University, Xi'an 710123, China. Email: [email protected] Keywords: Pressure sensor; hx711; A/ D acquisition Abstract: Electronic scale is a very important measuring instrument. The electronic scale mainly uses the single chip microcomputer as the central control unit, uses the pressure sensor to measure the weight of the object, which will convert the pressure deformation caused by the weight of the object into the voltage value. Through the A / D acquisition circuit hx711, the A / D conversion is carried out, and the 24 bit binary digital converted is input into the high-performance single chip microcomputer for processing, and the final result is displayed on the display. With hx711, the In order to improve the accuracy of measurement. 1. Introduction The realization of electronic weighing is to collect the weight of the measured object through the pressure sensor and convert it into a voltage signal. The output voltage signal is usually very small, which needs to be amplified accurately by the front-end signal processing circuit. The amplified analog voltage signal is converted into digital value by a / D conversion circuit and sent to the single-chip microcomputer of the main control circuit. Then, the single-chip microcomputer controls the decoding display to display the weight of the measured object. 2. System Design The electronic scale designed in this scheme can realize the function of weighing and pricing, but it is limited to the function of digital tube. When it is displayed, it can only display the unit price, total purchase amount and simple goods code. When displaying the weight, if the nixie tube does not have enough digits, the accuracy of weighing the object weight must be limited, so this scheme needs more nixie tubes to access the circuit. 3. Main Hardware Circuit Design 3.1. Pressure bridge circuit design The pressure bridge and instrument amplification circuit are shown in Figure 1. The equivalent circuit of the pressure bridge is shown on the left side of Figure 1, which is composed of two fixed resistors R and variable resistors R1 and R2. When there is no external force, the bridge is balanced. The output voltage of one pin is VCC / 2, and that of two pin is R2 * VCC / (R1 + R2). As shown in figure a in Figure 1, when there is no external force, face F1 and face F2 are the same length; when a heavy object is placed on face F1, because there is support on the left side of the pressure sensor, the whole body will bend, and the upper surface F1 will be stretched, which will cause the resistance value of R1 to increase in a certain ratio, and the lower surface F2 will be pressed short, which will cause the resistance value of R2 to decrease in a certain proportion. This will change the output voltage of pin 2. Generally, the differential output voltage range of 1-pin and 2-pin of pressure sensor is 0-20mv. The signal must be amplified. In this design, the instrument amplifier ina128 is used. 2019 International Conference on Math and Engineering (ICME 2019) Copyright © (2019) Francis Academic Press, UK DOI: 10.25236/icme.2019.026 138

Upload: others

Post on 13-Feb-2021

63 views

Category:

Documents


0 download

TRANSCRIPT

  • Weighing Device based on Hx711

    Jian Huang XiJing University, Xi'an 710123, China.

    Email: [email protected]

    Keywords: Pressure sensor; hx711; A/ D acquisition

    Abstract: Electronic scale is a very important measuring instrument. The electronic scale mainly uses the single chip microcomputer as the central control unit, uses the pressure sensor to measure the weight of the object, which will convert the pressure deformation caused by the weight of the object into the voltage value. Through the A / D acquisition circuit hx711, the A / D conversion is carried out, and the 24 bit binary digital converted is input into the high-performance single chip microcomputer for processing, and the final result is displayed on the display. With hx711, the In order to improve the accuracy of measurement.

    1. Introduction The realization of electronic weighing is to collect the weight of the measured object through the

    pressure sensor and convert it into a voltage signal. The output voltage signal is usually very small, which needs to be amplified accurately by the front-end signal processing circuit. The amplified analog voltage signal is converted into digital value by a / D conversion circuit and sent to the single-chip microcomputer of the main control circuit. Then, the single-chip microcomputer controls the decoding display to display the weight of the measured object.

    2. System Design The electronic scale designed in this scheme can realize the function of weighing and pricing,

    but it is limited to the function of digital tube. When it is displayed, it can only display the unit price, total purchase amount and simple goods code. When displaying the weight, if the nixie tube does not have enough digits, the accuracy of weighing the object weight must be limited, so this scheme needs more nixie tubes to access the circuit.

    3. Main Hardware Circuit Design 3.1. Pressure bridge circuit design

    The pressure bridge and instrument amplification circuit are shown in Figure 1. The equivalent circuit of the pressure bridge is shown on the left side of Figure 1, which is composed of two fixed resistors R and variable resistors R1 and R2. When there is no external force, the bridge is balanced. The output voltage of one pin is VCC / 2, and that of two pin is R2 * VCC / (R1 + R2). As shown in figure a in Figure 1, when there is no external force, face F1 and face F2 are the same length; when a heavy object is placed on face F1, because there is support on the left side of the pressure sensor, the whole body will bend, and the upper surface F1 will be stretched, which will cause the resistance value of R1 to increase in a certain ratio, and the lower surface F2 will be pressed short, which will cause the resistance value of R2 to decrease in a certain proportion. This will change the output voltage of pin 2. Generally, the differential output voltage range of 1-pin and 2-pin of pressure sensor is 0-20mv. The signal must be amplified. In this design, the instrument amplifier ina128 is used.

    2019 International Conference on Math and Engineering (ICME 2019)

    Copyright © (2019) Francis Academic Press, UK DOI: 10.25236/icme.2019.026138

  • Figure 1 pressure bridge and its equivalent circuit

    The amplification of ina128 adopts differential input, and the voltage generated by pressure bridge is connected to pin 2 (in -) and pin 3 (in +) of ina128. The resistance rg.5 is connected to the reference voltage Vref between pin 1 and pin 8. When the power supply film is 3.6V, TL431 shown in Figure 3 can stably output 1.8V voltage. The negative pressure is generated by TPS60400, as shown in Figure 4. The amplification factor of ina128 is calculated as shown in formula (1), and the output voltage is calculated as shown in formula (2).

    𝐺𝐺 = 1 + 50𝐾𝐾𝑅𝑅𝑔𝑔

    (1)

    𝑉𝑉𝑂𝑂 = (𝑉𝑉1 − 𝑉𝑉2) × 𝐺𝐺 + 𝑉𝑉𝑟𝑟𝑟𝑟𝑟𝑟 (2)

    3.2. HX711 design The hardware circuit of the electronic scale is shown in Figure 2, in which the bridge pressure

    sensor is used. When there is a heavy object on the pressure bridge, it will produce deformation, resulting in the change of resistance value. The bridge sensor will generate voltage difference and send it to 24 bit a / D conversion chip hx711. After internal amplification and conversion, it will send it to stm32h743iit6. It can accurately detect the weight of the object, and the calculation of the weight is shown in formula (3). The accuracy is 1g.

    Figure 2 circuit diagram of bridge pressure sensor

    5.429/DW = (3)

    In formula (3), D is the number converted by hx711. W is the weight of the object after calculation。

    4. Software Programming The electronic scale is designed in C language and compiled in keil MDK. Some codes are as

    follows:

    #include "stm32f10x.h" #include "delay.h" #include "HX711.h" #include "usart.h" int main(void) { Init_HX711pin(); delay_init();

    139

  • NVIC_Configuration(); uart_init(9600); Get_Maopi(); delay_ms(1000); delay_ms(1000); Get_Maopi(); while(1) { Get_Weight(); printf("weight = %d g\r\n",Weight_Shiwu); delay_ms(1000); } }

    #include "HX711.h" #include "delay.h" u32 HX711_Buffer; u32 Weight_Maopi; s32 Weight_Shiwu; u8 Flag_Error = 0; #define GapValue 106.5 void Init_HX711pin(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);

    //HX711_SCK GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_InitStructure); //HX711_DOUT GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_SetBits(GPIOB,GPIO_Pin_0); } u32 HX711_Read(void) { unsigned long count; unsigned char i; HX711_DOUT=1; delay_us(1); HX711_SCK=0; count=0; while(HX711_DOUT); for(i=0;i

  • if(HX711_DOUT) count++; delay_us(1); } HX711_SCK=1; count=count^0x800000; delay_us(1); HX711_SCK=0; return(count); } void Get_Maopi(void) { Weight_Maopi = HX711_Read(); } void Get_Weight(void) { HX711_Buffer = HX711_Read(); if(HX711_Buffer > Weight_Maopi) { Weight_Shiwu = HX711_Buffer; Weight_Shiwu = Weight_Shiwu - Weight_Maopi; Weight_Shiwu = (s32)((float)Weight_Shiwu/GapValue); } }

    5. Conclusion An electronic measuring device is built to measure the weak signal of pressure bridge with

    hx711. After amplifying, it is input to microprocessor, and data is collected and processed by software. Through a large number of experiments, the relationship between the analog input voltage and the weight value is determined, which can accurately measure the weight of the object and achieve the expected purpose. The system has the advantages of fast response, high precision and strong anti-interference ability.

    Reference [1] Yu Zebin, Liu Zhengchong, Lei Ruiting, Zhang Shihong, Chen Wanhua. 2m Structural design and research of supersonic wind tunnel [J]. Journal of Aeronautics, 2013,34 (2): 197-207. [2] Huang Jian, Dong Sanfeng, Wang Liping. Design based on ldc1000 automatic tracking intelligent car [J]. Micro special motor, 2017,45 (6): 62-64. [3] Ding suming et al. Design and test of njs-1 DC closed wind tunnel for plant protection [J]. Journal of agricultural engineering, 2015,31 (4): 76-86. [4] Lu Fangcheng, et al. Characteristics of live fouling of insulators under natural crosswind conditions in wind tunnel [J]. High voltage technology, 2014:40 (5): 1281-1289 [5] Tang Zhigong et al. Technical progress of aerodynamic test in hypersonic wind tunnel [J]. Journal of Aeronautics, 2015:36 (1): 86-97. [6] Wang Jun, Feng Nenglian, Zhang chunqiang, Zhang Xingyu. Research on fuzzy and PI double closed-loop speed regulation system of BLDCM [J]. Journal of Anhui Agricultural University, 2016,43 (4): 662-666

    141

  • [7] Wen Jiabin, Ma Chenwei. Design of fuzzy PI control system for BLDCM [J]. Journal of motor and control, 2016, 20 (3): 102-108 [8] Guo Wei, Chen Yifan, Zhou Li, Ni Jiajian. Fractional stage of BLDCM Research on PI Predictive Functional Control [J]. Journal of Wuhan University of technology, 2013,35 (3): 130-135

    142

    1. Introduction2. System Design3. Main Hardware Circuit Design4. Software Programming5. ConclusionReference