Method and system for detecting number of cigarette bins through ultrasonic waves
By introducing a temperature compensation module based on LSTM in the ultrasonic cigarette bin quantity detection system, the impact of temperature changes on ultrasonic distance measurement accuracy is solved, and high-precision and automated cigarette bin quantity detection in the tobacco logistics center is achieved.
Patent Information
- Application Number
- CN202411609160.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-02-28
AI Technical Summary
In the complex environment of tobacco logistics centers, ultrasonic ranging methods are affected by temperature changes, resulting in reduced measurement accuracy, especially when temperature differences are large in winter and summer.
The temperature compensation module based on the long and short-term memory network (LSTM) is used to measure the actual distance and temperature data through the ultrasonic module and the temperature sensor, normalize and compensate, and output the compensated distance data to overcome the temperature influence.
It effectively compensates for the error of ultrasonic distance measurement at different temperatures, improves measurement accuracy and stability, and realizes the function of automated, real-time monitoring and accurate detection of cigarette bins in different seasons.
Smart Images

Figure CN119535424A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of ultrasonic detection technology, and more specifically to a method and system for ultrasonic cigarette bin quantity detection. Background Art
[0002] With the continuous deepening of ultrasonic technology research, coupled with its advantages of high precision, non-destructiveness, and non-contact, the application of ultrasound has become more and more popular. At present, it has been widely used in industrial fields such as machinery manufacturing, electronic metallurgy, navigation, aerospace, petrochemical, and transportation. In addition, it also occupies an important position in the fields of material science, medicine, and biological science.
[0003] Using ultrasound as a positioning technology is a means of defense and survival for some creatures without visual ability, such as bats. That is, the organism emits ultrasound that cannot be heard by people, and uses the air medium to transmit the time interval reflected by the prey or obstacle to be captured and the strength of the reflected ultrasound to judge the nature of the prey or the location of the obstacle. Since the speed of ultrasound is much smaller than the speed of light, its propagation time is easier to detect, and it is easy to transmit in a directional manner, with good directionality and good intensity control. Therefore, humans use simulation skills to use ultrasound to measure distance. Ultrasonic ranging is a method that combines sound wave characteristics, electronic counting, and photoelectric switches to achieve non-contact distance measurement. Because ultrasound has good directivity, slow energy consumption, and a long distance in the medium, ultrasound is often used to measure distance. The design of using ultrasound to detect distance is relatively simple, the calculation and processing are also relatively simple, and the measurement accuracy can also meet the requirements of daily use.
[0004] Ultrasonic distance measurement has significant advantages in some occasions, because this method uses the calculation of the transmission of ultrasonic waves between the object to be measured and the ultrasonic probe to measure the distance. Therefore, it is a non-contact measurement and can be used in some specific occasions or in harsh environments. For example, to measure the liquid level of toxic or corrosive chemicals or the distance between fast-moving cars on the highway.
[0005] At present, non-contact distance meters often use ultrasonic, laser and radar. However, laser and radar distance meters are expensive, which is not conducive to widespread popularization and application. In some application fields, they have their limitations. In comparison, ultrasonic methods have obvious advantages:
[0006] 1. The propagation speed of ultrasound is only one millionth of that of light waves, and it has strong directivity and slow energy consumption, so it can directly measure the distance to closer targets.
[0007] 2. Ultrasonic waves are insensitive to color and light intensity and can be used to identify transparent, translucent and poorly diffuse reflective objects such as glass and polished objects.
[0008] 3. Ultrasonic waves are insensitive to external light and electromagnetic fields and can be used in harsh environments such as darkness, dust or smoke, strong electromagnetic interference, and toxicity.
[0009] 4. Ultrasonic sensors have simple structure, small size, low cost, simple and reliable information processing, are easy to miniaturize and integrate, and can perform real-time control.
[0010] In summary, ultrasonic method as a means of non-contact detection and identification has attracted more and more attention. It has been widely used in robot obstacle avoidance, navigation system, mechanical processing automation assembly and detection, automatic ranging, non-destructive testing, ultrasonic positioning, car reversing, industrial well logging, reservoir level measurement, etc.
[0011] In the prior art, the method of using ultrasonic waves to measure the distance between a known reference position and the surface of a target object is called ultrasonic ranging. However, whether measuring distance indoors or outdoors, temperature is an important factor affecting the measurement accuracy, especially in the complex environment of tobacco logistics centers. When operating, there is a certain difference in ultrasonic speed under different temperatures in winter and summer. Therefore, when using ultrasonic waves for ranging, the influence of temperature on the measurement results must be considered. Summary of the invention
[0012] The present invention overcomes the deficiencies in the prior art and provides a method and system for ultrasonic cigarette bin quantity detection.
[0013] The purpose of the present invention is achieved through the following technical solutions.
[0014] The ultrasonic cigarette bin quantity detection method comprises the following specific steps:
[0015] S1, sending sound wave signals into the cigarette bin through the ultrasonic module, and regularly receiving ultrasonic signals returned from the top of the cigarette bin;
[0016] S2, the system control module uses the parameters of the long short-term memory network temperature compensation module to perform temperature compensation on the ultrasonic signal obtained in S1 and then calculates the distance value from the ultrasonic module to the top of the smoke placement;
[0017] S3, continuously record the distance value data obtained in S2, determine whether the output condition is met, and enter S4 when the condition is met;
[0018] S4, transmitting the calculated distance value to the display module to end the distance measurement process;
[0019] S5. Substitute the distance value obtained in S4 into the corresponding single cigarette bin height and the existing cigarette bin height respectively, compare the single cigarette bin height with the existing cigarette bin height, and complete the detection of the number of cigarette bins.
[0020] The specific steps of S2 include: measuring the actual distance data and the actual temperature data through the ultrasonic ranging module and the temperature sensor in the ultrasonic module, normalizing the actual distance data and the actual temperature data respectively, compensating the data through the long short-term memory network temperature compensation module, denormalizing the compensated data and outputting the compensated distance data.
[0021] The specific steps of S3 are:
[0022] S31, continue to record the distance value data obtained in S2, when the distance value data obtained in S2 reaches 18 results, arrange the array members in ascending order, take the 9th, 10th, 11th, and 12th results in the middle and add them to calculate the average value;
[0023] S32, taking the difference of the two adjacent average results, judging whether the difference is greater than 4 mm, if it is greater, entering S4 to output the calculated distance, and if it is less than 4 mm, returning to S41 to recalculate.
[0024] In S2, the distance from the ultrasonic module to the top of the smoke stack is the product of the time obtained by the timer and the speed of light.
[0025] The transmission state of the LSTM network is controlled by the forget gate, input gate, and output gate;
[0026] The forget gate is used to determine the information that needs to be forgotten from the unit state in the network, and selectively forget the information input by the previous node. The formula of the forget gate is as follows:
[0027] f t =δ(W f ·[h t-1 ,x t ]+b f )
[0028] Among them, F, the forget gate applies δ(x) to the weight matrix W f and the bias vector b f ,h t-1 As the last output signal, x t As the current input signal, h t-1 and x t The forgotten gate reads and outputs the vector f t , through [h t-1 ,x t ]The result of the linear transformation is mapped to [0,1] as the memory decay coefficient to decide whether to keep C t-1 Information in the unit's state;
[0029] The input gate is used to select and memorize the input information and determine the information that needs to be retained from the unit state. The formula of the input gate is as follows:
[0030] i t =δ(W i ·[h t-1 ,x t ]+b f )
[0031] C t =f t ×C t-1 +i t ×tanh(W i ·[h t-1 ,x t ]+b f )
[0032] Among them, i t is the input gate. After the input gate receives the data, the long short-term memory network state will update the information, so that the forget gate can discard the previous part of the information. t The information status is required;
[0033] Output gate, used to determine the information h that needs to be output t , the output unit o is determined by the activation function t After obtaining the judgment condition, the tan function is used to process it and mapped to a vector in the range of [-1,1]. Finally, the judgment condition is multiplied by the vector to obtain the output of the long short-term memory network. The calculation formula of the output gate is as follows:
[0034] o t =δ(W o ·[h t-1 ,x t ]+b o )
[0035] h t =o t ×tan(C t ).
[0036] The temperature model training steps of the long short-term memory network temperature compensation module are as follows:
[0037] A1. Establish a fully connected layer in the temperature model of the long short-term memory network temperature compensation module and set the number of neurons in the output layer to 1.
[0038] A2. After filtering the data corresponding to the sound speed at different temperatures using a filtering algorithm to obtain the filtered values, the data is normalized and reconstructed, and the data is divided into a training set and a test set in proportion;
[0039] A3, initializing the parameters of the long short-term memory network model, inputting the training set divided in A2 into the long short-term memory network model for training, and obtaining the long short-term memory network model after training;
[0040] A4. Combined with the test set, the root mean square error and calculation time are used to evaluate the performance of the model and obtain the accuracy of the prediction algorithm;
[0041] A5. Debug the model parameters through orthogonal experimental design, and obtain the optimal combination of parameters as the optimal solution for the output parameters based on the model prediction performance and calculation time.
[0042] Ultrasonic cigarette bin quantity detection system, including:
[0043] A system control module controls each module and circuit in the system, and the system control module executes the system to implement the ultrasonic cigarette bin quantity detection method described in any one of claims 1 to 5;
[0044] Ultrasonic module, used to emit sound waves to record the distance between the system and the object to be measured at each moment and return the distance value to the program to calculate the number of objects to be measured for display;
[0045] Display module, used to display real-time distance and count value;
[0046] The power supply circuit module is used to supply power to each circuit module.
[0047] The beneficial effects of the present invention are:
[0048] This solution introduces an LSTM neural network based on orthogonal parameter optimization to establish a mapping relationship between temperature and ultrasonic velocity to achieve the purpose of compensating for velocity measurement, and has strong adaptability. At the same time, because this solution adopts ultrasonic ranging technology, the optimized method prevents the accumulation of errors and causes counting deviations, and effectively improves the accuracy. Furthermore, this system only needs to record the empty warehouse distance and the height of the target object by pressing a button once before starting, and can realize the function of automatic detection and real-time display in subsequent measurements, making the operation easier and suitable for popularization. Furthermore, the advantage of this solution is that it can not only calculate the number of tobacco rods in the tobacco warehouse, but also automatically monitor in real time, which is convenient for intuitive statistics of the number, greatly reducing the workload of the staff, and has the advantages of simple operation, accuracy and reliability. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 This is the flow chart of ultrasonic distance measurement in this scheme;
[0050] Figure 2 is a circuit schematic diagram of the ultrasonic cigarette bin quantity detection system in this embodiment;
[0051] Figure 3 It is the operation flow chart of the ultrasonic cigarette bin quantity detection system;
[0052] Figure 4 This is the basic structure diagram of LSTM;
[0053] Figure 5 This is the LSTM model flow chart;
[0054] Figure 6 This is the temperature compensation schematic diagram of S2. DETAILED DESCRIPTION
[0055] The technical solution of the present invention is further described below through specific embodiments.
[0056] Example
[0057] like Figure 1 As shown, in this embodiment, during the height measurement process, the transmitting part of the ultrasonic module sends a sound wave signal into the cigarette chamber, and a timer is used for timing. Finally, the receiving part receives the returned ultrasonic signal, obtains the time parameter and transmits it to the system control module. The temperature compensation module of the long short-term memory network in the system control module, that is, the LSTM network temperature compensation module, compensates for the ultrasonic wave velocity at the current temperature, calculates the distance value of the product of the compensated sound wave velocity and the time parameter and transmits it to the display module to complete the detection.
[0058] like Figure 2 As shown, in this embodiment, the ultrasonic cigarette bin quantity detection system uses the STC89C52RC single-chip microcomputer as the system control module, and its specific connection method is shown in the figure. Among them, P1 is the LCD power supply module, which is used to power the LCD screen. P2 is the LCD signal line, which is used as the LCD screen communication interface for data display. P3 is UART, which is used as a serial communication interface to receive the current ultrasonic velocity parameters calculated by the temperature compensation algorithm of the LSTM model. P4 is the reset button, and its function is to reset the single-chip microcomputer by pressing the reset button and restart it. P5 is the backlight, which is used to provide brightness adjustment power for the LCD. P6 is the 5V port: 5V power supply for the ultrasonic sensor and temperature sensor. P7 is the interrupt button: press the interrupt button to interrupt the program process. P8 is the main power supply, which is used to provide power support for the system main power supply to maintain the system. P9 is the grounding port, which is used to ground the single-chip microcomputer. P10 is the sensor, which serves as the data receiving port of the ultrasonic sensor.
[0059] Preferably, the ultrasonic transducer of the ultrasonic module resonates at a frequency of 40KHz, and the module is provided with a 40KHz square wave generating circuit. In order to collect and process the temperature and obtain a more accurate temperature value, a DS18B20 temperature sensor module is designed for temperature collection, and its temperature measurement range is -55℃~+125℃, and the accuracy is ±0.5℃ in the range of -10℃~+85℃. The display module adopts an LCD1602 liquid crystal display, and the display of the measurement results uses a four-digit field code in the format of XXXX millimeters, and also uses a two-digit segment code to display the number of data. The power supply adopts a 9V DC power input, and after the voltage regulator tube, 5V and 3.3V power supplies are obtained for use by various circuits of the system.
[0060] like Figure 3 As shown, the operation example of the ultrasonic cigarette bin quantity detection system is as follows:
[0061] After the system is powered on, first set the timer 0 and external interrupt 0, clear the trigger and receiving pins of the ultrasonic module and display module, and clear the data of the first sector of the eeprom; in the while loop, first provide the SR04 ultrasonic ranging module in the ultrasonic module with a high-level pulse signal of more than 10us, and then it will automatically send out a series of ultrasonic waves. After reflection, it will immediately output a high level from the receiving pin. The duration of this level is the time from sending the sound wave to receiving the rebound sound wave. According to the product of the timer time and the speed of light, the distance value is stored in the array; when 18 results are stored, the array members are arranged in ascending order, and the 9th, 10th, 11th, and 12th results in the middle are added to calculate the average value. Since the measurement accuracy of the ultrasonic module sensor itself will have an error of 3 to 4mm, the difference between the two adjacent results is made. If the difference is less than 4mm, the last result is still output, otherwise the latest data is taken as the output; the output data is sent to the display and stored in the eeprom according to the interrupt triggering situation. When the displayed distance is stable, the user first long presses the interrupt key to enter and exit the data into the second sector of the eeprom as the total length, then puts in a cigarette box, and short presses the interrupt key when the display is stable again. At this time, the system compares the two lengths and subtracts them, and stores the difference as the height of a box of cigarettes in the first sector of the eeprom. After that, when the user puts in any box of cigarettes, the system automatically subtracts the total length value from the measured value and divides it by the height of a box of cigarettes to calculate the number of cigarette boxes and send it to the display, completing the automatic update of the number. If the user wants to record the difference, just short press the interrupt key again. When the system is powered off, since the eeprom can realize power-off storage, and only the first sector data is erased during initialization, the total length value can be kept all the time. Just put in a new cigarette box and short press it again.
[0062] Furthermore, compared with the traditional RNN network, the LSTM used in this solution introduces the concept of gated units, uses three gates and some computing nodes to form neurons, and replaces the activation function of the hidden state in the RNN. Through a large amount of learning in the LSTM network training set, the ultrasonic ranging error caused by the change in external temperature can be corrected, so that the compensated sound speed value can better approach the true value of the target, and improve the accuracy and sensitivity of the ranging module. The core of LSTM is the unit state, which stores the memory of the unit and converts the information from the beginning to the end. The unit state can remain unchanged between different time steps, and information can be selectively discarded or added. This enables the network to better capture long-term dependencies and effectively avoid gradient disappearance.
[0063] like Figure 4 As shown, the transmission state of the LSTM network is controlled by the input gate, forget gate and output gate;
[0064] The forget gate is used to determine the information that needs to be forgotten from the unit state in the network, and selectively forget the information input by the previous node. The formula of the forget gate is as follows:
[0065] f t =δ(W f ·[h t-1 ,x t ]+b f )
[0066] Among them, F, the forget gate applies δ(x) to the weight matrix W f and the bias vector b f ,h t-1 As the last output signal, x t As the current input signal, h t-1 and x t The forgotten gate reads and outputs the vector f t , decide whether to keep C t-1 Information in the unit's state;
[0067] The input gate is used to select and memorize the input information and determine the information that needs to be retained from the unit state. The formula of the input gate is as follows:
[0068] i t =δ(W i ·[h t-1 ,x t ]+b f )
[0069] C t =f t ×C t-1 +i t ×tanh(W i ·[ht-1 ,x t ]+b f )
[0070] Among them, i t is the input gate. After the input gate receives the data, the long short-term memory network state will update the information, so that the forget gate can discard the previous part of the information. t The information status is required;
[0071] The output gate is used to determine the information that needs to be output. The state of the output unit is determined by the excitation function. After the judgment condition is obtained, it is processed with the tan function and mapped to a vector in the range of [-1,1]. Finally, the judgment condition is multiplied by the vector to obtain the output of the long short-term memory network. The calculation formula of the output gate is as follows:
[0072] o t =δ(W o ·[h t-1 ,x t ]+b o )
[0073] h t =o t ×tan(C t )
[0074] Further, if Figure 5 As shown in FIG. 1 , this scheme uses the orthogonal method to systematically optimize the temperature model parameters based on the LSTM temperature compensation module. The temperature compensation algorithm based on the temperature model takes the temperature environment (T) as input and performs normalization.
[0075] like Figure 6 As shown, the temperature compensation module of LSTM in S2 first normalizes the actual distance collected by the ultrasonic ranging module and the temperature collected by the temperature sensor, and then the LSTM temperature compensation module denormalizes the predicted value and outputs the temperature compensated distance to realize LSTM network compensation, and the ultrasonic ranging parameters are used as output.
[0076] The above is a detailed description of an embodiment of the present invention, but the content is only a preferred embodiment of the present invention and cannot be considered to limit the scope of implementation of the present invention. All equivalent changes and improvements made within the scope of the present invention should still fall within the scope of the patent coverage of the present invention.
Claims
1. An ultrasonic cigarette bin quantity detection method, characterized in that: The specific steps include: S1, sending sound wave signals into the cigarette bin through the ultrasonic module, and regularly receiving ultrasonic signals returned from the top of the cigarette bin; S2, the system control module uses the parameters of the long short-term memory network temperature compensation module to perform temperature compensation on the ultrasonic signal obtained in S1 and then calculates the distance value from the ultrasonic module to the top of the smoke placement; S3, continuously record the distance value data obtained in S2, determine whether the output condition is met, and enter S4 when the condition is met; S4, transmitting the calculated distance value to the display module to end the distance measurement process; S5. Substitute the distance value obtained in S4 into the corresponding single cigarette bin height and the existing cigarette bin height respectively, compare the single cigarette bin height with the existing cigarette bin height, and complete the detection of the number of cigarette bins.
2. The ultrasonic cigarette bin quantity detection method according to claim 1, characterized in that: The specific steps of S2 include: measuring the actual distance data and the actual temperature data through the ultrasonic ranging module and the temperature sensor in the ultrasonic module, normalizing the actual distance data and the actual temperature data respectively, compensating the data through the long short-term memory network temperature compensation module, denormalizing the compensated data and outputting the compensated distance data.
3. The ultrasonic cigarette bin quantity detection method according to claim 1, characterized in that: The specific steps of S3 are: S31, continue to record the distance value data obtained in S2, when the distance value data obtained in S2 reaches 18 results, arrange the array members in ascending order, take the 9th, 10th, 11th, and 12th results in the middle and add them to calculate the average value; S32, taking the difference of the two adjacent average results, judging whether the difference is greater than 4 mm, if it is greater, entering S4 to output the calculated distance, and if it is less than 4 mm, returning to S41 to recalculate.
4. The ultrasonic cigarette bin quantity detection method according to claim 1, characterized in that: In S2, the distance from the ultrasonic module to the top of the smoke stack is the product of the time obtained by the timer and the speed of light.
5. The ultrasonic cigarette bin quantity detection method according to claim 1, characterized in that: The transmission state of the LSTM network is controlled by the forget gate, input gate, and output gate; The forget gate is used to determine the information that needs to be forgotten from the unit state in the network, and selectively forget the information input by the previous node. The formula of the forget gate is as follows: f t =δ(W f ·[h t-1 ,x t ]+b f ) Among them, F, the forget gate applies δ(x) to the weight matrix W f and the bias vector b f ,h t-1 As the previous output signal, x t As the current input signal, h t-1 and x t The forgotten gate reads and outputs the vector f t , through [h t-1 ,x t ]The result of the linear transformation is mapped to [0,1] as the memory decay coefficient to decide whether to keep C t-1 Information in the unit's state; The input gate is used to select and memorize the input information and determine the information that needs to be retained from the unit state. The formula of the input gate is as follows: i t =δ(W i ·[h t-1 ,x t ]+b f ) C t =f t ×C t-1 +i t ×tanh(W i ·[h t-1 ,x t ]+b f ) Among them, i t is the input gate. After the input gate receives the data, the long short-term memory network state will update the information, so that the forget gate can discard the previous part of the information. t The information status is required; Output gate, used to determine the information h that needs to be output t , the output unit o is determined by the activation function t After obtaining the judgment condition, the tan function is used to process it and mapped to a vector in the range of [-1,1]. Finally, the judgment condition is multiplied by the vector to obtain the output of the long short-term memory network. The calculation formula of the output gate is as follows: o t =δ(W o ·[h t-1 ,x t ]+b o ) h t =o t ×tan(C t )。 6. The ultrasonic cigarette bin quantity detection method according to claim 1, characterized in that: The temperature model training steps of the long short-term memory network temperature compensation module are as follows: A1. Establish a fully connected layer in the temperature model of the long short-term memory network temperature compensation module and set the number of neurons in the output layer to 1. A2. After filtering the data corresponding to the sound speed at different temperatures using a filtering algorithm to obtain the filtered values, the data is normalized and reconstructed, and the data is divided into a training set and a test set in proportion; A3, initializing the parameters of the long short-term memory network model, inputting the training set divided in A2 into the long short-term memory network model for training, and obtaining the long short-term memory network model after training; A4. Combined with the test set, the root mean square error and calculation time are used to evaluate the performance of the model and obtain the accuracy of the prediction algorithm; A5. Debug the model parameters through orthogonal experimental design, and obtain the optimal combination of parameters as the optimal solution for the output parameters based on the model prediction performance and calculation time.
7. Ultrasonic cigarette bin quantity detection system, characterized in that: include: A system control module controls each module and circuit in the system, and the system control module executes the system to implement the ultrasonic cigarette bin quantity detection method described in any one of claims 1 to 5; Ultrasonic module, used to emit sound waves to record the distance between the system and the object to be measured at each moment and return the distance value to the program to calculate the number of objects to be measured for display; Display module, used to display real-time distance and count value; The power supply circuit module is used to supply power to each circuit module.