Second order IIR filter
By temporarily outputting the old filtered output signal after the filter coefficients change and then outputting the latest signal after stabilization, the noise problem of the second-order IIR filter when the coefficients change is solved, ensuring the stability and quality of the signal.
Patent Information
- Application Number
- CN202511366150.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-23
- Publication Date
- 2026-01-13
AI Technical Summary
When the filter coefficients of a second-order IIR filter change, noise significantly affects the subsequent application of the sensor signal.
For a period of time after the filter coefficients change, the latest filter output signal is not output. Instead, the filter output signal at the last moment before the filter coefficients are updated is output. The latest filter output signal is output after it stabilizes. The control unit determines whether to update the filter coefficients based on the frequency information of the input signal, and performs filtering processing based on the latest filter coefficients immediately after the filter coefficients are updated.
This avoids noise in the output signal, ensuring signal stability and quality.
Smart Images

Figure CN121333266A_ABST
Abstract
Description
[Technical Field]
[0001] This invention relates to the field of filters, and more particularly to a second-order IIR (Infinite Impulse Response) filter. [Background Technology]
[0002] The typical formula for calculating a second-order IIR filter is: y t =b0*x t +b1*x t-1 +b2*x t-2 +a1*y t-1 +a2*y t-2 Where b0, b1, b2, a1, and a2 are filter coefficients, t is the current time, t-1 is the previous time, t-2 is the time two moments before, and x... t Let x be the current input signal. t-1 Let x be the input signal from the previous time step. t-2 Let y be the input signal from the previous two moments. t For the current filtered output signal, y t-1 The filtered output signal from the previous moment, y t-2 This is the filtered output signal from the previous two moments.
[0003] When the filter coefficients of a second-order IIR filter change, due to y t-1 y t-2 The output values of the old filter coefficients are still stored in the filter, which will cause noise in the filtered result. The greater the change in the filter coefficients, the more obvious the noise will be. If it is not processed, it will affect the subsequent application of the sensor signal. [Summary of the Invention]
[0004] To solve the above-mentioned technical problems, or at least partially solve them, embodiments of the present invention provide a second-order IIR filter.
[0005] According to one aspect of the present invention, an embodiment of the present invention provides a second-order IIR filter, comprising: a second-order IIR filtering unit, which filters an input signal based on the latest filter coefficients to obtain a filtered output signal; a control unit, which determines whether the filter coefficients need to be updated based on the frequency information of the input signal, calculates the latest filter coefficients based on the frequency information of the input signal when the filter coefficients need to be updated, and provides the latest filter coefficients to the second-order IIR filtering unit for updating; the second-order IIR filtering unit immediately filters the input signal based on the latest filter coefficients after updating the filter coefficients and obtains a filtered output signal, and for N output moments after updating the filter coefficients, the last filtered output signal output by the second-order IIR filtering unit before the filter coefficients are updated is continuously used as the output signal of the second-order IIR filter, during which the filtered output signal obtained by the second-order IIR filtering unit is not used as the output signal of the second-order IIR filter, and from the (N+1)th output moment after updating the filter coefficients, the latest filtered output signal obtained by the second-order IIR filtering unit is continuously used as the output signal of the second-order IIR filter, where N is a natural number greater than or equal to 1.
[0006] Compared with the prior art, the present invention does not output the latest filtered output signal for a period of time after the filter coefficients change. Instead, it outputs the filtered output signal at the last moment before the filter coefficients are updated. The latest filtered output signal is output after it stabilizes, thus avoiding noise in the output signal. [Attached Image Description]
[0007] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:
[0008] Figure 1 A block diagram of a second-order IIR filter provided for embodiments of the present invention;
[0009] Figure 2 The waveform diagram of the output signal of the second-order IIR filter provided by this invention before and after the filter coefficient update is shown.
Detailed Implementation Methods
[0010] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0011] The term "an 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 invention. The phrase "in one embodiment" appearing in different places throughout this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.
[0012] An embodiment of the present invention provides a second-order IIR filter that, after a change in the filter coefficients, does not output the latest filtered output signal for a period of time, but instead outputs the filtered output signal at the last moment before the filter coefficients are updated, and outputs the latest filtered output signal after it has stabilized. This avoids noise in the output signal.
[0013] Figure 1 A block diagram of a second-order IIR filter is provided for an embodiment of the present invention. For example... Figure 1 As shown, the second-order IIR filter includes a second-order IIR filter unit 110, a control unit 120, and an output unit 130.
[0014] The second-order IIR filter unit 110 filters the input signal based on the latest filter coefficients to obtain a filtered output signal.
[0015] Specifically, the calculation formula for the second-order IIR filter unit is as follows:
[0016] y t =b0*x t +b1*x t-1 +b2*x t-2 +a1*y t-1 +a2*y t-2 ,
[0017] Where b0, b1, b2, a1, and a2 are filter coefficients, t is the current time, t-1 is the previous time, t-2 is the time two moments before, and x... t Let x be the current input signal. t-1 Let x be the input signal from the previous time step. t-2 Let y be the input signal from the previous two moments. t Let y be the current filtered output signal of the second-order IIR filter unit. t-1 The filtered output signal from the previous moment, y t-2 This is the filtered output signal from the previous two moments.
[0018] The control unit 120 determines whether the filter coefficients need to be updated based on the frequency information of the input signal. If the filter coefficients need to be updated, it calculates the latest filter coefficients based on the frequency information of the input signal and provides the latest filter coefficients to the second-order IIR filter unit 110 for updating. After updating the filter coefficients, the second-order IIR filter unit 110 immediately performs filtering processing on the input signal based on the latest filter coefficients and obtains a filtered output signal.
[0019] For N output moments after the filter coefficients are updated, the output unit 130 continuously uses the last filtered output signal of the second-order IIR filter unit 110 before the filter coefficients are updated as the output signal of the second-order IIR filter. During this period, the filtered output signal obtained by the second-order IIR filter unit is not used as the output signal of the second-order IIR filter. Starting from the (N+1)th output moment after the filter coefficients are updated, the latest filtered output signal obtained by the second-order IIR filter unit is continuously used as the output signal of the second-order IIR filter, where N is a natural number greater than or equal to 1.
[0020] In one embodiment, if the filter coefficients remain unchanged at time t, but have been updated at time t+1, then:
[0021] For time t, the filtered output signal y of the second-order IIR filter unit 110 t The output signal Y of the second-order IIR filter t That is, Y t =y t ;
[0022] For times t+1 to t+N, the last filtered output signal y output by the second-order IIR filter unit 110 before the filter coefficients are updated is continuously applied. t The output signal Y of the second-order IIR filter t+i That is, Y t+i =y t Where i is greater than or equal to 1 and less than or equal to N, at this stage, the second-order IIR filter unit 110 still filters the input signal based on the latest filter coefficients and obtains the filtered output signal y. t+i However, the filtered output signal y t+i It was not used as the output signal of the second-order IIR filter, where:
[0023] y t+i =b0*x t+i +b1*x t+i-1 +b2*x t+i-2 +a1*y t+i-1 +a2*yt+i-2 ;
[0024] For time t+N+j, the latest filtered output signal y is obtained by continuously filtering the second-order IIR filter unit 110. t+N+j The output signal Y of the second-order IIR filter t+N+j j is a natural number greater than or equal to 1.
[0025] The choice of N is one of the key and important aspects of this invention. In one embodiment, the value of N can be determined based on the stability constant and the filter coefficient a2, wherein the stability constant is related to the difference between the filtered output signal of the second-order IIR filter unit 110 and the stable value after the output stabilizes.
[0026] In one embodiment, Where a2 represents the filter coefficients before or after the update, and α is the stability constant. This is for rounding down. Preferably, a2 represents the filter coefficients before the update.
[0027] For example, if the difference between the filtered output signal of the second-order IIR filter unit 110 and the stable value after output stabilization is within 1% after the filter coefficients change, it can be determined that the system has no jitter, and the stability constant α is set to 0.01 in this example. As another example, if the difference between the filtered output signal of the second-order IIR filter unit 110 and the stable value after output stabilization is within 2% after the filter coefficients change, it can be determined that the system has no jitter, and the stability constant α is set to 0.02 in this example. In one embodiment, the value of α can be in the range of 0.005-0.03. Preferably, the value of N can be calculated by the control unit and provided to the output unit; alternatively, the value of N can be calculated by the output unit 130.
[0028] When the control unit 120 provides the latest filter coefficients to the second-order IIR filter unit 110 for updating, it sends a parameter update notification to the output unit 130 so that the output unit 130 knows when the filter coefficients are updated.
[0029] Figure 2 The diagram shows the waveforms of the output signal of the second-order IIR filter provided by this invention before and after the filter coefficients are updated. Figure 2 As shown, the filter coefficients are the original values at 0 seconds, and are updated to the latest values at the next time step. The output signal Y of the second-order IIR filter is calculated over a period of time starting from 0 seconds (duration is N cycles, N=9 in this example). t+i Always for Y t At this time, the second-order IIR filter unit 110 obtains the filtered output signal y. t+iIt is not output, but only used as an internal operating value; at time t+9+j, it reaches stability, and the latest filtered output signal y is obtained by continuously filtering the second-order IIR filter unit 110. t+9+j The output signal Y of the second-order IIR filter t+9+j .
[0030] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. In addition, those skilled in the art can combine and integrate the different embodiments or examples described in this specification.
[0031] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications and variations to the above embodiments within the scope of the present invention.
Claims
1. A second-order IIR filter, characterized in that, It includes: The second-order IIR filter unit filters the input signal based on the latest filter coefficients to obtain the filtered output signal. The control unit determines whether the filter coefficients need to be updated based on the frequency information of the input signal. When the filter coefficients need to be updated, it calculates the latest filter coefficients based on the frequency information of the input signal and provides the latest filter coefficients to the second-order IIR filtering unit for updating. After updating the filter coefficients, the second-order IIR filtering unit immediately performs filtering processing on the input signal based on the latest filter coefficients and obtains the filtered output signal. The output unit continuously uses the last filtered output signal of the second-order IIR filter unit before the filter coefficients are updated as the output signal of the second-order IIR filter for N output moments after the filter coefficients are updated. During this period, the filtered output signal obtained by the second-order IIR filter unit is not used as the output signal of the second-order IIR filter. Starting from the (N+1)th output moment after the filter coefficients are updated, the latest filtered output signal obtained by the second-order IIR filter unit is continuously used as the output signal of the second-order IIR filter, where N is a natural number greater than or equal to 1.
2. The second-order IIR filter according to claim 1, characterized in that, The calculation formula for the second-order IIR filter unit is as follows: y t =b0*x t +b1*x t-1 +b2*x t-2 +a1*y t-1 +a2*y t-2 , Where b0, b1, b2, a1, and a2 are filter coefficients, t is the current time, t-1 is the previous time, t-2 is the time two moments before, and x... t Let x be the current input signal. t-1 Let x be the input signal from the previous time step. t-2 Let y be the input signal from the previous two moments. t Let y be the current filtered output signal of the second-order IIR filter unit. t-1 The filtered output signal from the previous moment, y t-2 This is the filtered output signal from the previous two moments.
3. The second-order IIR filter according to claim 2, characterized in that, If the filter coefficients remain unchanged at time t, and have been updated at time t+1, then: For time t, the filtered output signal y of the second-order IIR filter unit t The output signal Y of the second-order IIR filter t That is, Y t =y t ; For times t+1 to t+N, continuously apply the last filtered output signal y from the second-order IIR filter unit before the filter coefficients are updated. t The output signal Y of the second-order IIR filter t+i That is, Y t+i =y t Where i is greater than or equal to 1 and less than or equal to N, at this stage, the second-order IIR filter unit still filters the input signal based on the latest filter coefficients and obtains the filtered output signal y. t+i However, the filtered output signal y t+i It was not used as the output signal of the second-order IIR filter, where: y t+i =b0*x t+i +b1*x t+i-1 +b2*x t+i-2 +a1*y t+i-1 +a2*y t+i-2 ; For time t+N+j, the latest filtered output signal y is obtained by continuously filtering the second-order IIR filter unit. t+N+j The output signal Y of the second-order IIR filter t+N+j j is a natural number greater than or equal to 1.
4. The second-order IIR filter according to claim 2, characterized in that, The value of N is determined based on the stability constant and the filter coefficient a2, where the stability constant is related to the difference between the filtered output signal of the second-order IIR filter unit and the stable value after the output stabilizes.
5. The second-order IIR filter according to claim 4, characterized in that, Where a2 represents the filter coefficients before or after the update, and α is the stability constant. This is for rounding down.
6. The second-order IIR filter according to claim 5, characterized in that, The value of α ranges from 0.005 to 0.
03.
7. The second-order IIR filter according to claim 1, characterized in that, The control unit calculates the value of N and provides the value of N to the output unit.
8. The second-order IIR filter according to claim 1, characterized in that, The control unit sends a parameter update notification to the output unit when it provides the latest filter coefficients to the second-order IIR filter unit for updating.
