Temperature compensation method and device for displacement sensor
By optimizing the backpropagation neural network using the dung beetle optimization algorithm, a high-performance BP neural network model was constructed, which solved the problems of zero-point drift and sensitivity shift of displacement sensors in high-temperature environments. This achieved efficient and robust temperature compensation, improving the stability and operating efficiency of magnetic levitation rotating machinery.
Patent Information
- Application Number
- CN202511916431.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-18
- Publication Date
- 2026-03-20
AI Technical Summary
In magnetic levitation bearing rotor systems, displacement sensors experience zero-point drift and sensitivity shift under high-temperature environments, leading to increased measurement errors and affecting the stability and operating efficiency of magnetic levitation rotating machinery. Furthermore, traditional compensation methods suffer from poor model adaptability and insufficient compensation accuracy when dealing with complex nonlinear temperature drift.
The Dung Beetle Optimization Algorithm (DBO-BP) is used to optimize the backpropagation neural network. By constructing a high-performance BP neural network model, the initial weights and thresholds are optimized using the Dung Beetle Optimization Algorithm, and the model is trained using a composite loss function to achieve temperature compensation of the displacement sensor.
It significantly improves the measurement stability and accuracy of displacement sensors over a wide temperature range, enhances the operating efficiency and lifespan of magnetically levitated rotating machinery, and reduces the risk of equipment vibration.
Smart Images

Figure CN121706831A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to a temperature compensation method and device of a displacement sensor, and belongs to the technical field of temperature compensation of displacement sensors. BACKGROUND
[0002] Magnetic levitation rotating machinery (such as magnetic levitation blowers, magnetic levitation air compressors, magnetic levitation vacuum pumps, etc.) uses active magnetic levitation bearing technology and high-speed permanent magnet synchronous motor technology. It realizes the non-contact suspension of the rotating shaft through the controllable electromagnetic force of the magnetic levitation bearing system, avoids mechanical wear and tear, and improves the operating efficiency. At the same time, the high-speed permanent magnet synchronous motor directly drives the impeller, reducing transmission loss. This integrated design of the blower is also equipped with an intelligent control system, which can realize remote monitoring and data transmission. Due to its energy-saving, high-efficiency, low-noise, and no need for lubrication, the magnetic levitation blower has been widely used in many fields such as sewage treatment, chemical industry, and papermaking.
[0003] In the magnetic levitation bearing rotor system, the displacement sensor monitors the position and state of the rotor in real time, providing accurate feedback data for the system, and is a key component to ensure the stable operation and efficient operation of the magnetic levitation blower. However, the high-temperature environment in industrial sites poses a great challenge to displacement sensors. When the operating temperature changes, the internal component parameters of the displacement sensor will change, causing zero drift and sensitivity deviation, resulting in a significant increase in measurement error. This not only interferes with the precise control of the rotor by the magnetic levitation bearing, increasing the risk of equipment vibration, but also may cause system failure, reducing the operating efficiency and service life of the magnetic levitation rotating machinery, and even affecting the stability and safety of the entire industrial production process.
[0004] For an eddy current displacement sensor in a wide temperature range and high-precision application scenario, the traditional compensation method generally has poor model adaptability and insufficient compensation accuracy when dealing with complex nonlinear temperature drift.
[0005] Therefore, there is an urgent need for an efficient and robust temperature drift compensation method for displacement sensors. SUMMARY
[0006] In view of the deficiencies of the prior art, the application proposes a displacement sensor temperature compensation method based on dung beetle optimization algorithm (DBO) optimized back propagation (BP) neural network. Through the pre-optimization of the dung beetle optimization algorithm, a set of network initial parameters close to the global optimum is obtained, and a high-performance BP neural network compensation model is constructed, effectively improving the measurement stability and precision of the displacement sensor in a wider temperature range, providing an efficient and robust new solution to the temperature drift problem.
[0007] Terminology: 1. Dung Beetle Optimizer (DBO) is a swarm intelligence optimization algorithm inspired by the natural behaviors of dung beetles, such as rolling balls, foraging, and reproduction. It can be used to solve complex problems such as path planning and parameter optimization.
[0008] 2. Back Propagation Neural Network (BPNN) is a multi-layer feedforward neural network architecture based on the error backpropagation algorithm. It consists of an input layer, a hidden layer, and an output layer. It calculates the output result through forward propagation and adjusts the weight parameters by backpropagating the error gradient, effectively solving the modeling problem of non-linear complex problems.
[0009] The technical solution of the present application is: In the first aspect, the present application provides a temperature compensation method for displacement sensors, which comprises: Data acquisition: synchronously acquire the original output signal U of the displacement sensor x , the ambient temperature signal U t , and the reference displacement value U x0 calibrated under standard conditions to obtain the target compensation value U b ; Model construction: construct a BP neural network model, the input of which is the original output signal U x and the ambient temperature signal U t , and the output is the displacement signal U x0' compensated by temperature and the predicted compensation value U b' ; Parameter optimization: use the Dung Beetle Optimization algorithm to optimize the initial weight and threshold combination of the BP neural network model, so as to minimize the error of the BP neural network model; Model training: train the optimized BP neural network model; Compensation output: input the real-time collected original output signal U of the displacement sensor x and its corresponding ambient temperature signal U t to the trained BP neural network model, output the displacement signal U x0' compensated by temperature and the predicted compensation value U b' , and generate the final compensation result based on U x0' and / or U b' .
[0010] According to the preferred embodiment of the present application, in the data acquisition process: the target compensation value U b is calculated based on the difference between the reference displacement value U x0 and the original output signal U x .
[0011] According to a preferred embodiment of the present invention, in the compensation output process, the method for generating the final compensation result is as follows: the original output signal U of the displacement sensor acquired in real time is used to generate the final compensation result. x The predicted compensation value U output by the model b' The two signals are added together to obtain the final displacement signal after temperature compensation.
[0012] According to a preferred embodiment of the present invention, in the compensation output process, the method for generating the final compensation result is as follows: directly using the temperature-compensated displacement signal U output by the model. x0' As the final displacement signal.
[0013] According to a preferred embodiment of the present invention, during the model training process, the loss function of the BP neural network model is a composite loss function, which simultaneously considers a first error and a second error; the first error is the displacement signal U after temperature compensation. x0' With reference displacement value U x0 The error between the two; the second error is the predicted compensation value U. b' The calculated target compensation value U b The error between them.
[0014] According to a preferred embodiment of the present invention, the composite loss function Loss is expressed as: Loss=α×MSE(U x0' U x0 )+β×MSE(U b' U b (V), In equation (V), MSE(·) is the mean square error function, α represents the weighting coefficient of the first error, and β represents the weighting coefficient of the second error.
[0015] According to a preferred embodiment of the present invention, the optimization of the initial weight and threshold combination of the BP neural network model using the dung beetle optimization algorithm to minimize the error of the BP neural network model specifically includes: All initial weights and threshold combinations of the BP neural network model are mapped to the positions of individuals in the dung beetle population, where each individual position represents a complete set of candidate solutions for the initial parameters of the BP neural network; In each iteration, individuals in the population update their positions in parallel according to their corresponding behavioral rules. The main behaviors include: rolling ball behavior, dancing behavior, reproductive behavior, foraging behavior, and stealing behavior. All updated individuals are merged to form a new population. The fitness of each individual's position is calculated using a composite loss function based on the BP neural network model. The global best position and the global worst position are then updated based on the fitness. When the termination condition is met, the final global optimal position is decoded into a set of optimal initial weights and thresholds as the optimal combination of initial parameters to minimize the error of the BP neural network model.
[0016] In a second aspect, the present invention provides a temperature compensation device for a displacement sensor, comprising: The data acquisition module is used to receive the raw output signal from the displacement sensor and the ambient temperature signal. The compensation processing module is used to output a temperature-compensated displacement signal and a displacement compensation value based on the original output signal and the ambient temperature signal. The compensation processing module includes a trained neural network model, which is obtained by optimizing the initial parameters of the BP neural network using the dung beetle algorithm and then training it with a composite loss function. The composite loss function simultaneously minimizes the first error between the temperature-compensated displacement signal and the reference displacement value, and the second error between the displacement compensation value and the target compensation value. The result generation module is used to generate the final compensation result based on the temperature-compensated displacement signal and / or the displacement compensation value.
[0017] Thirdly, the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method when executing the program.
[0018] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the method described thereon.
[0019] The beneficial effects of this invention are as follows: 1. This invention proposes a temperature compensation method for displacement sensors based on the Dung Beetle Optimization Algorithm (DBO-BP) for optimizing a backpropagation neural network. The emerging Dung Beetle Optimization Algorithm is introduced to perform a global optimal search for the initial weights and thresholds of the BP neural network, thereby constructing a high-performance BP neural network model. The DBO algorithm, with its unique multi-dimensional search strategies such as rolling, dancing, breeding, and stealing, can efficiently avoid local optima, significantly overcoming the inherent drawbacks of traditional BP neural networks, including sensitivity to initial parameters, slow convergence speed, and susceptibility to local minima.
[0020] 2. In this invention, the BP neural network model uses the original output signal of the displacement sensor and the real-time ambient temperature signal as input, and is trained using the calibrated reference displacement value and target compensation value as learning objectives. A composite loss function is set in the BP neural network model, allowing the BP neural network to learn both the final result and the compensation mechanism simultaneously. This enables the network to learn laws that are closer to physical meaning, thereby significantly improving the robustness and stability of the neural network model in different temperature ranges, and ultimately enhancing the compensation accuracy. Attached Figure Description
[0021] Figure 1 This is a flowchart illustrating the temperature compensation method for displacement sensors based on the DBO algorithm to optimize the BP neural network in an embodiment of the present invention.
[0022] Figure 2 This is a schematic diagram of the BP neural network model in an embodiment of the present invention.
[0023] Figure 3 This is a schematic diagram illustrating the dung beetle's foraging area selection strategy in an embodiment of the present invention.
[0024] Figure 4 This is a schematic diagram illustrating a temperature compensation system for a displacement sensor in an embodiment of the present invention. Detailed Implementation
[0025] The following illustrations will disclose several embodiments of this application, providing a clear and complete description of the technical solution of the present invention, which constitutes a part of this application. The accompanying drawings are used to provide a further understanding of the present invention. The illustrative embodiments and descriptions of the present invention are used to explain the present invention and do not constitute an improper limitation of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] The technical solutions of the various embodiments of the present invention can be combined with each other, but only if they are based on the ability of a person skilled in the art to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such combination of technical solutions does not exist and is not within the scope of protection claimed by the present invention.
[0027] A method for temperature compensation of a displacement sensor, such as Figure 1 As shown, the method includes: Data acquisition: Synchronously acquire the raw output signal U of the displacement sensor. x Ambient temperature signal U t and the reference displacement value U calibrated under standard conditions x0 Obtain the target compensation value U b ; U xUsed to reflect sensor output changes caused by temperature; U t Used to quantify the current ambient temperature state; the reference displacement value U is obtained by actual calibration using high-precision measuring equipment under standard ambient temperature conditions. x0 , which serves as the ideal reference true value for the sensor output.
[0028] Model Construction: Construct a BP neural network model, whose input is the original output signal U. x and ambient temperature signal U t The output is a temperature-compensated displacement signal U. x0' and predicted compensation value U b' ; Parameter optimization: The initial weights and thresholds of the BP neural network model are optimized using the dung beetle optimization algorithm to minimize the error of the BP neural network model; Model training: Train the optimized BP neural network model; Compensated Output: The raw output signal from the displacement sensor acquired in real time, along with its corresponding ambient temperature signal, is input into the trained BP neural network model, which outputs a temperature-compensated displacement signal U. x0' and predicted compensation value U b' and based on U x0' and / or U b' Generate the final compensation result.
[0029] In one exemplary embodiment, during the data acquisition process: based on the reference displacement value U x0 With the original output signal U x The difference is used to calculate the target compensation value U. b .
[0030] In an exemplary embodiment, during the compensation output process, the method for generating the final compensation result is as follows: The original output signal U from the displacement sensor, acquired in real time... x The predicted compensation value U output by the model b' The two signals are added together to obtain the final displacement signal after temperature compensation.
[0031] In an exemplary embodiment, during the compensation output process, the final compensation result is generated by directly using the temperature-compensated displacement signal U output by the model. x0' As the final displacement signal.
[0032] In one exemplary embodiment, the process of building and training a BP neural network model specifically includes: The input to the model is the original output signal U. x and ambient temperature signal U tThe output is a temperature-compensated displacement signal U. x0' and predicted compensation value U b' We constructed sample pairs with clear physical meaning, laying the data foundation for the neural network to learn the temperature-displacement error mapping relationship.
[0033] In this embodiment, as Figure 2 As shown, this temperature compensation model employs a typical three-layer BP neural network model, comprising an input layer, a single hidden layer, and an output layer connected sequentially; the data transmission process within the network is as follows: 1) Hidden layer processing: Input signal x i First, the signal is passed to the hidden layer, where the output h of the j-th neuron is... j Including the weighted sum w of all input signals received by it ji x i Add a bias term β j Finally, it is generated by nonlinear transformation through the activation function g(·), as shown in formula (Ⅰ): h j =g(∑w ji ·x i+ β j (Ⅰ), x i This represents a two-dimensional input, including the sensor's raw output signal U. x and ambient temperature signal U t The vector formed; 2) Output layer processing: The output h of the hidden layer j As the input to the output layer, the output layer is designed with two neurons, each used to generate two output quantities with clear physical meaning. The first neuron outputs the temperature-compensated displacement signal U. x0' This output is a direct estimate of the true displacement by the model, serving as the final result after compensation. The second neuron outputs the displacement compensation value U. b' This output is the model prediction, and the original displacement output signal U needs to be adjusted to compensate for the temperature effect. x The compensation amount to be corrected satisfies the relationship: U x0' ≈U x +U b' ; The calculation process for each output neuron is as follows: For output U x0' (i.e., the first output neuron, n=1): U x0' =y1=f(∑w 1j ·h j +θ1) (Ⅱ), In formula (II), w 1j ∑ represents the weight connecting the j-th neuron in the hidden layer to the first output neuron, ∑ represents the weighted summation of the outputs of all neurons j in the hidden layer, θ1 is the bias term of the first output neuron, and f(·) is the activation function of the output layer. For output U b' (i.e., the second output neuron, n=2): U b' =y2=f(∑w 2j ·h j +θ2) (Ⅲ), In equation (Ⅲ), w 2j θ represents the weight connecting the j-th neuron in the hidden layer to the second output neuron, θ2 represents the bias term of the second output neuron, and the activation function f(·) is the same as that of the first output neuron.
[0034] The combined expression of equations (II) and (III) is as follows: y n =f[∑(w nj ·h j )+θ n ], n=1,2 (Ⅳ), In equation (Ⅳ), w nj ·h j θ represents the weight connecting the j-th neuron and the n-th output neuron in the hidden layer. n This represents the bias term of the nth output neuron; y n Let f(·) represent the output of the nth neuron, and f(·) represent the activation function. 3) Design of composite loss function In each forward propagation, the network output y1 (i.e., U) is obtained. x0' ) and y2 (i.e., U b' After that, they will be compared with the expected true value (i.e., the target output U). x0 and U b To ensure both the accuracy of the final output and the reasonableness of the compensation value, this invention defines a composite loss function. The loss function of the BP neural network model is a composite loss function, which considers both the first error and the second error; the first error is the displacement signal U after temperature compensation. x0' With reference displacement value U x0 The error between the two; the second error is the predicted compensation value U. b' The calculated target compensation value U b The error between them.
[0035] In an exemplary embodiment, the composite loss function Loss considers the errors of both outputs simultaneously, combining the first error with the second error in a weighted manner. Loss is defined as follows: Loss=α×MSE(y1,U x0 )+β×MSE(y2, U b )=α×MSE(U x0' U x0 )+β×MSE(U b' U b (V), In equation (V), MSE(U) x0' U x0 The first error (MSE) measures the difference between the compensated displacement output by the network and the true reference displacement, and is a direct reflection of the compensation accuracy; b' ,Ub) is the second error, which measures the difference between the compensation value predicted by the network and the actual calculated compensation value, ensuring that the network has learned the correct compensation rules. α and β are preset weighting coefficients used to balance the contribution ratio of the two error terms to the total loss.
[0036] During training, the backpropagation algorithm plays a crucial role. The BP neural network uses gradient descent to adjust the weights and thresholds of each layer, layer by layer, along the negative gradient of the error function, based on the error between the forward propagation calculation and the desired output. This process gradually optimizes the network, improving accuracy and stability.
[0037] In an exemplary embodiment, the optimization of the initial weight and threshold combination of the BP neural network model using the dung beetle optimization algorithm to minimize the error of the BP neural network model specifically includes: The BP neural network structure to be optimized is determined to contain 2 input neurons, 4 hidden layer neurons, and 2 output neurons, totaling 22 trainable parameters. These parameters are combined into a parameter vector in hierarchical order, specifically including: 8 weights from the input layer to the hidden layer [w 11 , w 12 , w 13 , w 14 , w 21 , w 22 , w 23 , w 24 The hidden layer has four biases [β1, β2, β3, β4], and the hidden layer has eight weights [w`] leading to the output layer. 11 , w` 12 , w` 13 , w` 14 , w` 21 , w` 22 , w` 23 , w` 24The initial weights and thresholds, along with the two biases [θ1, θ2] of the output layer, are combined with all parameters in a fixed order to form a vector that maps to the position of an individual in the dung beetle population. Each individual position represents a complete set of candidate solutions for the initial parameters of the BP neural network. The training and optimization process follows these rules: In each iteration, individuals in the population update their positions in parallel according to their corresponding behavioral rules. The main behaviors include: rolling ball behavior, dancing behavior, reproductive behavior, foraging behavior, and stealing behavior. The specific rules for these behaviors are as follows: 1) Dung beetle rolling ball behavior During the rolling of the dung ball, the dung beetle utilizes not only the sun but also celestial cues such as moonlight and polarized light to propel the ball forward in a straight line. To more realistically reproduce its navigation and movement characteristics, the dung beetle's direction of movement needs to be defined throughout the search space. This process can be numerically simulated using the model shown in equation (VI): x i (t+1)=x i (t)+α1×k×x i (t-1)+b×Δx (VI), Δx=|x i (t)-x worst | (Ⅶ), In equations (VI) and (VII), t represents the current iteration number, and x i (t) represents the position information of the i-th dung beetle in the tth iteration, k ∈ (0, 0.2] represents the deviation coefficient value, b is a random number taking values between (0, 1), α1 is the natural coefficient, which takes values of -1 (with deviation) or 1 (without deviation), Δx represents the difference between the current position and the worst position, x worst Indicates the worst-case position globally; 2) Dung beetle dancing behavior When encountering obstacles, dung beetles will use dancing to find a new direction. Once a new direction is determined, the dung beetle will continue rolling its dung ball. The position update formula at this time is as shown in equation (VIII): x i (t+1)=tan(θ)×|x i (t)-x i (t-1)| (VIII), In equation (VIII), θ is the deflection angle, and θ takes the value [0,π]. When θ is 0, π / 2 or π, the dung beetle does not update its position.
[0038] 3) Dung beetle reproductive behavior Once the dung beetle finds a suitable location, it will conceal itself and begin the egg-laying process. This process involves a reproductive boundary selection strategy, and the specific reproductive area is determined based on the calculation results of equations (IX) and (X): Lb * =MAX(X * ×(1-R),Lb) (Ⅸ), Ub * =MIN(X * ×(1+R),Ub) (Ⅹ), In equations (IX) and (X), X * Lb represents the local optimum. * and Ub * These represent the upper and lower boundaries of the spawning search area, respectively, where R = 1 - t / T. max T max The maximum number of iterations is given by Lb and the lower bound of the optimal solution, respectively. In each iteration, only one egg is produced in the rolling ball, making it a nursery ball. The position of the nursery ball is updated with the number of iterations as follows: B i (t+1)=X * +b1×(B i (t)-Lb * )+b2×(B i (t)-Ub * ) (XI), In equation (XI), B i (t) represents the position of the i-th egg in the t-th iteration; b1 and b2 are both independent random vectors of 1×D dimensions; 4) Dung beetle foraging behavior Conceptual model of dung beetle foraging area selection strategy, such as Figure 3 As shown. After hatching, dung beetle larvae are guided to forage by defining an optimal foraging area. The dung beetles participating in foraging can locate the globally optimal position and thus carry out global search behavior. Lb b =MAX(X b ×(1-R),Lb) (Ⅻ), Ub b =MIN(X b ×(1+R),Ub) (XIII), In equations (XII) and (XIII), X b For the globally optimal position, Ub b and Lb b This represents the upper and lower limits of the optimal foraging area; The location of dung beetle larvae during foraging is updated as follows: xi (t+1)=x i (t)+C1×(x i (t)-Lb b )+C2×(x i (t)-Ub b (XIV), In equation (XIV), C1 is a random number that follows a normal distribution, i.e., C1 ~ N(0,1); C2 is a 1×D random vector belonging to the range (0,1); 5) Dung beetle theft Within the population, some dung beetles will steal dung balls from other dung beetles; the position update for this stage is: x i (t+1)=X b +S×g×(|x i (t)-X * |+|x i (t)-X b |) (XV), In formula (XV), X b For the globally optimal position, x i (t) represents the position of the i-th thief in the t-th iteration; g is a random vector whose values follow a normal distribution; S is a preset step size constant, which can be set to 1 for example; All updated individuals are merged to form a new population. The fitness of each individual's position is calculated using a composite loss function based on the BP neural network model. The global best position and the global worst position are then updated based on the fitness. When the termination condition is met, such as reaching the maximum number of iterations, the final globally optimal position is decoded into a set of optimal initial weights and thresholds for output.
[0039] The DBO-BP model employs a high-precision dung beetle algorithm to optimize its initial connection weights and neuron thresholds. The key objective of this optimization is to find a set of optimal parameters that minimizes the initial output error of the network. This allows the BP neural network to move beyond traditional random initialization and begin training from a superior starting point closer to the global optimum. The trained DBO-BP model can then be embedded into the processor of a sensor system to achieve real-time, high-precision temperature compensation during measurement.
[0040] This embodiment provides a temperature compensation device for a displacement sensor, such as... Figure 4 As shown, it includes: The data acquisition module is used to receive the raw output signal from the displacement sensor and the ambient temperature signal. The compensation processing module is used to output a temperature-compensated displacement signal and a displacement compensation value based on the original output signal and the ambient temperature signal. The compensation processing module includes a trained neural network model, which is obtained by optimizing the initial parameters of the BP neural network using the dung beetle algorithm and then training it with a composite loss function. The composite loss function simultaneously minimizes the first error between the temperature-compensated displacement signal and the reference displacement value, and the second error between the predicted compensation value and the target compensation value. The result generation module is used to generate the final compensation result based on the temperature-compensated displacement signal and / or the displacement compensation value.
[0041] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described above.
[0042] This embodiment provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described thereon.
[0043] The DBO algorithm simulates various natural behaviors of dung beetles to efficiently explore and develop the solution space, ultimately obtaining a globally approximate optimal parameter combination that minimizes the network error function. After training and parameter optimization using a DBO-BP hybrid model, a model is established to study the effect of temperature on voltage U. t With the original output U x to the actual displacement U x0 Nonlinear compensation mapping between them.
[0044] The foregoing description illustrates and describes preferred embodiments of this application. However, as previously understood, this application is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. It can be used in various other combinations, modifications, and environments, and can be altered within the scope of the conception herein through the foregoing teachings or techniques or knowledge in related fields. Any modifications and variations made by those skilled in the art that do not depart from the spirit and scope of this application should be within the protection scope of the appended claims.
Claims
1. A temperature compensation method for a displacement sensor, characterized in that, include: Data acquisition: Synchronously acquire the raw output signal U of the displacement sensor. x Ambient temperature signal U t And at the calibrated reference displacement value U x0 Obtain the target compensation value U b ; Model Construction: Construct a BP neural network model, whose input is the original output signal U. x and ambient temperature signal U t The output is a temperature-compensated displacement signal U. x0' and predicted compensation value U b' ; Parameter optimization: The initial weights and thresholds of the BP neural network model are optimized using the dung beetle optimization algorithm to minimize the error of the BP neural network model; Model training: Train the optimized BP neural network model; Compensation output: The original output signal U of the displacement sensor acquired in real time x and its corresponding ambient temperature signal U t The input is fed into a trained BP neural network model, and the output is a temperature-compensated displacement signal U. x0' and predicted compensation value U b' and based on U x0' and / or U b' Generate the final compensation result.
2. The temperature compensation method for a displacement sensor according to claim 1, characterized in that, During data acquisition: based on the reference displacement value U x0 With the original output signal U x The difference is used to calculate the target compensation value U. b .
3. The temperature compensation method for a displacement sensor according to claim 1, characterized in that, During the compensation output process, the method for generating the final compensation result is as follows: The original output signal U from the displacement sensor, acquired in real time... x The predicted compensation value U output by the model b' The two signals are added together to obtain the final displacement signal after temperature compensation.
4. The temperature compensation method for a displacement sensor according to claim 1, characterized in that, During the compensation output process, the final compensation result is generated by directly using the temperature-compensated displacement signal U output by the model. x0' As the final displacement signal.
5. The temperature compensation method for a displacement sensor according to claim 2, characterized in that, During model training, the loss function of the BP neural network model is a composite loss function, which considers both the first error and the second error; the first error is the displacement signal U after temperature compensation. x0' With reference displacement value U x0 The error between the two; the second error is the predicted compensation value U. b' The calculated target compensation value U b The error between them.
6. The temperature compensation method for a displacement sensor according to claim 5, characterized in that, The composite loss function Loss is expressed as: Loss=α×MSE(U x0' ,IN x0 )+β×MSE(U b' ,IN b ) (Ⅴ), In equation (V), MSE(·) is the mean square error function, α represents the weighting coefficient of the first error, and β represents the weighting coefficient of the second error.
7. The temperature compensation method for a displacement sensor according to claim 1, characterized in that, The optimization of the initial weights and thresholds of the BP neural network model using the dung beetle optimization algorithm to minimize the error of the BP neural network model specifically includes: All initial weights and threshold combinations of the BP neural network model are mapped to the positions of individuals in the dung beetle population, where each individual position represents a complete set of candidate solutions for the initial parameters of the BP neural network; In each iteration, individuals in the population update their positions in parallel according to their corresponding behavioral rules. The main behaviors include: rolling ball behavior, dancing behavior, reproductive behavior, foraging behavior, and stealing behavior. All updated individuals are merged to form a new population. The fitness of each individual's position is calculated using a composite loss function based on the BP neural network model. The global best position and the global worst position are then updated based on the fitness. When the termination condition is met, the final global optimal position is decoded into a set of optimal initial weights and thresholds as the optimal combination of initial parameters to minimize the error of the BP neural network model.
8. A temperature compensation device for a displacement sensor, used to implement the temperature compensation method according to any one of claims 1-7, characterized in that, include: The data acquisition module is used to receive the raw output signal from the displacement sensor and the ambient temperature signal. The compensation processing module is used to output a temperature-compensated displacement signal and a displacement compensation value based on the original output signal and the ambient temperature signal. The compensation processing module includes a trained neural network model, which is obtained by optimizing the initial parameters of the BP neural network using the dung beetle algorithm and then training it with a composite loss function. The composite loss function simultaneously minimizes the first error between the temperature-compensated displacement signal and the reference displacement value, and the second error between the displacement compensation value and the target compensation value. The result generation module is used to generate the final compensation result based on the temperature-compensated displacement signal and / or the displacement compensation value.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method described in any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-7.