AD key adaptive compensation correction method and device, computer equipment and storage medium

By adopting the AD button adaptive compensation and correction method in the key detection system, combined with PID control, PSO particle swarm optimization, LSTM network and SOGI-FLL signal decoupling technology, the misjudgment rate and missed decision rate of key detection in complex environments are solved. It solves the problem of high adaptability and accuracy of key recognition.

CN119356077AInactive Publication Date: 2025-01-24深圳市云希谷科技有限公司
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202411930787.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-01-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing key detection systems have problems with high misjudgment rates and misjudgment rates when facing complex environments, especially in environments of noise, interference and frequency variations, and traditional methods are difficult to achieve high adaptability and accuracy.

Method used

Adopt AD button adaptive compensation and correction method, collect button signals in real time and perform preprocessing, use PID control loop and PSO particle swarm to optimize PID parameters, combine with long and short-term memory network to make final correction of the target threshold, and use SOGI-FLL to digitally The signal is decoupled and a key state model is constructed to obtain the real-time key state.

Benefits of technology

It significantly improves the reliability and response accuracy of the keys, enhance the adaptability and stability of the system, and reduce the misjudgment and missed judgment rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119356077A_ABST
    Figure CN119356077A_ABST
Patent Text Reader

Abstract

The invention discloses an AD key adaptive compensation correction method and device, computer equipment and a storage medium, and relates to the technical field of intelligent control and signal processing, and the method comprises the steps: collecting a key signal in real time, converting the key signal into a digital signal, and carrying out the preprocessing; a PID control loop is used for preliminarily and dynamically adjusting a target threshold value, and parameters of a PID controller are optimized through combination of a PSO particle swarm and improved ITAE; outputting an error correction value by using the long short-term memory network to carry out final correction on the target threshold value; and performing signal decoupling on the digital signal by using SOGI-FLL, and constructing a key state model to obtain a real-time key state. A PID control loop and a PSO particle swarm optimization PID parameter are utilized, a target threshold value can be dynamically adjusted, the stability and accuracy of a system in various environments are ensured, the target threshold value is corrected through an LSTM neural network, the defects of a traditional method are effectively overcome, an SOGI-FLL is adopted to decouple digital signals, higher harmonic components are accurately analyzed, and the accuracy of the system is improved. And the reliability and the response precision of key identification are obviously improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of intelligent control and signal processing technology, in particular to an AD key adaptive compensation correction method, device, computer equipment and storage medium. Background Art

[0002] With the continuous improvement of the intelligence level of electronic devices, buttons, as one of the main input methods of human-computer interaction, have been widely used in various consumer electronics, smart homes, automotive electronics and other fields. However, traditional button detection technology has certain limitations in the application process. Especially under the influence of factors such as signal noise, environmental interference and dynamic changes in button status, the accuracy and stability of button recognition are often difficult to guarantee. In order to solve this problem, many studies have proposed button detection methods based on signal processing and intelligent algorithms, trying to improve the adaptability and robustness of button detection systems. In recent years, with the development of digital signal processing technology, signal analysis methods based on sinusoidal wave decoupling (SOGI) algorithm have gradually become a research hotspot in the field of button signal processing. SOGI algorithm This method can effectively extract the fundamental and harmonic components of the key signal from the noisy signal, especially in solving the problems of frequency change and signal interference. In addition, PID control loops are also widely used in threshold adjustment and error correction, but traditional PID control is difficult to fully adapt to changes in complex dynamic environments, especially in the case of variable external interference and key input frequency, which may lead to high misjudgment and missed judgment rates. In order to further improve the accuracy of key detection, the long short-term memory network (LSTM) has received more and more attention as a deep learning model that can process time series data. LSTM can provide important support for the dynamic prediction of key status and optimize the detection accuracy of traditional methods by effectively capturing the long-term dependency of key signals.

[0003] Although the existing technology has achieved many results in key signal processing and detection, there are still some shortcomings. The existing key detection method based on signal decoupling usually relies on a fixed threshold to judge the key state, which makes the system lack sufficient adaptability to changes in the external environment. In some environments with strong noise interference or irregular input, the recognition accuracy and stability of key signals are often difficult to be effectively guaranteed. Although the traditional PID control loop can correct the error, its parameter setting usually relies on manual experience, and it is difficult to adjust and adapt to the dynamic changes of the key state in real time, resulting in insufficient accuracy of threshold adjustment, further affecting the recognition effect of the key. Although the LSTM model has a good performance in the prediction of time series signals, it may be limited by insufficient training data and poor model generalization ability in practical applications, making it difficult to effectively deal with complex and irregular key signal changes. The limitations of the existing technology in these aspects make the traditional key detection system often show a high misjudgment rate and missed judgment rate when facing a complex environment. It is urgent to improve the adaptability and accuracy of the system through innovative technical methods. Summary of the invention

[0004] In view of the above existing problems, the present invention is proposed.

[0005] Therefore, the present invention provides an AD key adaptive compensation correction method to solve the problems of insufficient adaptability, threshold adjustment lag and misjudgment and missed judgment in the prior art, especially in a complex environment with noise, interference and frequency changes.

[0006] In order to solve the above technical problems, the present invention provides the following technical solutions: In a first aspect, the present invention provides an AD key adaptive compensation correction method, which comprises: Real-time acquisition of key signals, converting them into digital signals and preprocessing them; The PID control loop is used to perform preliminary dynamic adjustment of the target threshold and the parameters of the PID controller are optimized by PSO particle swarm combined with improved ITAE; Use the long short-term memory network to output the error correction value to make a final correction to the target threshold; Use SOGI-FLL to decouple digital signals and build a key state model to obtain the real-time key state.

[0007] As a preferred solution of the AD key adaptive compensation correction method of the present invention, the real-time acquisition of key signals and conversion into digital signals includes: According to business needs, select capacitive buttons and design the overall circuit diagram and signal sampling circuit; The overall circuit diagram of the design includes connecting one terminal of the capacitive button to a 5V power supply and the other terminal to a The pull-up resistor is connected to the GPIO input terminal and grounded. When the capacitor button is pressed, the GPIO input terminal is grounded to form a low-level signal. A TVS diode is added to the GPIO input terminal for overvoltage protection. The cathode terminal is connected to the GPIO input terminal. The reverse working voltage of the TVS diode is selected to be 5.5V to 6V. A 10nF decoupling capacitor is added between the input terminal and the ground. The signal sampling circuit includes a capacitor connected in series with the capacitor key input terminal and the GPIO input terminal. and 1 The low-pass filter of the capacitor connects the input of the operational amplifier to the The resistor is connected to the key signal, and the output terminal is connected through The feedback resistor is connected to the input terminal, and the output signal is transmitted to the microcontroller through the output terminal of the operational amplifier; Configure the sampling duration of the digital converter ADC. When a key is pressed, the key signal is collected and transmitted to the analog-to-digital converter ADC through the signal sampling circuit to be converted into a digital signal. Set the target threshold, collect digital signals greater than the target threshold and transmit them to the microcontroller.

[0008] As a preferred solution of the AD key adaptive compensation correction method of the present invention, the preprocessing includes: Use low pass filters and band pass filters to eliminate digital signals The high-frequency noise in the digital signal After normalization, the amplitude range of the processed digital signal is between [-1,1]; The normalized digital signal Perform discrete Fourier transform to obtain digital signal The spectrum of the calculated frequency spectrum is extracted, and the harmonic components higher than the fundamental frequency are taken as the higher harmonic components, and the amplitude and phase information of the higher harmonic components are extracted from the spectrum.

[0009] As a preferred solution of the AD key adaptive compensation correction method of the present invention, the method of using a PID control loop to perform preliminary dynamic adjustment of the target threshold value includes: Calculate the difference between the current digital signal and the target threshold , the formula is: in, Indicates the target threshold of the digital signal currently set; According to the difference Construct a complete PID controller and calculate the target threshold adjustment L. The formula is: Where L represents the final target threshold adjustment value output by the PID controller. , , Represent the proportional gain, integral gain and differential gain respectively, a is the derivative operator, which represents the error Perform differentiation, d represents a small variable of the time variable t; According to the obtained target threshold adjustment amount L, the current target threshold is dynamically updated.

[0010] As a preferred solution of the AD button adaptive compensation correction method of the present invention, the parameters of the PID controller optimized by PSO particle swarm combined with improved ITAE include: Initialize the particle swarm, build a PID parameter tuning control system, and set PID parameters , , The search space is , each particle represents a PID parameter combination, the particle dimension is 3, the PID parameter value is randomly initialized for each particle and the particle velocity is initialized, the local optimal position of each particle is initialized to the current position of the particle, and the global optimal position is initialized to the position of the particle with the best fitness in the particle swarm; Simulate according to the initialized PID parameters, obtain the adjusted target threshold through the PID controller, and calculate the error with the reference signal ,in, represents the adjusted target threshold at time point t, Indicates that according to the digital signal The fundamental frequency Generate reference signal ; The calculated error , select the integral time absolute error ITAE and combine the overshoot and response time factors as the optimization objective function to calculate the fitness of each particle , the formula is: in, Indicates The fitness of a particle, and Denote the derivative terms and the integral error term The weight of represents the time constant of the integral action, The time constant Small variables, A tiny variable representing the time variable t; For each particle, if its fitness value is greater than the historical optimal fitness value, then update the local optimal position of the particle; if its fitness value is greater than the global optimal fitness value, then update the global optimal position; Update all particle velocities according to the particle swarm optimization algorithm and update the particle positions through the particle position update formula; By using the QUATRE algorithm to change the search direction of the particle, the particle transformation matrix is ​​obtained and applied to the particle position update formula; As the number of iterations increases, the search step size of the particle is gradually adjusted using a decreasing factor, and the maximum number of iterations is set. When the maximum number of iterations is reached, the PID parameter value corresponding to the global optimal particle is output, and the PID parameter value is substituted into the complete PID controller and the target threshold is dynamically adjusted. The error threshold is set, and after each key operation, the PID controller periodically checks the error. If the error is greater than the set error threshold, the error model will be entered to readjust the threshold, otherwise, no operation will be performed.

[0011] As a preferred solution of the AD key adaptive compensation correction method of the present invention, the method of using the long short-term memory network output error correction value to finally correct the target threshold includes: The long short-term memory network LSTM is selected as the neural network model to build the error model, which includes input layer, hidden layer and output layer; The input layer includes a digital signal, a current target threshold and an error; The hidden layer includes a 3-layer LSTM network, each LSTM layer includes 128 units, and a Dropout layer is set to reduce the network complexity; The output layer includes an output error correction value; The mean square error is selected as the loss function, and the Adam optimizer is used for parameter optimization. The network weights are updated after each training until the training error converges to the predetermined range; Input the real-time digital signal and the current target threshold into the trained error model and output the error correction value , introduces the future error predicted by the neural network, and calculates the adjusted target threshold at the next time point t+1 , the formula is: in, represents the threshold smoothing factor, represents the neural network prediction influence coefficient, Represents the error correction value output by the error model; Whenever the digital signal changes, the error model predicts the error correction value and adjusts the target threshold in real time based on the current digital signal and the current target threshold; Collect real-time feedback data and perform incremental updates. Through incremental learning, the error correction and threshold adjustment strategies are gradually optimized.

[0012] As a preferred solution of the AD key adaptive compensation correction method of the present invention, wherein: the use of SOGI-FLL to decouple the digital signal includes: According to the digital signal The fundamental frequency Generate reference signal , the digital signal With reference signal Multiply to get the real part of the digital signal and convert the digital signal With reference signal The cosine component of the digital signal is multiplied by The imaginary part of The digital signal is obtained by calculating the amplitude of the real and imaginary parts of the digital signal. The fundamental amplitude , The amplitude and phase information of the high-order harmonic components are expressed as complex numbers, and the dynamic change value of the high-order harmonic amplitude during the key pressing process is analyzed. ; A frequency locked loop is used to adjust the frequency of the reference signal; The frequency locked loop includes calculating a reference signal and digital signals The frequency error between the two is calculated, and the frequency of the reference signal is adjusted according to the calculated frequency error.

[0013] As a preferred solution of the AD key adaptive compensation correction method of the present invention, the step of constructing a key state model to obtain a real-time key state includes: Use the state machine model to build a key state model and define key states and state transition conditions; The key state is divided into two state nodes, each state node corresponds to a key state, and the state switching rule between each key state is determined by the fundamental amplitude. and dynamically changing values As the driver, set the pressing threshold , Release threshold Harmonic change thresholds , define the button release state and button press state; The button release state refers to and , it means the key is in the released state; The button pressing state refers to and , it means the key is in the pressed state; The state transition condition refers to the use of real-time digital signals and defined key states to transition the key state. If the key is in the pressed state, Reduce to and , it means that the key changes from the pressed state to the released state. If it is in the released state, Rise to and , it means that the key changes from the released state to the pressed state; According to the real-time digital signal, the key state model generates the corresponding real-time key state, and generates the corresponding start instruction according to the key state.

[0014] In a second aspect, the present invention provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program is executed by the processor, any step of the AD key adaptive compensation correction method as described in the first aspect of the present invention is implemented.

[0015] In a third aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program is executed by a processor, any step of the AD key adaptive compensation correction method as described in the first aspect of the present invention is implemented.

[0016] The beneficial effects of the present invention are as follows: by utilizing the PID control loop and the PSO particle swarm to optimize the PID parameters, the target threshold can be adjusted dynamically to ensure the stability and accuracy of the system under various environments; the target threshold is corrected by the LSTM neural network, which effectively overcomes the shortcomings of the traditional method; the SOGI-FLL is used to decouple the digital signal and accurately analyze the high-order harmonic components, which significantly improves the reliability and response accuracy of key recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.

[0018] Figure 1 This is a flow chart of the AD key adaptive compensation correction method in Example 1.

[0019] Figure 2 Schematic diagram of target threshold adaptive compensation in Example 1. DETAILED DESCRIPTION

[0020] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.

[0021] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0022] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.

[0023] Example 1, reference Figure 1 and Figure 2 , which is the first embodiment of the present invention, and provides an AD key adaptive compensation correction method, comprising the following steps: S1, real-time acquisition of key signals, converting them into digital signals and preprocessing them; Specifically, real-time acquisition of key signals and conversion into digital signals includes: According to business needs, select capacitive buttons and design the overall circuit diagram and signal sampling circuit; The overall circuit diagram of the design includes connecting one terminal of the capacitive button to a 5V power supply and the other terminal to a The pull-up resistor is connected to the GPIO input and grounded. When the capacitor button is pressed, the GPIO input is grounded to form a low-level signal. A TVS diode is added to the GPIO input for overvoltage protection. Ensure that the anode end of the diode is grounded and the cathode end is connected to the GPIO input. The reverse working voltage of the TVS diode is selected to be 5.5V to 6V to prevent high-voltage pulses from damaging the microcontroller. A 10nF decoupling capacitor is added between the input and ground to filter power supply noise. The signal sampling circuit includes a capacitor connected in series with the capacitor key input terminal and the GPIO input terminal. and 1 The low-pass filter of the capacitor connects the input of the operational amplifier to the The resistor is connected to the key signal, and the output terminal is connected through The feedback resistor is connected to the input terminal, and the output signal is transmitted to the microcontroller through the output terminal of the operational amplifier; The key signal refers to the capacitive key that relies on physical contact to complete the switch operation. When the capacitive key is pressed, the internal contact point is closed, current flows, and a low-level signal is generated. When released, the contact point is disconnected and the signal returns to a high level. Configure the sampling duration of the digital converter ADC. When a key is pressed, the key signal is collected and transmitted to the analog-to-digital converter ADC through the signal sampling circuit to be converted into a digital signal. Set the target threshold, collect digital signals greater than the target threshold and transmit them to the microcontroller.

[0024] The present invention effectively realizes the stable collection and conversion of capacitive key signals into digital signals through precise circuit design and signal sampling circuit. The circuit design adopts overvoltage protection of pull-up resistor and TVS diode to ensure the safety and reliability of the signal. The application of low-pass filter and operational amplifier optimizes the signal quality, removes noise interference, and improves the accuracy of the signal. By configuring the appropriate ADC sampling time, the change of the key signal can be accurately captured, and a reasonable target threshold can be set to ensure that a valid digital signal is collected when the key is pressed. This design scheme improves the accuracy and stability of signal acquisition, effectively prevents electrical interference, and ensures the reliability of the system under different working environments.

[0025] Furthermore, preprocessing includes, Use low pass filters and band pass filters to eliminate digital signals The high-frequency noise in the digital signal After normalization, the amplitude range of the processed digital signal is between [-1,1]; The normalized digital signal Perform discrete Fourier transform to obtain digital signal The spectrum of the key is obtained. In the calculated spectrum, the harmonic components higher than the fundamental frequency are extracted as the higher harmonic components. The fundamental frequency represents the overall on-off state of the key. The higher harmonic components reflect the change in the action frequency of the key, that is, the dynamic process of pressing and releasing. The amplitude and phase information of the higher harmonic components are extracted from the spectrum. The amplitude and phase characteristics of the higher harmonic components reflect the dynamic characteristics of the key (such as the pressing speed and rebound of the key).

[0026] This preprocessing method effectively eliminates high-frequency noise in digital signals through low-pass and band-pass filters, improving the purity of the signal. After signal normalization, it ensures that the amplitude range is stable between [-1,1], providing a unified standard for subsequent processing. Discrete Fourier transform further extracts high-order harmonic components in the signal spectrum. These high-order harmonic components can not only reflect the overall on and off state of the key, but also reveal the frequency changes in the dynamic process of the key, such as the speed and amplitude of pressing and rebounding. By extracting the amplitude and phase information of these harmonic components, more accurate feature data is provided for the accurate recognition and dynamic response of the key, thereby improving the system's perception accuracy and response sensitivity to key actions.

[0027] S2, using the PID control loop to perform preliminary dynamic adjustment of the target threshold and optimizing the parameters of the PID controller through PSO particle swarm combined with improved ITAE; Specifically, the initial dynamic adjustment of the target threshold using the PID control loop includes: Calculate the difference between the current digital signal and the target threshold , the formula is: in, Indicates the target threshold of the digital signal currently set; According to the difference Construct a complete PID controller and calculate the target threshold adjustment L. The formula is: Where L represents the final target threshold adjustment value output by the PID controller. , , Represent the proportional gain, integral gain and differential gain respectively, a is the derivative operator, which represents the error Perform differentiation, d represents a small variable of the time variable t; According to the obtained target threshold adjustment amount L, the current target threshold is dynamically updated.

[0028] By introducing a PID control loop to dynamically adjust the target threshold, the present invention can respond to the error between the current digital signal and the target threshold in real time and automatically perform precise adjustments. The PID controller takes into account the current state of the system error, the accumulated historical error and the error change trend through a combination of proportional gain, integral gain and differential gain, thereby optimizing the adjustment process of the target threshold. This dynamic adjustment mechanism effectively improves the stability and response speed of the system, can more accurately adapt to key inputs under different environments and operating conditions, ensures higher recognition accuracy and reliability, and significantly improves the sensitivity and intelligence level of the system.

[0029] Furthermore, the parameters of the PID controller optimized by PSO particle swarm combined with improved ITAE include: Initialize the particle swarm, build a PID parameter tuning control system, and set PID parameters , , The search space is 3, each particle represents a PID parameter combination, the particle dimension is 3, the PID parameter value is randomly initialized for each particle and the particle speed is initialized. The particle speed determines the step size of the position update. The local optimal position of each particle is initialized to the current position of the particle, and the global optimal position is initialized to the position of the particle with the best fitness in the particle swarm. The particle position refers to the particle position as a vector composed of numerical values, each numerical value representing a value of a dimension; Simulate according to the initialized PID parameters, obtain the adjusted target threshold through the PID controller, and calculate the error with the reference signal ,in, represents the adjusted target threshold at time point t, Indicates that according to the digital signal The fundamental frequency Generate reference signal ; The calculated error , select the integral time absolute error ITAE and combine the overshoot and response time factors as the optimization objective function to calculate the fitness of each particle , which is usually used to improve response speed and reduce errors. The smaller the fitness, the better the performance of the particle, which means the better the PID parameter combination. The formula is: in, Indicates The fitness of a particle, and Denote the derivative terms and the integral error term The weight of As a penalty term, it suppresses overshoot and oscillation in the transition process of the PID parameter tuning control system. It represents the time constant of the integral action and is used to adjust the influence of the integral term on the response of the PID controller. In practical applications, the integral error term will continue to increase as the error accumulates. Controls the speed of accumulation. The time constant Small variables, A tiny variable representing the time variable t; The introduction of the derivative term effectively suppresses the overshoot of the PID parameter tuning control system, and at the same time enables the PID parameter tuning control system to quickly converge to a steady state in a relatively short time, which not only improves the response speed of the PID parameter tuning control system, but also avoids the instability caused by oscillation and overshoot; By introducing a weighted integral error term, it is possible to avoid accumulating too large an error too quickly during integration. For example, ITAE will make the PID parameter tuning control system respond more smoothly when facing a large error, avoiding the over-response that may be caused by the traditional integral term, thereby improving the stability of the PID parameter tuning control system. For each particle, if its fitness value is greater than the historical optimal fitness value, then update the local optimal position of the particle; if its fitness value is greater than the global optimal fitness value, then update the global optimal position; Update all particle velocities according to the particle swarm optimization algorithm and update the particle positions through the particle position update formula; By using the QUATRE algorithm to change the search direction of particles to avoid falling into the local optimal solution, the particle transformation matrix is ​​obtained and applied to the particle position update formula to enhance the global search ability of particles; As the number of iterations increases, the search step size of the particle is gradually adjusted using a decreasing factor, and the maximum number of iterations is set. When the maximum number of iterations is reached, the PID parameter value corresponding to the global optimal particle is output, and the PID parameter value is substituted into the complete PID controller and the target threshold is dynamically adjusted. The error threshold is set, and after each key operation, the PID controller periodically checks the error. If the error is greater than the set error threshold, the error model will be entered to readjust the threshold, otherwise, no operation will be performed; In order to avoid instability caused by frequent threshold adjustments, a minimum response period is set. For example, the threshold is updated every 500ms. This can avoid excessive threshold fluctuations and allow the PID controller to maintain higher detection accuracy in a stable state.

[0030] This scheme combines the PSO particle swarm optimization algorithm with the improved ITAE optimized PID controller to achieve precise tuning of PID parameters, thereby improving the response speed, stability and accuracy of the system. The optimal PID parameters are searched by the particle swarm, and the overshoot, response time and integral error are comprehensively considered using the fitness function to ensure that the system quickly converges to a steady state while avoiding excessive oscillation. The ITAE optimization effectively suppresses the excessive accumulation of integral terms, reduces excessive response under large error conditions, and improves the stability of the system. In addition, the global search capability of the particle swarm is enhanced by the QUATRE algorithm, avoiding local optimal solutions and ensuring the efficiency of the tuning process. By setting the error threshold and the minimum response period, the instability caused by frequent threshold adjustments is further reduced, thereby improving the reliability and detection accuracy of the system.

[0031] S3, using the long short-term memory network output error correction value to make a final correction to the target threshold; Specifically, the final correction of the target threshold using the long short-term memory network output error correction value includes: The long short-term memory network LSTM is selected as the neural network model to build the error model, which includes input layer, hidden layer and output layer; The input layer includes a digital signal, a current target threshold and an error; The hidden layer includes a 3-layer LSTM network, each LSTM layer includes 128 units, and a Dropout layer is set to reduce the network complexity; The output layer includes an output error correction value for adjusting a target threshold of the detection according to the prediction of the error model; The mean square error is selected as the loss function, and the Adam optimizer is used for parameter optimization. The network weights are updated after each training until the training error converges to the predetermined range; Input the real-time digital signal and the current target threshold into the trained error model and output the error correction value , which indicates the adjustment direction of the target threshold currently detected relative to the target state; In the traditional dynamic threshold adjustment method, the threshold is corrected based on the weighted average of the historical value and the current measurement value. The introduction of the future error predicted by the neural network makes the threshold correction not only dependent on the current measurement value, but also on the prediction error. The target threshold at the next time point t+1 after adjustment is calculated. , the formula is: in, Represents the threshold smoothing factor, which controls the weight in the current threshold. Represents the neural network prediction influence coefficient, which controls the influence of the neural network output. Represents the error correction value output by the error model; Whenever the digital signal changes, the error model predicts the error correction value and adjusts the target threshold in real time based on the current digital signal and the current target threshold; Collect real-time feedback data and perform incremental updates. Through incremental learning, the error correction and threshold adjustment strategies are gradually optimized.

[0032] The present invention significantly improves the accuracy and intelligence level of target threshold adjustment by introducing a long short-term memory network for error correction. The LSTM network dynamically predicts and outputs the error correction value by processing the digital signal, the current target threshold and the error data, thereby accurately adjusting the target threshold. Different from the traditional weighted average correction method, this scheme not only relies on the current measurement value, but also predicts the future error through the neural network, optimizes the threshold adjustment strategy, and gradually improves the error correction and threshold adjustment through incremental learning and real-time feedback data update, thereby improving the stability and response accuracy of the system in a changing environment. This method effectively improves the sensitivity and reliability of the key signal, and ensures the accuracy and efficiency of the key operation.

[0033] S4, using SOGI-FLL to decouple the digital signal and construct a key state model to obtain the real-time key state; Specifically, using SOGI-FLL to decouple digital signals includes: According to the digital signal The fundamental frequency Generate reference signal , the frequency of the reference signal and the digital signal The fundamental frequency of is: , in, Represents the digital signal at time point t The fundamental frequency of The digital signal With reference signal Multiply them to get the real part of the digital signal. Through this operation, the real part contains the component with the same frequency as the reference signal. With reference signal The cosine component of the digital signal is multiplied by The imaginary part of The digital signal is obtained by calculating the amplitude of the real and imaginary parts of the digital signal. The fundamental amplitude , The amplitude and phase information of the high-order harmonic components are expressed as complex numbers, and the dynamic change value of the high-order harmonic amplitude during the key pressing process is analyzed. , the formula is: , in, represents the complex number representation of the nth higher harmonic component, where N represents the number of higher harmonic components; A frequency locked loop is used to adjust the frequency of the reference signal; The main function of adjusting the frequency of the reference signal is to achieve accurate synchronization of the signal frequency. By synchronizing the frequency of the reference signal and the digital signal, the frequency offset and phase error can be eliminated to ensure the accuracy of the signal in the spectrum analysis. After frequency synchronization, the real and imaginary parts of the digital signal obtained by discrete Fourier transform can accurately reflect the frequency components of the signal, thereby accurately extracting the high-order harmonic components, which is crucial for analyzing the dynamic characteristics of the key (such as pressing speed and rebound), ensuring the accuracy of subsequent spectrum analysis and the reliability of signal feature extraction; The frequency locked loop includes calculating a reference signal and digital signals The frequency error between the two is calculated, and the frequency of the reference signal is adjusted according to the calculated frequency error.

[0034] This scheme uses SOGI-FLL to accurately decouple digital signals. By generating a reference signal that matches the fundamental frequency of the digital signal and multiplying it with the digital signal, the real and imaginary parts of the signal are successfully extracted, thereby accurately calculating the fundamental amplitude and high-order harmonic components. This process achieves precise synchronization of the signal frequency through a frequency-locked loop, effectively eliminating frequency offset and phase error, and ensuring the accuracy of the signal in spectrum analysis. Through frequency synchronization and dynamic change analysis of high-order harmonic amplitudes, this method can accurately extract the dynamic characteristics of the key pressing process, improve the accuracy and reliability of signal feature extraction, and provide a solid foundation for subsequent key judgment and optimization.

[0035] Furthermore, the key state model is constructed to obtain the real-time key state including: Use the state machine model to build a key state model and define key states and state transition conditions; The key state is divided into two state nodes, each state node corresponds to a key state, and the state switching rule between each key state is determined by the fundamental amplitude. and dynamically changing values As the driver, set the pressing threshold , Release threshold Harmonic change thresholds , define the button release state and button press state; The button release state refers to and , it means the key is in the released state; When the user releases the key, the contact point between the key and the circuit is disconnected, and the strength of the electrical signal is significantly reduced. At this time, the amplitude of the digital signal decreases, usually returning to a low level or zero level, and the signal waveform tends to be stable. The high-order harmonic components of the circuit signal are usually weakened, resulting in a certain fluctuation in the amplitude of the high-order harmonics. The button pressing state refers to and , it means the key is in the pressed state; When a key is pressed, the contact point between the key and the circuit is closed, forming a stable electrical signal. At this time, the strength of the electrical signal increases, and the waveform is usually relatively stable. In order to detect this state, the amplitude of the fundamental wave is increased, the interference fluctuation in the circuit is reduced, the high-order harmonic components are stable, and the frequency change in the signal waveform is small. Therefore, the high-order harmonic components are low at this time, reflecting that the key is stably pressed; The state transition condition refers to the use of real-time digital signals and defined key states to transition the key state. If the key is in the pressed state, Reduce to and , it means that the key changes from the pressed state to the released state. If it is in the released state, Rise to and , it means that the key changes from the released state to the pressed state; According to the real-time digital signal, the key state model generates the corresponding real-time key state, and generates the corresponding start instruction according to the key state.

[0036] This key state model realizes accurate key state recognition and transition control by introducing a state machine model and combining the dynamic changes of fundamental wave amplitude and higher harmonics. By defining key pressing and key releasing and utilizing the real-time changes of digital signals, the model can accurately judge the different states of the key and trigger the state transition through the set threshold rules. When the key is released, the signal amplitude decreases significantly, the waveform tends to be stable, and the higher harmonics weaken; when the key is pressed, the signal amplitude increases, the waveform stabilizes, and the higher harmonic components decrease, ensuring the reliability and accuracy of state recognition. This model makes the real-time response of key operation more accurate and stable, and can generate corresponding start instructions.

[0037] This embodiment also provides a computer device, which is suitable for the AD key adaptive compensation correction method, including: a memory and a processor; the memory is used to store computer executable instructions, and the processor is used to execute computer executable instructions to implement the AD key adaptive compensation correction method proposed in the above embodiment. The computer device may be a terminal, and the computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covered on the display screen, or a key, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.

[0038] The present embodiment also provides a storage medium on which a computer program is stored. When the program is executed by a processor, the method for realizing the adaptive compensation correction of AD keys proposed in the above embodiment is implemented. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read Only Memory, referred to as EPROM), programmable read-only memory (Programmable Red-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0039] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. AD key adaptive compensation correction method, characterized by: include, Real-time acquisition of key signals, converting them into digital signals and preprocessing them; The PID control loop is used to perform preliminary dynamic adjustment of the target threshold and the parameters of the PID controller are optimized by PSO particle swarm combined with improved ITAE; Use the long short-term memory network to output the error correction value to make a final correction to the target threshold; Use SOGI-FLL to decouple digital signals and build a key state model to obtain the real-time key state.

2. The AD key adaptive compensation correction method according to claim 1, characterized in that: The real-time acquisition of key signals and conversion into digital signals includes: According to business needs, select capacitive buttons and design the overall circuit diagram and signal sampling circuit; The overall circuit diagram of the design includes connecting one terminal of the capacitive button to a 5V power supply and the other terminal to a The pull-up resistor is connected to the GPIO input terminal and grounded. When the capacitor button is pressed, the GPIO input terminal is grounded to form a low-level signal. A TVS diode is added to the GPIO input terminal for overvoltage protection. The cathode terminal is connected to the GPIO input terminal. The reverse working voltage of the TVS diode is selected to be 5.5V to 6V. A 10nF decoupling capacitor is added between the input terminal and the ground. The signal sampling circuit includes a capacitor connected in series with the capacitor key input terminal and the GPIO input terminal. and 1 The low-pass filter of the capacitor connects the input of the operational amplifier to the The resistor is connected to the key signal, and the output terminal is connected through The feedback resistor is connected to the input terminal, and the output signal is transmitted to the microcontroller through the output terminal of the operational amplifier; Configure the sampling duration of the digital converter ADC. When a key is pressed, the key signal is collected and transmitted to the analog-to-digital converter ADC through the signal sampling circuit to be converted into a digital signal. Set the target threshold, collect digital signals greater than the target threshold and transmit them to the microcontroller.

3. The AD key adaptive compensation correction method according to claim 2, characterized in that: The pre-processing comprises: Use low pass filters and band pass filters to eliminate digital signals The high-frequency noise in the digital signal After normalization, the amplitude range of the processed digital signal is between [-1,1]; The normalized digital signal Perform discrete Fourier transform to obtain digital signal The spectrum of the calculated frequency spectrum is extracted, and the harmonic components higher than the fundamental frequency are taken as the higher harmonic components, and the amplitude and phase information of the higher harmonic components are extracted from the spectrum.

4. The AD key adaptive compensation correction method according to claim 3, characterized in that: The use of a PID control loop to initially dynamically adjust the target threshold value includes: Calculate the difference between the current digital signal and the target threshold , the formula is: ; in, Indicates the target threshold of the digital signal currently set; According to the difference Construct a complete PID controller and calculate the target threshold adjustment L. The formula is: ; Where L represents the final target threshold adjustment value output by the PID controller. , , Represent the proportional gain, integral gain and differential gain respectively, a is the derivative operator, which represents the error Perform differentiation, d represents a small variable of the time variable t; According to the obtained target threshold adjustment amount L, the current target threshold is dynamically updated.

5. The AD key adaptive compensation correction method according to claim 4, characterized in that: The parameters of the PID controller optimized by PSO particle swarm combined with improved ITAE include: Initialize the particle swarm, build a PID parameter tuning control system, and set PID parameters , , The search space is , each particle represents a PID parameter combination, the particle dimension is 3, the PID parameter value is randomly initialized for each particle and the particle velocity is initialized, the local optimal position of each particle is initialized to the current position of the particle, and the global optimal position is initialized to the position of the particle with the best fitness in the particle swarm; Simulate according to the initialized PID parameters, obtain the adjusted target threshold through the PID controller, and calculate the error with the reference signal ,in, represents the adjusted target threshold at time point t, Indicates that according to the digital signal The fundamental frequency Generated reference signal ; The calculated error , select the integral time absolute error ITAE and combine the overshoot and response time factors as the optimization objective function to calculate the fitness of each particle , the formula is: ; in, Indicates The fitness of a particle, and Denote the derivative terms and the integral error term The weight of represents the time constant of the integral action, The time constant Small variables, A tiny variable representing the time variable t; For each particle, if its fitness value is greater than the historical optimal fitness value, then update the local optimal position of the particle; if its fitness value is greater than the global optimal fitness value, then update the global optimal position; Update all particle velocities according to the particle swarm optimization algorithm and update the particle positions through the particle position update formula; By using the QUATRE algorithm to change the search direction of the particle, the particle transformation matrix is ​​obtained and applied to the particle position update formula; As the number of iterations increases, the search step size of the particle is gradually adjusted using a decreasing factor, and the maximum number of iterations is set. When the maximum number of iterations is reached, the PID parameter value corresponding to the global optimal particle is output, and the PID parameter value is substituted into the complete PID controller and the target threshold is dynamically adjusted. The error threshold is set, and after each key operation, the PID controller periodically checks the error. If the error is greater than the set error threshold, the error model will be entered to readjust the threshold, otherwise, no operation will be performed.

6. The AD key adaptive compensation correction method according to claim 5, characterized in that: The final correction of the target threshold using the long short-term memory network output error correction value includes: The long short-term memory network LSTM is selected as the neural network model to build the error model, which includes input layer, hidden layer and output layer; The input layer includes a digital signal, a current target threshold and an error; The hidden layer includes a 3-layer LSTM network, each LSTM layer includes 128 units, and a Dropout layer is set to reduce the network complexity; The output layer includes an output error correction value; The mean square error is selected as the loss function, and the Adam optimizer is used for parameter optimization. The network weights are updated after each training until the training error converges to the predetermined range; Input the real-time digital signal and the current target threshold into the trained error model and output the error correction value , introduces the future error predicted by the neural network, and calculates the adjusted target threshold at the next time point t+1 , the formula is: ; in, represents the threshold smoothing factor, represents the neural network prediction influence coefficient, Represents the error correction value output by the error model; Whenever the digital signal changes, the error model predicts the error correction value and adjusts the target threshold in real time based on the current digital signal and the current target threshold; Collect real-time feedback data and perform incremental updates. Through incremental learning, the error correction and threshold adjustment strategies are gradually optimized.

7. The AD key adaptive compensation correction method according to claim 6, characterized in that: The use of SOGI-FLL to decouple the digital signal includes: According to the digital signal The fundamental frequency Generate reference signal ; The digital signal With reference signal Multiply to get the real part of the digital signal and convert the digital signal With reference signal The cosine component of the digital signal is multiplied by The imaginary part of The digital signal is obtained by calculating the amplitude of the real and imaginary parts of the digital signal. The fundamental amplitude , The amplitude and phase information of the high-order harmonic components are expressed as complex numbers, and the dynamic change value of the high-order harmonic amplitude during the key pressing process is analyzed. ; A frequency locked loop is used to adjust the frequency of the reference signal; The frequency locked loop includes calculating a reference signal and digital signals The frequency error between the two is calculated, and the frequency of the reference signal is adjusted according to the calculated frequency error.

8. The AD key adaptive compensation correction method according to claim 7, characterized in that: The constructing of the key state model to obtain the real-time key state includes: Use the state machine model to build a key state model and define key states and state transition conditions; The key state is divided into two state nodes, each state node corresponds to a key state, and the state switching rule between each key state is determined by the fundamental amplitude. and dynamically changing values As the driver, set the pressing threshold , Release threshold Harmonic change thresholds , define the button release state and button press state; The button release state refers to and , it means the key is in the released state; The button pressing state refers to and , it means the key is in the pressed state; The state transition condition refers to the use of real-time digital signals and defined key states to transition the key state. If the key is in the pressed state, Reduce to and , it means that the key changes from the pressed state to the released state. If it is in the released state, Rise to and , it means that the key changes from the released state to the pressed state; According to the real-time digital signal, the key state model generates the corresponding real-time key state, and generates the corresponding start instruction according to the key state.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the AD key adaptive compensation correction method described in any one of claims 1 to 8 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the AD key adaptive compensation correction method described in any one of claims 1 to 8 are implemented.

Citation Information

Cited By

  • System and method for improving feedback and stability in digital amplifiers

    CN120016981A

  • System and method for improving feedback and stability in digital amplifiers

    CN120016981B

  • Sunlight energy optical fiber leading-in system capable of tracking in real time

    CN120653022A