Hysteretic filtering method, device and equipment with frequency interference suppression and medium
By adopting a hysteresis filtering method with frequency interference suppression in the ADC acquisition module in the field of industrial automation, low-pass filter and FFT transformation remove high-frequency signals and specific frequency interference, solving the problem of data jitter and excessive resource usage, and achieving high-precision and short response time filtering effect.
Patent Information
- Application Number
- CN202411723968.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-18
AI Technical Summary
In the prior art, when dealing with special customized products or in environments where there is a specific frequency interference, data jitter is too large to meet the accuracy requirements, and the higher-order filters occupy too much resources when running on the MCU, resulting in long response time and loss of accuracy.
The hysteresis filtering method with frequency interference suppression is adopted to remove high-frequency signals and specific frequency interference through low-pass filters and FFT transformations, and then hysteresis smoothing filtering is performed to control signal accuracy.
With a smaller RAM space and short response time, the frequency suppression effect and data smoothness are improved, and the data availability and signal processing capabilities of the ADC sampling module are improved.
Smart Images

Figure CN119652277A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of industrial automation control, and in particular to a hysteresis filtering method, device, equipment and medium with frequency interference suppression. Background Art
[0002] In the prior art, the methods for collecting and processing instrument signals on site are relatively fixed. Although the signal processing accuracy meets the use requirements, for special customized products or when working in an environment with specific frequency interference, the prior art will have excessive data jitter, so that it cannot meet the required accuracy and has low availability.
[0003] In addition, the time complexity of traditional high-order frequency suppression algorithms such as FIR and IIR is O(MN), which means that one filter requires M×N multiplication and addition operations, while the time complexity of fast Fourier transform FFT is O(NlogN), which is more efficient in spectrum processing. Therefore, compared with some filters with higher orders that can filter out certain frequencies, the high order leads to excessive computation, which increases the burden of filter processing. Such problems are particularly obvious on MCUs with limited resources. And because of the limited floating-point precision of MCUs, the higher the filter order, the greater the loss of precision.
[0004] Therefore, the defects of applying conventional high-order filters for filtering out frequencies on MCUs are that they consume a large amount of RAM space and have a long response time. Summary of the invention
[0005] The present invention aims to provide a method, device, equipment and medium for hysteresis filtering with frequency interference suppression, which can improve the data availability and signal processing capability of the ADC sampling module in the natural frequency interference environment by using relatively small RAM space and short filtering calculation time. The accuracy of the input and output modules can still be guaranteed while adapting to various special working conditions, while also reducing the impact of the module's surrounding environment, thereby ensuring the accuracy of the ADC sampling of the field equipment, and also being able to avoid the problem of interlocking the field equipment due to the deviation of the input module's accuracy, which eventually leads to the problem of field parking.
[0006] The present invention is achieved through the following technical solutions:
[0007] In a first aspect, the present invention provides a hysteresis filtering method with frequency interference suppression, the method comprising:
[0008] Acquire ADC sampling signal, where the ADC sampling signal is a sampling signal of an ADC acquisition module in the field of industrial automation;
[0009] A low-pass filter is used to filter the ADC sampling signal to remove high-frequency signals and reduce signal aliasing, thereby obtaining a first processed signal;
[0010] According to the first processed signal, window interception is performed to obtain an intercepted signal; and the intercepted signal is subjected to FFT forward transformation to remove the corresponding frequency interference, and the spectrum without the interference frequency is used as the second processed signal;
[0011] According to the second processed signal, an IFT inverse transform is performed to obtain a time domain signal after the interference frequency is removed, and an amplitude normalization process is performed on the time domain signal after the interference frequency is removed to obtain a third processed signal;
[0012] According to the signal after the third processing, a lag filter is used to perform filtering again to obtain a final filtered signal.
[0013] The present invention directly uses FFT to filter out the corresponding frequency interference in the frequency domain, and then performs hysteresis smoothing filtering on the signal after the interference is filtered out, and controls its accuracy within a specified range. The scheme of the present invention only consumes a small RAM space and a short response time, and can achieve the corresponding frequency suppression effect and data smoothness. The present invention is mainly used in the filtering processing of the ADC acquisition module in the field of industrial automation.
[0014] Furthermore, the low-pass filter adopts an RC low-pass filter circuit.
[0015] Furthermore, the method also includes: before performing window interception, first storing the first filtered signal in a buffer area.
[0016] Further, according to the first processed signal, window interception is performed to obtain an intercepted signal; and the intercepted signal is subjected to FFT forward transformation to remove the corresponding frequency interference, and the spectrum without the interference frequency is used as the second processed signal; including:
[0017] Performing window interception according to the first processed signal to obtain an intercepted signal;
[0018] According to the intercepted signal, FFT forward transformation is performed to obtain the corresponding waveform spectrum;
[0019] The corresponding waveform spectrum obtained by the forward transformation of FFT is processed by using the Hamming window function, and the proportions of various frequency domain points are readjusted to obtain the second processed signal.
[0020] Furthermore, the Hamming window function is used to process the frequency domain signal obtained by the FFT forward transform, and the expression is:
[0021]
[0022] Among them: g(t) is the time domain input; h(t) is the time domain Hamming window function; G(w) is the frequency domain input; H(w) is the frequency domain Hamming window function; F[.] is the Fourier transform process.
[0023] Furthermore, the lag filter adopts a first-order lag filter, and the expression is:
[0024] Y[N]=a·Y[N-1]+(1-a)·X[n]
[0025] Where: n represents the data at the nth moment; a is the proportional coefficient, which is used to adjust the ratio of the historical value and the sampled value, and the value range of a is: 0~1; Y[n] is the output value at the nth moment, that is, the output value at the current moment; Y[n-1] is the output value at the n-1th moment, that is, the historical value at the previous moment; X[n] is the sampled value at the nth moment, that is, the sampled value at the current moment.
[0026] In a second aspect, the present invention further provides a hysteresis filtering device with frequency interference suppression, the device using the above-mentioned hysteresis filtering method with frequency interference suppression; the device comprises:
[0027] An acquisition unit, used for acquiring an ADC sampling signal, where the ADC sampling signal is a sampling signal of an ADC acquisition module in the field of industrial automation;
[0028] A low-pass filtering unit is used to filter the ADC sampling signal using a low-pass filter to filter out high-frequency signals and reduce signal aliasing, thereby obtaining a first processed signal;
[0029] An FFT forward transform unit is used to perform window interception according to the first processed signal to obtain an intercepted signal; and perform FFT forward transform on the intercepted signal to remove the corresponding frequency interference, and use the spectrum without the interference frequency as the second processed signal;
[0030] An IFT inverse transform unit is used to perform an IFT inverse transform on the second processed signal to obtain a time domain signal after the interference frequency is removed, and perform amplitude normalization processing on the time domain signal after the interference frequency is removed to obtain a third processed signal;
[0031] The hysteresis filtering unit is used to perform a second filtering process using a hysteresis filter according to the signal after the third processing to obtain a final filtered signal.
[0032] Further, the FFT forward transform unit comprises:
[0033] A window interception subunit, used for performing window interception according to the first processed signal to obtain an intercepted signal;
[0034] The FFT forward transformation subunit is used to perform FFT forward transformation according to the intercepted signal to obtain the corresponding waveform spectrum;
[0035] The Hamming window subunit is used to process the corresponding waveform spectrum obtained by the forward transformation of the FFT using the Hamming window function, re-adjust the proportions at each frequency domain point, and obtain the second processed signal.
[0036] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned lag filtering method with frequency interference suppression when executing the computer program.
[0037] In a fourth aspect, the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned lag filtering method with frequency interference suppression is implemented.
[0038] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0039] The present invention discloses a method, device, equipment and medium for hysteresis filtering with frequency interference suppression. The present invention directly uses FFT to filter out the corresponding frequency interference in the frequency domain, and then performs hysteresis smoothing filtering on the signal after the interference is filtered out, and controls its accuracy within a specified range. The scheme of the present invention only consumes a small amount of RAM space and a short response time to achieve the corresponding frequency suppression effect and data smoothness. The present invention is mainly used in the filtering processing of ADC acquisition modules in the field of industrial automation. (1) It occupies less MCU storage RAM and ROM space; (2) The filtering response time is short and the accuracy is high; (3) It occupies less MCU computing resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The drawings described herein are used to provide a further understanding of the embodiments of the present invention, constitute a part of this application, and do not constitute a limitation of the embodiments of the present invention. In the drawings:
[0041] Figure 1 This is a flow chart of a hysteresis filtering method with frequency interference suppression according to the present invention;
[0042] Figure 2 The RC low-pass filter circuit used in the present invention;
[0043] Figure 3 Parameter configuration of the RC low-pass filter circuit of the present invention;
[0044] Figure 4 The spectrum analyzed by FFT of the present invention;
[0045] Figure 5 This is the spectrum analyzed when Nw=500 in the present invention;
[0046] Figure 6 The spectrum after adding the Hamming window of the present invention;
[0047] Figure 7 The spectrum of the interference signal is removed for the present invention;
[0048] Figure 8 The simulation result after the transformed result is assigned and normalized by the present invention;
[0049] Fig. 9 This is an illustration of the filtering accuracy of the present invention. Figure 1 ;
[0050] Fig.10 This is an illustration of the filtering accuracy of the present invention. Figure 2 ;
[0051] Fig.11 The response time of the present invention is shown in FIG. Figure 1 ;
[0052] Fig.12 The response time of the present invention is shown in FIG. Figure 2 ;
[0053] Fig.13 The accuracy of adding first-order lag filtering to the present invention is shown in FIG. Figure 1 ;
[0054] Fig.14 The accuracy of adding first-order lag filtering to the present invention is shown in FIG. Figure 2 ;
[0055] Fig.15 Response time of adding first-order lag filtering to the present invention Figure 1 ;
[0056] Fig.16 Response time of adding first-order lag filtering to the present invention Figure 2 ;
[0057] Fig.17 The present invention is a structural block diagram of a hysteresis filter device with frequency interference suppression. DETAILED DESCRIPTION
[0058] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.
[0059] The present invention solves the shortcomings of the high-order frequency suppression algorithm commonly used in traditional IO modules, which occupies a lot of MCU computing resources, has a poor response time, and cannot meet the required filtering accuracy.
[0060] The present invention directly uses FFT to filter out the corresponding frequency interference in the frequency domain, and then performs hysteresis smoothing filtering on the signal after the interference is filtered out, and controls its accuracy within a specified range. The scheme of the present invention only consumes a small RAM space and a short response time, and can achieve the corresponding frequency suppression effect and data smoothness. The present invention is mainly used in the filtering processing of the ADC acquisition module in the field of industrial automation.
[0061] The present invention is divided into two parts: hardware processing and software processing. The first part is the hardware processing part, which corresponds to the low-pass filter in step 2 in the following embodiment. The second part is the software processing part, which corresponds to steps 3 to 5 in the following embodiment.
[0062] Example 1
[0063] like Figure 1 As shown, the present invention provides a hysteresis filtering method with frequency interference suppression, the method comprising:
[0064] Step 1, obtaining an ADC sampling signal, where the ADC sampling signal is a sampling signal of an ADC acquisition module in the field of industrial automation;
[0065] Step 2, use a low-pass filter to filter the ADC sampling signal, filter out high-frequency signals and reduce aliasing effects, and obtain a first processed signal; wherein the low-pass filter uses an RC low-pass filter circuit.
[0066] In order to prevent the ADC from introducing high-frequency signals into low-frequency signals during the sampling process, thus causing frequency aliasing and affecting the most important 0Hz DC analog input, a low-pass filter needs to be set before the ADC sampling to prevent the introduction of high-frequency signals. The low-pass filter is implemented through an RC low-pass filter circuit. The specific circuit implementation is as follows Figure 2 shown.
[0067] By calculating different cutoff frequencies under the resistance of 2kΩ, different capacitance values can be calculated. Here we assume that our sampling frequency Fs = 250Hz. At this time, in order to meet the theoretical effective frequency range of FFT transformation [-Fs / 2, Fs / 2] (the actual transformation here is the range [0, Fs], but the frequency of the range [-Fs / 2, 0] is counted into the next cycle), we must limit the sampled frequency to within Fs / 2, that is, within 125Hz, otherwise the analyzed spectrum will produce aliasing. Here we choose to limit the -3dB cutoff frequency to about 10Hz before 125Hz to ensure that the sampled 125Hz interference has been attenuated to a certain extent. The cutoff frequency formula of the RC low-pass circuit is:
[0068]
[0069] This formula can be used to calculate that in actual application, when R = 2kΩ resistance and capacitance C = 680uf, the cut-off frequency fc ≈ 117Hz. At this time, the designed Rc low-pass filter meets the definition of anti-aliasing filter. Figure 3 shown.
[0070] Step 3, performing window interception according to the first processed signal to obtain an intercepted signal; performing FFT forward transform on the intercepted signal to remove the corresponding frequency interference, and using the spectrum without the interference frequency as the second processed signal;
[0071] Step 3 specifically includes:
[0072] Performing window interception according to the first processed signal to obtain an intercepted signal;
[0073] According to the intercepted signal, FFT forward transformation is performed to obtain the corresponding waveform spectrum;
[0074] The corresponding waveform spectrum obtained by the forward transformation of FFT is processed by using the Hamming window function, and the proportions of various frequency domain points are readjusted to obtain the second processed signal.
[0075] As a further implementation, the method further includes: before performing window capture, first storing the first filtered signal in a buffer area.
[0076] Specifically, the signal is intercepted and subjected to FFT forward transformation, as follows:
[0077] The purpose of this step is to convert the time domain signal to the frequency domain for corresponding processing. The discrete expression of FFT is as follows:
[0078]
[0079] Where: Ts is the sampling period; t0 is the sampling start time, which is 0 here, indicating that sampling starts from time 0; F is the current conversion frequency. In order to normalize the spectrum, it satisfies the formula: K is the kth frequency domain point currently being transformed; Ndft is the number of sample points to be transformed, which is equal to Nw here; Nw is the window width, that is, the number of sample points; X[k] is the spectrum sequence; X[n] is the sampled signal time domain sequence;
[0080] The following is the pair function simulated by Matlab:
[0081] f(n)=sin(120πn)+5×cos(150πn)+2×sin(200πn)
[0082] The spectrum obtained by FFT analysis when Nw = 1000 (right) and 500 (left) respectively is as follows Figure 4 As shown, Figure 4 The horizontal axis represents the frequency, and the vertical axis represents the amplitude corresponding to each frequency.
[0083] The precision of the above image spectrum satisfies the mathematical expression:
[0084]
[0085] Where: Nw is the sampling window width; Fs is the sampling frequency; Precison is the frequency domain transformation accuracy, that is, the unit of spectrum accuracy.
[0086] It can be seen that when Nw is small and the spectrum accuracy is low, the spectrum will have a certain frequency leakage. The main reason for frequency leakage is that the truncated data is not the entire period of this frequency signal. The impact of frequency leakage will be distributed to each resolved frequency point, so the more resolved frequency points, the smaller the impact of frequency leakage. Therefore, in order to accurately filter out the value of the corresponding frequency, it is important to set a relatively reasonable window size Nw. If Nw is set too large, it will occupy too much RAM and ROM space, and the amount of calculation will increase accordingly, but the corresponding accuracy will increase. Here, if we want to use a smaller RAM / ROM space and a smaller amount of calculation to obtain a more accurate spectrum, we must use a window function to process it.
[0087] This part of performance optimization:
[0088] In order to reduce the impact of frequency leakage on the signal, the spectrum transformed by FFT is processed accordingly through windowing operation. The following is the spectrum analyzed when Nw=500. Figure 5 As shown, the horizontal axis is the frequency, and the vertical axis is the amplitude corresponding to each frequency.
[0089] Here, by adding the Hamming window function, we can re-adjust the proportion of each frequency domain point to reduce the impact of the side lobe on the system. The process of frequency domain input passing through the system can be regarded as a convolution process, and this system is the embodiment of the window function we choose in the frequency domain, which can be specifically expressed as:
[0090] -F(w)→W(w)-F(w) * W(w)→
[0091] The convolution of the system in the frequency domain is equal to the Fourier transform of the system product in the time domain, and its formula is:
[0092]
[0093] Among them: g(t) is the time domain input; h(t) is the time domain Hamming window function; G(w) is the frequency domain input; H(w) is the frequency domain Hamming window function; F[.] is the Fourier transform process.
[0094] So when we perform forward FFT, we just need to multiply g(t) by a time domain proportional system h(t). This system needs to satisfy the characteristics that the proportions are lower on both sides and higher in the middle. Here we choose the Hamming window function, which has the following characteristics:
[0095] 1. In the middle of the window function, the weight is large, and the maximum is 1;
[0096] 2. On both sides of the window function, the weights gradually decrease to 0, making both ends of the window completely 0 and the signal edge very smooth;
[0097] 3. The main lobe width is moderate, which has a good balance between frequency resolution and frequency leakage reduction;
[0098] 4. The side lobe decays quickly, which means it can effectively reduce frequency leakage and suppress side lobe interference;
[0099] The mathematical expression of the Hamming window function is as follows:
[0100]
[0101] Where: Nw is the window size; the value range of n is [0, Nw-1].
[0102] After multiplying it with the corresponding sequence of the original signal sequence and normalizing it, the final spectrum is as follows Figure 6 As shown, the horizontal axis is the frequency, and the vertical axis is the amplitude corresponding to each frequency.
[0103] It can be clearly observed that after adding the Hamming window, its spectrum leakage is greatly improved.
[0104] Step 4, performing an IFT inverse transform on the second processed signal to obtain a time domain signal after removing the interference frequency, and performing amplitude normalization processing on the time domain signal after removing the interference frequency to obtain a third processed signal;
[0105] Specifically, the corresponding interference is removed in the frequency domain and the IFT time domain signal restoration processing (i.e., IFT inverse transform) is performed, as follows:
[0106] (1) Remove the unnecessary signals from the spectrum. The function we simulate here is:
[0107] f(n)=sin(120πn)+5×cos(150πn)+2×sin(200πn)
[0108] If we want to remove the 100Hz and 60Hz signals, we need to change the amplitudes of 100Hz and 60Hz on the spectrum graph and the symmetrical frequencies of 900Hz and 940Hz on the spectrum to 0, as follows: Figure 7 As shown, the horizontal axis is the frequency, and the vertical axis is the amplitude corresponding to each frequency.
[0109] (2) IFT inverse transform restores the signal
[0110] The spectrum after removing the corresponding frequency signal is subjected to inverse fast Fourier transform IFT, and its mathematical expression is:
[0111]
[0112] Where: Nw is the window width; Fs is the sampling frequency; F0 is the starting frequency; Ndft is the number of samples for IFT, where Ndft = Nw; K is the number of samples currently transformed; X[k] is the spectrum sequence; X[n] is the time domain sequence;
[0113] t: The time of the current transformation. The time domain is also normalized, and it satisfies the formula:
[0114]
[0115] (3) Perform normalization on the transformed results
[0116] Similarly, we have normalized the time domain, which will cause the value of the transformed time domain signal to become the "window width" times the original value, so here we need to restore the result to the original amplitude. The mathematical expression for restoration is:
[0117]
[0118] After normalizing the transformed time domain sequence, their imaginary parts are all 0, so at this time, we only need to use the real part of the transformed result as the value of the time domain signal. The simulation results are as follows: Figure 8 As shown, the horizontal axis is the time size and the vertical axis is the amplitude.
[0119] It can be seen that after removing the frequency values of 60Hz and 100Hz, the remaining signal with an amplitude of 5 and a frequency of 75Hz is perfectly restored.
[0120] Step 5: According to the third processed signal, a lag filter is used to perform filtering again to obtain a final filtered signal.
[0121] Step 5 The purpose of this process is to reduce the response time of the system while maintaining accuracy. According to process 1 and process 2, the filtering processing simulation of the ADC sampling data with a sampling frequency of 250Hz is performed. The interference is a 60Hz sine signal with an amplitude of 20 times the accuracy, which is coupled to the 5MA current signal input. The following is the filtering accuracy and response time when facing this interference under different Nw window sizes:
[0122] (1) Filtering accuracy
[0123] like Fig. 9 and Fig.10 As shown, Fig. 9 The horizontal axis is the time axis, and the vertical axis is the signal amplitude; Fig. 9 The upper part is the comparison between the actual value sampling curve and the filtering curve when the filtering parameters are Nw=256 and Nw=32. Fig. 9 The lower part is a comparison of the filtering curves when the filtering parameters are Nw=256 and Nw=32.
[0124] Fig.10 The upper part is the spectrum diagram of the sampled value actually intercepted by the ADC after passing through the RC low-pass filter. Fig.10 The lower part is the spectrum diagram after removing interference.
[0125] Fig. 9 The lines in the figure represent the following:
[0126] Black line: actual ADC sampling value after external interference;
[0127] Red line: filtering curve when Nw window width is 32;
[0128] Green line: filtering curve when Nw window width is 256;
[0129] The accuracy formula is as follows:
[0130] From the green line, we can see that the frequency range after current filtering is [0.99783, 1.00242]. According to the accuracy formula:
[0131]
[0132] Among them: Range is the maximum range; (0~20MA); MAX_offset is the maximum offset relative to the input; Precision is the precision value;
[0133] The accuracy formula can be used to calculate that when Nw = 256, the accuracy of the curve after suppressing the frequency is When Nw=32, the accuracy of the curve after suppressing the frequency will be It is about 1.9 per thousand. Obviously, the filtering curve when Nw=32 does not meet the standard of 1 per thousand.
[0134] (2) Response time
[0135] like Fig.11 and Fig.12 As shown, Fig.11 The horizontal axis is the time axis, and the vertical axis is the signal amplitude; Fig.11 The upper part is the comparison between the actual value sampling curve and the filtering curve when the filtering parameters are Nw=256 and Nw=32 respectively; Fig.11 The lower part is a comparison of the filtering curves when the filtering parameters are Nw=256 and Nw=32. Fig.11 It mainly shows the response time after filtering under different configuration parameters.
[0136] Fig.12 The upper part is the spectrum diagram of the sampled value actually intercepted by the ADC after passing through the RC low-pass filter. Fig.12 The lower part is the spectrum diagram after removing interference.
[0137] It can be observed from the actual simulation that the response time when Nw=256 is about 962ms; the response time when Nw=32 is about 124ms; but the accuracy when Nw=32 does not currently meet the specified requirement of 1 / 1000.
[0138] Performance optimization:
[0139] By adding a lag filter after the filtering result when Nw=32, the filtering accuracy can be improved with a relatively small response time. The expression of the first-order lag filter is as follows:
[0140] Y[n]=a·Y[n-1]+(1-a)·X[n]
[0141] Where: n represents the data at the nth moment; a is the proportional coefficient, which is used to adjust the ratio of the historical value and the sampled value, and the value range of a is: 0~1; Y[n] is the output value at the nth moment, that is, the output value at the current moment; Y[n-1] is the output value at the n-1th moment, that is, the historical value at the previous moment; X[n] is the sampled value at the nth moment, that is, the sampled value at the current moment.
[0142] Currently, the a value of the lag filter is set to 0.85, and the filtering result when Nw=32 is used as the input of the lag filter. The simulation results are as follows: Fig.13 and Fig.14 As shown, Fig.13 The horizontal axis is the time axis, and the vertical axis is the signal amplitude; Fig.13 The upper part is a comparison of the filtering curves when the filtering parameter is Nw=256 and when the parameter is Nw=32 + first-order lag; Fig.13 The lower part is a comparison of the filtering curves when the filtering parameter is Nw=256 and when the parameter is Nw=32+first-order lag.
[0143] Fig.14 The upper part is the spectrum diagram of the sampled value actually intercepted by the ADC after passing through the RC low-pass filter. Fig.14 The lower part is the spectrum diagram after removing interference.
[0144] The accuracy of adding first-order lag filtering to the filter with Nw=32 is as follows Fig.15 and Fig.16 As shown, Fig.15 The horizontal axis is the time axis, and the vertical axis is the signal amplitude; Fig.15 The upper part is a comparison of the filtering curves when the filtering parameter is Nw=256 and when the parameter is Nw=32 + first-order lag; Fig.15 The lower part is a comparison of the filtering curves when the filtering parameter is Nw=256 and when the parameter is Nw=32+first-order lag. Fig.15 It mainly shows the comparison of their filtering response time.
[0145] Fig.16 The upper part is the spectrum diagram of the sample value actually intercepted by the ADC after passing through the RC low-pass filter. Fig.16 The lower part is the spectrum diagram after removing interference.
[0146] The red curve with hysteresis filtering added has an overall variation range within the green curve, and its accuracy is about 0.3185 thousandths, which is higher than the filtering accuracy when Nw=256.
[0147] Let's look at its response curve: the filter response time of Nw=32 with a first-order lag filter is about 169ms.
[0148] Conclusion: The filter designed at present only needs 1 / 8 of the ROM / RAM consumption when Nw=256, and can achieve 5.7 times shorter response time and higher filtering accuracy.
[0149] The present invention directly uses FFT to filter out the corresponding frequency interference in the frequency domain, and then performs hysteresis smoothing filtering on the signal after the interference is filtered out, and controls its accuracy within a specified range. The scheme of the present invention only consumes a small RAM space and a short response time, and can achieve the corresponding frequency suppression effect and data smoothness. The present invention is mainly used in the filtering processing of the ADC acquisition module in the field of industrial automation.
[0150] Example 2
[0151] like Fig.17As shown, the difference between this embodiment and embodiment 1 is that this embodiment further provides a hysteresis filtering device with frequency interference suppression, and the device uses a hysteresis filtering method with frequency interference suppression in embodiment 1; the device includes:
[0152] An acquisition unit, used for acquiring an ADC sampling signal, where the ADC sampling signal is a sampling signal of an ADC acquisition module in the field of industrial automation;
[0153] A low-pass filtering unit is used to filter the ADC sampling signal using a low-pass filter to filter out high-frequency signals and reduce signal aliasing, thereby obtaining a first processed signal;
[0154] An FFT forward transform unit is used to perform window interception according to the first processed signal to obtain an intercepted signal; and perform FFT forward transform on the intercepted signal to remove the corresponding frequency interference, and use the spectrum without the interference frequency as the second processed signal;
[0155] An IFT inverse transform unit is used to perform an IFT inverse transform on the second processed signal to obtain a time domain signal after the interference frequency is removed, and perform amplitude normalization processing on the time domain signal after the interference frequency is removed to obtain a third processed signal;
[0156] The hysteresis filtering unit is used to perform a second filtering process using a hysteresis filter according to the signal after the third processing to obtain a final filtered signal.
[0157] As a further implementation, the FFT forward transform unit includes:
[0158] A window interception subunit, used for performing window interception according to the first processed signal to obtain an intercepted signal;
[0159] The FFT forward transformation subunit is used to perform FFT forward transformation according to the intercepted signal to obtain the corresponding waveform spectrum;
[0160] The Hamming window subunit is used to process the corresponding waveform spectrum obtained by the forward transformation of the FFT using the Hamming window function, re-adjust the proportions at each frequency domain point, and obtain the second processed signal.
[0161] The execution process of each unit can be performed according to the process steps of a hysteresis filtering method with frequency interference suppression in Example 1, and will not be described in detail in this embodiment.
[0162] At the same time, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the above-mentioned hysteresis filtering method with frequency interference suppression is implemented.
[0163] At the same time, the present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned hysteresis filtering method with frequency interference suppression is implemented.
[0164] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0165] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0166] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0167] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0168] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A hysteresis filtering method with frequency interference suppression, characterized in that: The method includes: Acquire an ADC sampling signal, where the ADC sampling signal is a sampling signal of an ADC acquisition module in the field of industrial automation; Using a low-pass filter to filter the ADC sampling signal, filter out high-frequency signals and reduce signal aliasing, to obtain a first processed signal; According to the first processed signal, window interception is performed to obtain an intercepted signal; and the intercepted signal is subjected to FFT forward transformation to remove the corresponding frequency interference, and the spectrum without the interference frequency is used as the second processed signal; According to the second processed signal, an IFT inverse transform is performed to obtain a time domain signal after the interference frequency is removed, and an amplitude normalization process is performed on the time domain signal after the interference frequency is removed to obtain a third processed signal; According to the signal after the third processing, a lag filter is used to perform filtering again to obtain a final filtered signal.
2. A hysteresis filtering method with frequency interference suppression according to claim 1, characterized in that: The low-pass filter adopts an RC low-pass filter circuit.
3. The hysteresis filtering method with frequency interference suppression according to claim 1, characterized in that: The method also includes: before window interception, storing the first filtered signal in a buffer area.
4. The hysteresis filtering method with frequency interference suppression according to claim 1, characterized in that: According to the first processed signal, window interception is performed to obtain an intercepted signal; and the intercepted signal is subjected to FFT forward transformation to remove the corresponding frequency interference, and the spectrum without the interference frequency is used as the second processed signal, including: Performing window interception according to the first processed signal to obtain an intercepted signal; According to the intercepted signal, FFT forward transformation is performed to obtain a corresponding waveform spectrum; The corresponding waveform spectrum obtained by the forward transformation of FFT is processed by using the Hamming window function, and the proportions of various frequency domain points are readjusted to obtain the second processed signal.
5. The hysteresis filtering method with frequency interference suppression according to claim 1, characterized in that: The Hamming window function is used to process the frequency domain signal obtained by FFT forward transformation. The expression is: Among them: g(t) is the time domain input; h(t) is the time domain Hamming window function; G(w) is the frequency domain input; H(w) is the frequency domain Hamming window function; F[.] is the Fourier transform process.
6. The hysteresis filtering method with frequency interference suppression according to claim 1, characterized in that: The lag filter adopts a first-order lag filter, and the expression is: Y[n]=a·Y[n-1]+(1-a)·X[n] Where: n represents the data at the nth moment; a is the proportional coefficient, which is used to adjust the ratio of the historical value and the sampled value, and the value range of a is: 0~1; Y[n] is the output value at the nth moment, that is, the output value at the current moment; Y[n-1] is the output value at the n-1th moment, that is, the historical value at the previous moment; X[n] is the sampled value at the nth moment, that is, the sampled value at the current moment.
7. A hysteresis filter device with frequency interference suppression, characterized in that: The device uses a hysteresis filtering method with frequency interference suppression as described in any one of claims 1 to 6; the device comprises: An acquisition unit, used for acquiring an ADC sampling signal, wherein the ADC sampling signal is a sampling signal of an ADC acquisition module in the field of industrial automation; A low-pass filtering unit, configured to filter the ADC sampling signal using a low-pass filter, filter out high-frequency signals and reduce signal aliasing, and obtain a first processed signal; An FFT forward transform unit is used to perform window interception according to the first processed signal to obtain an intercepted signal; and perform FFT forward transform on the intercepted signal to remove the corresponding frequency interference, and use the spectrum without the interference frequency as the second processed signal; An IFT inverse transform unit, configured to perform an IFT inverse transform on the second processed signal to obtain a time domain signal after the interference frequency is removed, and perform amplitude normalization processing on the time domain signal after the interference frequency is removed to obtain a third processed signal; The hysteresis filtering unit is used to perform a second filtering process using a hysteresis filter according to the signal after the third processing to obtain a final filtered signal.
8. A hysteresis filter device with frequency interference suppression according to claim 7, characterized in that: The FFT forward transform unit comprises: A window interception subunit, configured to perform window interception according to the first processed signal to obtain an intercepted signal; An FFT forward transformation subunit is used to perform an FFT forward transformation on the intercepted signal to obtain a corresponding waveform spectrum; The Hamming window subunit is used to process the corresponding waveform spectrum obtained by the forward transformation of the FFT using the Hamming window function, re-adjust the proportions at each frequency domain point, and obtain the second processed signal.
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 computer program, the hysteresis filtering method with frequency interference suppression as described in any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the hysteresis filtering method with frequency interference suppression as claimed in any one of claims 1 to 6 is implemented.