当前位置:网站首页>LabVIEW Arduino electronic weighing system (project Part-1)

LabVIEW Arduino electronic weighing system (project Part-1)

2022-06-11 21:27:00 InfoQ

1、 Description of project

Mass is in physics 7 One of the basic dimensions . In industrial production and daily life , We all need to get the mass of an object , For example, when buying a certain commodity , The mass size needs to be determined , Or take the mass as the intermediate quantity to further obtain other parameters of the object , Such as centroid 、 Eccentricity, etc .
The load cell is actually a device that transforms the mass signal into a measurable electrical signal output . According to different conversion methods , The load cell is divided into photoelectric type 、 Hydraulic 、 Electromagnetic force type 、 Capacitive 、 Pole change form 、 Vibrating 、 Gyro ritual 、 Resistance strain gauge 8 class , among , The resistance strain gauge is the most widely used .
The working principle of resistance strain load cell : elastomer ( Elastic elements 、 Sensitive beam ) Elastic deformation occurs under the action of external force , The resistance strain gauge pasted on its surface ( Conversion element ) It also produces deformation , After the resistance strain gauge is deformed , Its resistance will change ( Increase or decrease ), Then the resistance change is converted into an electrical signal through the corresponding measuring circuit ( Voltage or current ), So as to complete the process of converting external forces into electrical signals .
thus it can be seen , Resistance strain gauges 、 Elastomer and detection circuit are indispensable components of resistance strain type load cell , The following is a brief description of the functions of the three .
  • Resistance strain gauges
Resistance strain gauge is to distribute a resistance wire evenly on a substrate made of organic material , It becomes a strain gauge , The most important parameter is the sensitivity coefficient K.
It should be noted that : Sensitivity coefficient K The value is a constant determined by the properties of the material used to make the metal resistance wire , It is related to the shape of the strain gauge 、 Size is irrelevant , Of different materials K The value is usually in 1.7~3.6. secondly K Value is a dimensionless quantity , That is, it has no dimension .
null
  • elastomer
An elastomer is a structural member with a special shape , There are two functions , First, it bears the external force on the load cell , React to an external force , Achieve relative static equilibrium . secondly , It needs to produce a high-quality strain field ( District ), The resistance strain gauge pasted in this area can ideally complete the conversion from mechanical deformation to electrical signal .
It should be noted that , The stress states analyzed above are “ Local " situation , What the strain gauge actually feels is “ Average " state .
  • Detection circuit
The function of the detection circuit is to convert the resistance change of the resistance strain gauge into voltage output . Because Wheatstone bridge has many advantages , For example, it can restrain the influence of temperature change , Lateral force interference can be suppressed , It can easily solve the compensation problem of load cell, etc , So Wheatstone bridge has been widely used in load cell . Because the full bridge equal arm bridge has the highest sensitivity , The parameters of each arm are consistent , The effects of various interferences are easy to offset each other , Therefore, the load cell adopts full bridge equal arm electric bridge .
The outgoing way of the load cell is 4 Line and 6 There are two kinds of thread , The wiring of the module or weighing transmitter also has 4 Line and 6 There are two kinds of thread , The wiring principle is : The sensor can be connected to 6 The line is not connected 4 Line , You have to 4 The cable should be short circuited .
General load cells are six wire system , When connected to a four wire system , power cord (EXC-,EXC+) With feedback lines (SEN-,SEN+) They were short circuited .SEN+ and SEN- It is used to compensate the line resistance ,SEN+ and EXC+ It's a pathway ,SEN- and EXC- It's a pathway .EXC+ and EXC- It supplies the load cell , But because of the line loss between the weighing module and the sensor , In fact, the voltage received by the sensor will be less than the supply voltage . Each load cell has a mV/V Characteristics of , It outputs mV The signal is closely related to the voltage received ,SENS+ and SENS- It's actually a high impedance loop inside the load cell , The voltage actually received by the weighing module can be fed back to the weighing module . On the load cell EXC+ And SENS+ Short circuit ,EXC- And SENS- Short circuit , Only the sensor is close to the weighing module , Where the voltage loss is very small , Otherwise, there is an error in the measurement . The actual load cell is shown in the figure below :
null

2、 Project framework

This blog post will introduce the use of strain gauge load cells 、HX711 modular 、Arduino Uno and LabVIEW It forms a small range electronic weighing system of upper and lower computers , The system block diagram is shown in the figure below :
null
​Arduino Uno As the next computer , be responsible for HX711 Read / write and data transmission ,LabVIEW The display software is used as the upper computer , The upper and lower computers use USB-TTL Interface to realize communication . in addition , This system can also be used to calibrate unknown sensors , To correct the error , Improve the measurement accuracy .
HX711 It is specially designed for high-precision load cell 24 position A/D Converter chip . Compared with other chips of the same type , The chip includes a regulated power supply 、 On chip clock oscillator and other peripheral circuits required by other chips of the same type , It has a high degree of integration 、 Fast response 、 Strong anti-interference and other advantages .
HX711 The cost of the electronic weighing machine is reduced , Improve the performance and reliability of the whole machine . The chip is connected to the back end MCU The interface and programming of the chip are very simple , All control signals are driven by pins , There is no need to program the registers inside the chip . Input selection switch can select any channel A Or the passage B, Connected to its internal low noise programmable amplifier .
null
​ Please refer to :
LabVIEWArduino Electronic weighing system 【 Actual project 】- MCU document resources
 

3、 Hardware environment

take HX711 Modular VCC、GND、SCK and DOUT Respectively connected to Arduino Uno Controller 5V、GND、D9 and D10; And will HX711 Modular E+、E-、A+ and A- Connect the excitation voltage positive of the load cell respectively 、 negative , The output voltage is positive 、 negative ( Please refer to the wiring instructions of the sensor used for specific wiring ), The final will be HX711 Modular B+ and B- Pick up GND.
To reduce interference signals ,HX711 High precision A/D The connecting wire between the module and the resistance load cell shall be as short as possible , If it is too long, it will be disturbed ,HX711 High precision A/D Module and Arduino Uno The connecting line between controllers should also be as short as possible . If an extension cord is necessary , It is better to use the cable with electromagnetic shielding . The effect is shown below :
null

​4、Arduino Functional design

Arduino The lower computer part needs to complete the following functions : Read and transmit the output signal of the load cell ,Arduino Uno Control board pass USB-TTL The cable receives the command from the upper computer , After reading the data of the load cell , And send the data back to LabVIEW Host computer software .HX711 The module mainly completes the high-precision of the output signal A/D Convert and supply excitation power to the load cell .
in addition , You also need to check the sensitivity of specific sensors , To calculate full scale voltage and gain multiples . The calculation formula of full scale voltage is ︰ Full scale output voltage = Excitation voltage × sensitivity . With sensitivity 1.0mV/V For example , Assume that the supply voltage is 5V, Then the full scale voltage is 5mV.
Through actual measurement ,HX711 High precision A/D The power supply voltage output by the module is 4V about , Then the full scale voltage of the sensor is 4mV. because HX711 High precision A/D The module gain multiple is 128 or 64 The corresponding full-scale differential input voltage is ±20mV or ±40mV. In order to obtain higher accuracy , Select a gain multiple of 128 times .
Arduino Uno The controller is responsible for reading LabVIEW Quality measurement command from upper computer , And pass HX71 Obtain the voltage value output by the load cell , Send it back to the upper computer through the serial port LabVIEW Software .Arduino Uno The program code of the controller is shown in the following figure :
#include <HX711.h>
HX711 hx(9, 10,128);
#define HX711_COMMAND 0x10 // Acquisition command word

byte comdata[3]={0}; // Define array data , Store serial port receiving data
 
void receive_data(void); // Accept serial data
void test_do_data(void); // Test whether the serial port data is correct , And update the data
double sum = 0; 
void setup()
{
 Serial.begin(9600); 

}
void loop()
{
 while (Serial.available() > 0) // Constantly check whether the serial port has data
 {
 receive_data(); // Accept serial data
 test_do_data(); // Test whether the data is correct and update the flag bit
 }
}
void receive_data(void) 
{
 int i ;
 for(i=0;i<3;i++)
 {
 comdata[i] =Serial.read();
 // Delay for a while , Make the serial port cache ready for the next byte , No delay may result in data loss ,
 delay(2);
 }
}
 
void test_do_data(void)
{
 if(comdata[0] == 0x55) //0x55 and 0xAA Are used to judge whether it is a valid command
 {
 if(comdata[1] == 0xAA)
 {
 if(comdata[2] == HX711_COMMAND)
 { 
 for (int i = 0; i < 10; i++){
 sum += hx.read();}
 Serial.println(sum/10,2); 
 }
 }
 }

5、LabVIEW Functional design

LabVIEW The upper computer part needs to complete the following functions :
1、 To the lower computer Arduino The controller sends a voltage acquisition command ,Arduino The controller receives the command from the upper computer through the serial port , After the corresponding data collection is completed, the collected data will be returned ,LabVIEW The software converts the returned data into quality and displays it on the front panel .
2、 Calibration is carried out by using a standard weight to balance the weight system , To obtain the relationship between the output voltage of the load cell and the mass , Thus, the calibration coefficients of the output voltage and mass of the sensor are fitted , It is used to convert the output voltage of the sensor into the weighed mass , And it is calibrated many times by the accurate weight symmetrical weight system , It is beneficial to improve the measurement accuracy of the whole weighing system .

5.1、 Front panel design

LabVIEW The front panel is divided into two parts: weighing and calibration , The weighing part mainly reads the calibration coefficient 、 Single weighing 、 Weigh for several times and take the average value . The calibration part mainly includes 5 Calibration of the positive and negative strokes of the first order 、 Calculate fitting coefficient and save fitting coefficient . meanwhile , In the calibration part, there is a display box for overtime voltage measurement , To display the change of the current load cell output signal value in real time . Small range electronic weighing system LabVIEW Front panel of upper computer , As shown in the figure below :
null

​5.2、 Program block diagram design

Because in LabVIEW The program design of the upper computer needs to call the voltage acquisition subroutine for many times , In order to ArduinoUno The controller sends the command code , And get the Arduino Uno Measurement data returned by the controller , Therefore, the voltage acquisition subroutine is designed as a subroutine Vl, It can not only simplify the program design , It is also convenient to call .
Front panel and program block diagram of voltage acquisition subroutine , As shown in the figure below :
null
null
​LabVIEW The structure of host computer main program is sequential structure +While loop + Event structure . First , In the first frame of the sequential structure , For the array used 、 Intermediate variables and display controls are initialized , In the second frame of the sequential structure , Initialize serial port communication through the set serial port number . then , Program entry While Loop and event structures , Constantly check if any events are responded to , And implement , The event structure has &quot; measurement _ Weigh ”、“ measurement _ Read the calibration factor ”&quot;、“ measurement _ Calculate average &quot;、“ calibration _ collection &quot;、“ calibration _ fitting &quot;、“ calibration _ preservation &quot; and “ Overtime ”. Last , Turn off serial communication .
The initialization program block diagram is shown in the following figure :
null
​ stay “ measurement _ Weigh &quot; In the event structure , adopt “ Acquisition subroutine &quot; Read Arduino Uno Data returned by the controller , And use the calibration coefficient to calculate the weight , At the same time, the weighing counter is used to display the weight data in the measurement data .“ measurement _ Weigh &quot; The value change event program block diagram is shown in the following figure :
null
​ stay “ measurement _ Read the calibration factor &quot; In the event structure , adopt “ File dialog &quot; To read the calibration factor of the load cell , To calculate the weighed weight , The current calibration factor is also displayed , To represent the currently used calibration factor , The application scope of the electronic weighing system is further expanded , The weighing requirements of different ranges can be realized by configuring weighing sensors with different ranges .“ measurement _ Read the calibration factor &quot; The value change event program block diagram is shown in the following figure :
null
​ stay &quot; measurement _ Calculate average &quot; In the event structure , Through the measurement data array 5 Elements are added and divided by 5, Get the weighed weight , This method of taking the average value through multiple measurements can improve the weighing accuracy , Meet the weighing requirements of high accuracy .“ measurement _ Calculate average &quot; The value change event program block diagram is shown in the following figure :
null
​ stay “ calibration _ collection &quot; In the event structure , adopt “ Acquisition subroutine &quot; Read Arduino Uno The voltage signal output from the load cell returned by the controller , The collected data are displayed on the forward stroke and the reverse stroke by using the calibration counter and the condition structure .“ calibration _ collection &quot; The value change event program block diagram is shown in the following figure :
null
​ stay “ calibration _ fitting &quot; In the event structure , By averaging the voltage data in the forward stroke and reverse stroke arrays , With the quality standard value array, use the linear fitting function to calculate the fitting coefficient , And displayed on the calibration coefficient .“ calibration _ fitting ” The value change event program block diagram is shown in the following figure :
null
​ stay “ calibration _ preservation &quot; In the event structure , adopt “ File dialog &quot; To select the path to save the calibration coefficient , And check whether there is a file with the same file name , If it exists, remind whether to replace the file , Then save the calibration coefficient in the format of configuration file , Suffix named &quot;.ini&quot;.“ calibration _ preservation &quot; The value change event program block diagram is shown in the following figure :
null
​ When 2 No event triggered within seconds , Then the event structure enters “ Overtime &quot; Branch . stay “ Overtime &quot; In the event structure , adopt “ Acquisition subroutine &quot; Read Arduino Uno The output signal of the load cell returned by the controller , And display it as the current voltage value on the front panel .“ Overtime &quot; The event structure is shown in the following figure :
null
​ In addition to the nonlinearity of the sensor , The deviation value of the temperature drift of the resistance strain load cell can not be ignored , Temperature sensors can be added to the system ( for example DS18B20), The linear temperature drift is corrected when calculating the weight .
in addition , Select a load cell with high accuracy , The small range electronic weighing system can also be used to measure the mass center of the object , for example , Mass centroid measurement system for solid rocket motor .
Please refer to :
LabVIEWArduino Electronic weighing system 【 Actual project 】- MCU document resources
原网站

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206112123494877.html