Obtaining the frequency response of the filter from the impulse response. Finite impulse response filter

Lecture #10

"Finite Impulse Response Digital Filters"

Transmission function physically implemented digital filter with a finite impulse response (FIR filter) can be represented as

(10.1).

When replacing in expression (10.1), we obtain the frequency response of the FIR filter in the form

(10.2),

Where - amplitude-frequency characteristic (AFC) filter,

- phase-frequency characteristic (PFC) filter.

Phase delay filter is defined as

(10.3).

group delay filter is defined as

(10.4).

A distinctive feature of FIR filters is the possibility of implementing constant phase and group delays in them, i.e. linear phase response

(10.5),

where a - constant. Under this condition, the signal passing through the filter does not distort its shape.

To derive conditions that provide a linear phase response, we write the frequency response of the FIR filter, taking into account (10.5)

(10.6).

Equating the real and imaginary parts of this equality, we obtain

(10.7).

Dividing the second equation by the first, we get

(10.8).

Finally, you can write

(10.9).

This equation has two solutions. First at a =0 corresponds to the equation

(10.10).

This equation has a unique solution corresponding to an arbitrary h(0)(sin(0)=0), and h(n)=0 for n >0. This solution corresponds to a filter whose impulse response has a single non-zero sample at the initial time. Such a filter is not of practical interest.

Let's find another solution for . At the same time, having cross-multiplied the numerators and denominators in (10.8), we obtain

(10.11).

Hence we have

(10.12).

Since this equation has the form of a Fourier series, its solution, if it exists, is unique.

It is easy to see that the solution of this equation must satisfy the conditions

(10.13),

(10.14).

It follows from condition (10.13) that for each order of the filter N there is only one phase delay a , at which strict linearity of the PFC can be achieved. From condition (10.14) it follows that the impulse response of the filter must be symmetric about the point for odd N , and relative to the midpoint of the interval (Fig. 10.1).



The frequency response of such a filter (for an odd N ) can be written as

(10.15).

Making the substitution in the second sum m = N -1- n , we get

(10.16).

Since h (n)= h (N -1- n ), then the two sums can be combined


(10.17).

Substituting , we get

(10.18).

If we designate

(10.19),

then we can finally write

(10.20).

Thus, for a filter with a linear phase response, we have

(10.21).

For the case of even N similarly we will have

(10.22).

Making a substitution in the second sum , we get

(10.23).

Making the substitution, we get

(10.24).

Denoting

(10.25),

we will finally have

(10.26).

Thus, for a FIR filter with linear phase response and even order N can be written

(10.27).

In what follows, for simplicity, we will consider only filters with an odd order.

When synthesizing the filter transfer function, the initial parameters are, as a rule, the requirements for the frequency response. There are many techniques for synthesizing FIR filters. Let's consider some of them.

Since the frequency response of any digital filter is a periodic function of frequency, it can be represented as a Fourier series

(10.28),

where the coefficients of the Fourier series are

(10.29).

It can be seen that the coefficients of the Fourier series h(n ) coincide with the coefficients impulse response filter. Therefore, if the analytical description of the required frequency response of the filter is known, then it can be used to easily determine the coefficients of the impulse response, and from them the transfer function of the filter. However, this is not feasible in practice, since the impulse response of such a filter has an infinite length. In addition, such a filter is not physically realizable since the impulse response begins at -¥ , and no finite delay will make this filter physically realizable.

One possible method for obtaining a FIR filter that approximates a given frequency response is to truncate the infinite Fourier series and the impulse response of the filter, assuming that h(n)=0 for . Then

(10.30).

Physical realizability of the transfer function H(z ) can be achieved by multiplying H (z ) on .

(10.31),

Where

(10.32).

With this modification of the transfer function, the amplitude characteristic of the filter does not change, and the group delay increases by a constant value.

As an example, we calculate a low-pass FIR filter with a frequency response of the form

(10.33).

In accordance with (10.29), the filter impulse response coefficients are described by the expression

(10.34).

Now from (10.31) we can get the expression for the transfer function

(10.35),

Where

(10.36).

The amplitude characteristics of the calculated filter for various N presented in Figure 10.2.

Fig.10.2

Ripple in the passband and stopband occurs due to the slow convergence of the Fourier series, which, in turn, is due to the presence of a discontinuity in the function at the cutoff frequency of the passband. These pulsations are known as Gibbs pulsations.

From Fig. 10.2 it can be seen that with an increase N the pulsation frequency increases, and the amplitude decreases both at the lower and at upper frequencies. However, the amplitude of the last ripple in the passband and the first ripple in the stopband remain practically unchanged. In practice, such effects are often undesirable, which requires finding ways to reduce Gibbs ripples.

Truncated impulse response h(n ) can be represented as the product of the required infinite impulse response and some window functions w (n) of length n (Fig. 10.3).

(10.37).



In the considered case of a simple truncation of the Fourier series, we use rectangular window

(10.38).

In this case, the frequency response of the filter can be represented as a complex convolution

(10.39).

This means that will be a "blurred" version of the required characteristic.

The problem is reduced to finding window functions that make it possible to reduce Gibbs ripples for the same filter selectivity. To do this, you must first study the properties of the window function using the example of a rectangular window.

The spectrum of the rectangular window function can be written as

(10.40).

The spectrum of the rectangular window function is shown in Fig. 10.4.

Fig.10.4

Since at , then the width of the main lobe of the spectrum is equal to .

The presence of side lobes in the spectrum of the window function leads to an increase in the Gibbs ripple in the frequency response of the filter. To obtain small ripple in the passband and high attenuation in the stopband, it is necessary that the area bounded by the side lobes is a small fraction of the area bounded by the main lobe.

In turn, the width of the main lobe determines the width of the transition zone of the resulting filter. For high filter selectivity, the width of the main lobe should be as small as possible. As can be seen from the above, the width of the main lobe decreases with increasing filter order.

Thus, the properties of suitable window functions can be formulated as follows:

- the window function must be limited in time;

- the spectrum of the window function should best approximate the frequency-limited function, i.e. have a minimum of energy outside the main lobe;

- the width of the main lobe of the spectrum of the window function should be as small as possible.

The most commonly used window functions are:

1. Rectangular window. Considered above.

2. Hamming window.

(10.41),

Where .

When this window is called the Hann window ( hanning).

3. Blackman window.


(10.42).

4. Bartlett window.

(10.43).

The indicators of filters built using the specified window functions are summarized in Table 10.1.

Window

Main lobe width

Pulsation factor, %

N=11

N=21

N=31

Rectangular

22.34

21.89

21.80

Hanning

2.62

2.67

2.67

Hamming

1.47

0.93

0.82

Blackman

0.08

0.12

0.12

The ripple factor is defined as the ratio of the maximum sidelobe amplitude to the mainlobe amplitude in the spectrum of the window function.

The data in Table 10.2 can be used to select the required filter order and the most appropriate window function when designing real filters.

transitional

unevenness

transmission (dB)

Decay in

barrage (dB)

Rectangular

Hanning

Hamming

Blackman

As can be seen from Table 10.1, there is a definite relationship between the ripple factor and the width of the main lobe in the spectrum of the window function. The smaller the ripple coefficient, the greater the width of the main lobe, and hence the transition zone in the filter's frequency response. To ensure low ripple in the passband, it is necessary to choose a window with a suitable ripple factor, and to provide the required width of the transition zone with an increased filter order N .

This problem can be solved using the window proposed by Kaiser. The Kaiser window function has the form

(10.44),

where a is an independent parameter, , I 0 is the zero-order Bessel function of the first kind, defined by the expression

(10.45).

An attractive property of the Kaiser window is the ability to smoothly change the ripple coefficient from small to large values, when only one parameter a is changed. In this case, as for other window functions, the width of the main lobe can be controlled by the filter order N .

The main parameters set when developing a real filter are:

Bandwidth - w p ;

Barrier - w a ;

The maximum allowable ripple in the passband - A p ;

Minimum attenuation in the stopband - A a ;

-sampling frequency - w s .

These parameters are illustrated in Figure 10.5. In this case, the maximum ripple in the passband is defined as

(10.46),

and the minimum attenuation in the stopband as

A relatively simple procedure for calculating a filter with a Kaiser window includes the following steps:

1. The impulse response of the filter h (n) is determined, provided the frequency response is ideal

(10.48),

where (10.49).

2. The parameter d is chosen as

(10.50),

Where (10.51).

3. The true value of A a and A p is calculated according to formulas (10.46), (10.47).

4. The parameter a is selected as

(10.52).

5. The parameter D is selected as

(10.53).

6. The smallest odd value of the filter order is selected from the condition

(10.54),

(10.57)

follows that

Since the samples of the filter's impulse response are the coefficients of its transfer function, condition (10.59) means that the codes of all filter coefficients contain only a fractional part and a sign bit and do not contain an integer part.

The number of digits of the fractional part of the filter coefficients is determined from the condition of satisfying the transfer function of the filter with quantized coefficients, the specified requirements for approaching the reference transfer function with exact values ​​of the coefficients.

The absolute values ​​of the filter input samples are usually normalized so that

If the analysis is carried out for a FIR filter with a linear phase response, then the algorithm for calculating its output signal can be as follows

where are the filter coefficients rounded up to s k.

This algorithm corresponds structural scheme filter shown in Figure 10.5.



There are two ways to implement this algorithm. In the first case, all multiplication operations are performed exactly and there is no rounding of products. In this case, the capacity of the products is s in +s k , where s in is the capacity input signal, and s k is the capacity of the filter coefficients. In this case, the block diagram of the filter shown in Fig. 10.5 corresponds exactly to the real filter.

In the second way of implementing the algorithm (10.61), each result of the multiplication operation is rounded, i.e. products are calculated with some error. In this case, it is necessary to change the algorithm (10.61) so as to take into account the error introduced by rounding the products

If the sample values ​​of the output signal of the filter are calculated by the first method (with exact values ​​of the products), then the variance of the output noise is defined as

(10.66),

those. depends on the variance of the rounding noise of the input signal and the values ​​of the filter coefficients. From here you can find the required number of bits of the input signal as

(10.67).

From the known values ​​of s in and s k, one can determine the number of bits required for the fractional part of the output signal code as

If the values ​​of the samples of the output signal are calculated according to the second method, when each product is rounded up to s d bits, then the variance of the rounding noise created by each of the multipliers can be expressed in terms of the word length of the product as

DR in and signal-to-noise ratio at the output of the filter SNR out . The value of the dynamic range of the input signal in decibels is defined as

(10.74),

where A max and A min are the maximum and minimum amplitudes of the filter input signal.

The signal-to-noise ratio at the output of the filter, expressed in decibels, is defined as

(10.75),

determines the root mean square value of the power of the output sinusoidal signal of the filter with amplitude A min , and

(10.77)

determines the noise power at the output of the filter. From (10.75) and (10.76) with A max =1 we obtain an expression for the variance of the output noise of the filter

(10.78).

This filter output noise variance value can be used to calculate the filter input and output signal widths.

Let's consider the simplest digital filters - filters with constant parameters.

An input signal is applied to the input of the digital filter in the form of a sequence of numerical values ​​following with an interval (Fig. 4.1, a). When each next signal value arrives in the digital filter, the next value of the output signal is calculated. Calculation algorithms can be very diverse; during the calculation, except for the last value of the input signal can be used

previous values ​​of the input and output signals: The signal at the output of the digital filter is also a sequence of numerical values ​​following with an interval of . This interval is the same for the entire digital signal processing device.

Rice. 4.1. Signal at the input and output of the digital filter

Therefore, if the simplest signal in the form of a single pulse is applied to the input of the digital filter (Fig. 4.2, a)

then at the output we will receive a signal in the form of a discrete sequence of numerical values ​​following with an interval

By analogy with conventional analog circuits, let's call this response signal the impulse response of the filter (Fig. 4.2, b). Unlike the impulse response of an analog circuit, the function is dimensionless.

Rice. 4.2. Unit pulse and digital filter impulse response

Let's feed an arbitrary filter input discrete signal rice. 4.1, a), which is a set of discrete values

Under the action of the first element, at the output of the filter, a sequence multiplied by is formed; under the action, a sequence multiplied by and shifted to the right by a value, etc. As a result, we get a sequence at the output with

Thus, the output signal is defined as the discrete convolution of the input signal and the impulse response. In this respect, digital filters are similar to conventional circuits, where the output signal is equal to the convolution of the input signal and the impulse response.

Formula (4.1) is an algorithm digital filtering. If the impulse response of the filter is described by a sequence with a finite number of terms, then the filter can be implemented in the form of the circuit shown in Fig. 4.3. Here, the letter denotes the elements of the signal delay for time (per cell); -elements that multiply the signal by the corresponding coefficient.

The scheme shown in fig. 4.3 is not a digital filter circuitry; this scheme is graphic image digital filtering algorithm and shows the sequence of arithmetic operations performed during signal processing.

Rice. 4.3. Non-recursive digital filter circuit

For digital filters that process signals in the form of abstract numerical sequences, the concept of "time delay" is not entirely correct. Therefore, the elements that delay the signal by one cell are usually marked on the digital filter circuits with a symbol denoting the signal delay in the language of -transformations. In what follows, we will adhere to this notation.

Let us return to the digital filter circuit shown in Fig. 4.3, Such filters, where only the values ​​of the input signal are used for calculation, are called simple or non-recursive.

The non-recursive filter algorithm is easy to write if the impulse response of the filter is known. For practical implementation algorithm requires that the impulse response contains a finite number of terms. If the impulse response contains an infinite number of terms, but they decrease rapidly in magnitude, then you can limit yourself to a finite number of terms, discarding those whose values ​​are small. If the elements of the impulse response do not decrease in magnitude, the non-recursive filter algorithm turns out to be unrealizable.

Rice. 4.4. -chain

As an example, consider the simplest digital filter, similar to the -circuit (Fig. 4.4). The impulse response of the -circuit has the form

To write the impulse response of the corresponding digital filter, the expression should be replaced by. However, the impulse response of a -circuit has a dimension, and the impulse response of a digital filter must be dimensionless. Therefore, we omit the factor in expression (4.2) and write the impulse response of the digital filter in the form

Such an impulse response contains infinitely many terms, but their magnitude decreases exponentially, and one can limit oneself to terms, choosing such that

Now you can write an expression for the signal at the output of the filter

This expression is also a digital filter algorithm. The scheme of this filter is shown in fig. 4.5.

The second approach to the analysis of processes in digital filters is similar to the operator method of analyzing conventional analog circuits, but instead of the Laplace transform, the -transform is used.

Rice. 4.5. Scheme of a non-recursive digital filter similar to -circuit

Let us define a digital filter parameter similar to the transfer function electrical circuit. To do this, apply the -transformation to the impulse response of the digital filter:

The function is called the system filter function.

In accordance with expression (4.1), the signal at the output of the digital filter is equal to the discrete convolution of the input signal and the impulse response of the filter. Applying the convolution -transform theorem to this expression, we get that the -transform of the output signal is equal to the -transform of the input signal, multiplied by the system filter function:

Thus, the system function plays the role of the transfer function of the digital filter.

As an example, let's find the system function of a first-order digital filter, similar to a -chain:

The third method of analyzing the passage of signals through digital filters is similar to the classical method of differential equations. Let's consider this method using order chains as an example.

The simplest analog circuit of the 1st order is the -circuit (see Fig. 4.4), the passage of signals through which is described by the differential equation

For a discrete circuit, instead of the differential equation (4.8), a difference equation should be written, where the input and output signals are given for discrete times, and instead of the derivative, the difference of neighboring signal values ​​should appear. For a discrete circuit of the 1st order, the difference equation can be written in a fairly general form

Let's apply to the equation -transformation

where we find the system filter function

Formula (4.10) is a fairly general expression for system function 1st order digital filter. For , it coincides with the previously obtained expression (4.7) for the system function of a digital filter equivalent to a -circuit.

Let us find the digital filtering algorithm corresponding to the system function (4.10). To do this, we solve equation (4.9) with respect to

The equivalent circuit of this algorithm is shown in fig. 4.6. Compared to the non-recursive filter (see Fig. 4.5), a kind of “feedback loop” has been added here, which means that the values ​​of the output signal are used in subsequent

Rice. 4.6. Scheme of a recursive digital filter similar to -circuit

calculations. Filters of this type are called recursive.

Algorithm (4.11) corresponds to a filter that is completely equivalent to the non-recursive filter considered earlier. But to determine one value of the output signal using the non-recursive filter algorithm (4.4), it is required to perform operations, and when using the recursive filter algorithm (4.11), only two operations are required. This is the main advantage of recursive filters. In addition, recursive filters allow you to process the signal with higher accuracy, as they allow you to more correctly implement the impulse response without discarding its "tail". Recursive filters allow you to implement algorithms that are generally unrealizable using non-recursive filters. For example, for a filter operating according to the scheme of Fig. 4.6 is, in essence, an ideal storage integrator and has an impulse response of the form A filter with such a characteristic cannot be implemented in a non-recursive scheme.

The considered examples show that it makes no sense to use non-recursive algorithms to create digital filters with a long impulse response. In these cases, it is more appropriate to use recursive filters.

The scope of non-recursive algorithms is the implementation of digital filters with an impulse response containing a small number of terms. An example is the simplest differentiator, the output signal of which is equal to the increment of the input signal:

The scheme of such a digital filter is shown in Fig. 4.7.

Rice. 4.7. Scheme of the simplest digital differentiator

Consider now a general digital filter, which is described by the equation

This equation can be considered both as a difference order equation and as a digital filtering algorithm, if it is rewritten in a different way, namely

Rice. 4.8. Scheme of a recursive digital order filter

Algorithm (4.13) corresponds to the circuit shown in fig. 4.8. Let's find the system function of such a filter. To do this, apply to the equation -transformation:

Expression (4.14) makes it possible to establish a connection between the sweeps of the elements of the filter circuit and the system function. The coefficients in the numerator of the system function determine the values ​​of the coefficients at

(in the non-recursive part of the filter), and the coefficients in the denominator determine the recursive part of the filter.

Finite impulse response filter (Non-recursive filter, FIR filter) or FIR filter (FIR short for finite impulse response - finite impulse response) - one of the types of linear digital filters, a characteristic feature of which is the limited time of its impulse response (from some point in time it becomes exactly zero). Such a filter is also called non-recursive due to the lack of feedback. The denominator of the transfer function of such a filter is a certain constant.

Dynamic characteristics

where is the delta function. Then the impulse response of the FIR filter can be written as:

#define N 100 // filter order float h[N] = ( #include "f1.h" ); //insert file with known filter coefficients float x[N] ; float y[N] ; short my_FIR(short sample_data) ( float result = 0 ; for ( int i = N - 2 ; i >= 0 ; i-- ) ( x[ i + 1 ] = x[ i] ; y[ i + 1 ] = y[ i] ; ) x[ 0 ] = (float ) sample_data; for (int k = 0 ; k< N; k++ ) { result = result + x[ k] * h[ k] ; } y[ 0 ] = result; return ((short ) result) ; }

see also

Links

  • Calculation of an FIR filter with a linear phase response using the frequency sampling method

Wikimedia Foundation. 2010 .

  • Romodin, Vladimir Alexandrovich
  • Vokhma (river)

See what "Finite Impulse Response Filter" is in other dictionaries:

    Filter - get a valid BeTechno promo code at Akademika or buy a filter at a discount on sale at BeTechno

    finite impulse response filter- - Telecommunication topics, basic concepts EN finite impulse response (filter) FIR ... Technical Translator's Handbook

    Infinite impulse response filter- (Recursive filter, IIR filter) or IIR filter (IIR short for infinite impulse response, infinite impulse response) a linear electronic filter that uses one or more of its outputs as an input, that is ... ... Wikipedia

    FIR filter

    Non-recursive filter- A filter with a finite impulse response (non-recursive filter, FIR filter, FIR filter) is one of the types of linear electronic filters, a characteristic feature of which is the time limitation of its impulse response (from which ... Wikipedia

    Recursive filter- Filter with infinite impulse response (Recursive filter, IIR filter) is a linear electronic filter that uses one or more of its outputs as an input, that is, it forms feedback. The main property of such filters is ... Wikipedia

    digital filter- Digital filter in electronics, any filter that processes a digital signal in order to highlight and / or suppress certain frequencies of this signal. Unlike digital, an analog filter deals with an analog signal, its properties ... ... Wikipedia

    discrete filter- Digital filter in electronics, any filter that processes a digital signal in order to highlight and / or suppress certain frequencies of this signal. Unlike a digital analog filter, it deals with an analog signal, its properties are non-discrete, ... ... Wikipedia

    Line filter- Linear filter is a dynamic system that uses a certain linear operator to the input signal to emphasize or suppress certain signal frequencies and other functions for processing the input signal. Linear filters are widely used in ... ... Wikipedia

    Moving average (filter)- This term has other meanings, see Moving Average (disambiguation). Block diagram of a simple second-order FIR filter that implements a moving average Moving average, moving average is a kind of digital filter with ... ... Wikipedia

    Moving Average (values)- Moving average, moving average (eng. moving average): Moving average of a family of functions, the value of which at each point of definition is equal to the average value of the original function for the previous period. Moving average ... ... Wikipedia

  • 7 General information about signals. Signal classification.
  • 8 Forms of representation of signals. Analog, discrete, digital signals.
  • 9 Deterministic and random signals: periodic, almost periodic, transient, stationary, ergodic, non-stationary.
  • 10 Calculation of numerical characteristics of signals
  • 11 Parameters characterizing the waveform
  • 12 Integration of polyharmonic signals in the frequency domain
  • 13 Formation of periodic signals. tabular way.
  • 14 Formation of polyharmonic signals.
  • 15 Single impulse. Representation of discrete signals.
  • 16 Discretization of continuous signals. Theorem of Kotelnikov. Nyquist frequency.
  • 17 Linear systems invariant to shift.
  • 18 Impulse response of linear systems. Stability and physical feasibility.
  • 19 Fourier series and integral Fourier transform. Fourier series in complex form.
  • 20 Fourier transform for a rectangular pulse.
  • 21 Representation of a periodic sequence of single pulses in the frequency domain.
  • 23 Fast Fourier Transform. Algorithm with thinning in time. (tsos_materials_of lectures 24-30)
  • 24 Binary inversion algorithm. Basic FFT operation. (26-30)
  • 25 Using FFT to process real sequences. (tsos_materials_of lectures 29-31)
  • 26 The concept of a linear discrete system//method 8.1
  • 27 Impulse response of linear systems. Resilience and physical
  • 28. Digital convolution of signals.
  • 29 Linear difference equations with constant coefficients.
  • 30 Z-transform: implementation, properties, application.
  • 32 Typical z-transforms. Z-transform of a digital unit hop.
  • 33 Typical z-transforms. Z-transform of decreasing discrete exponent.
  • 34 Inverse z-transform. Calculation methods.
  • 35 Transfer function of a linear discrete system. Impulse response definition. (See question)
  • 36 Transfer function of a linear discrete system. Definition by difference equation. Zeros and poles.
  • 37 Transfer function of the first order link.
  • 38 Transfer function of the second order link.
  • 39 Frequency response of a linear discrete system.
  • 40 Calculation of frequency response and phase response by transfer function.
  • 41 Calculation of frequency response and phase response of the link of the first order.
  • 42 Calculation of the frequency response and phase response of the second order link.
  • 43. The concept of a digital filter.
  • 44 Stages of digital filter design.
  • 45 Ensuring the linearity of the phase response of the digital filter.
  • 46 Digital filters with infinite impulse response. Bilinear z-transform method for calculating low-frequency bi-filters.
  • 47 Digital filters with infinite impulse response. Bilinear z-transform method for calculating high-frequency bi-filters.
  • 48 Finite impulse response digital filters. Calculation of FIR filters.
  • 49 Data smoothing. Moving average.
  • 50 Data smoothing. Smoothing with parabolas.
  • 51 Data smoothing. Spencer smoothing.
  • 52 Data smoothing. median filtering.
  • 53 Determination of trend parameters by the least squares method.
  • 54 The concept of the wavelet transform, the difference from the Fourier transform.
  • 55 Mathematical description of wavelet functions.
  • 56 Calculation of discrete wavelets.
  • 48 Finite impulse response digital filters. Calculation of FIR filters.

    Finite impulse response filter (Non-recursive filter, FIR filter) or FIR filter (FIR short for finite impulse response - finite impulse response) - one of the types of linear digital filters, a characteristic feature of which is the limited time of its impulse response (from some point in time it becomes exactly equal to zero). Such a filter is also called non-recursive due to the lack of feedback. The denominator of the transfer function of such a filter is a certain constant.

    Difference equation describing the relationship between the input and output signals of the filter: where P- filter order, x(n) - input signal, y(n) is the output signal, and b i- filter coefficients. In other words, the value of any output sample is determined by the sum of the scaled values P previous counts. It can be put differently: the value of the filter output at any time is the value of the response to the instantaneous value of the input and the sum of all gradually decaying responses P previous signal samples that still affect the output (after P-counts, the impulse transition function becomes equal to zero, as already mentioned, so all terms after P th will also become zero). Let's write the previous equation in a more capacious form:

    In order to find the filter kernel we put

    x(n) = δ( n)

    where δ( n) is a delta function. Then the impulse response of the FIR filter can be written as:

    The z-transform of the impulse response gives us the transfer function of the FIR filter:

    ]Properties

    The FIR filter has a number of useful properties that make it sometimes preferable to use over the IIR filter. Here are some of them:

      FIR filters are robust.

      FIR filters do not require feedback when implemented.

      The phase of FIR filters can be made linear

    Direct Form FIR Filter

    FIR filters can be implemented using three elements: a multiplier, an adder, and a delay block. The option shown in the figure is a direct implementation of type 1 FIR filters.

    Implementing a direct form FIR filter

    Program example

    The following is an example FIR filter program written in C:

    /* FIR 128-tap filter */

    float fir_filter(float input)

    static float sample;

    acc = 0.0f; /* Battery */

    /* Multiply with accumulation */

    for (i = 0; i< 128; i++) {

    acc += (h[i] * sample[i]);

    /* Exit */

    /* Offset the delayed signal */

    for (i = 127; i > 0; i--)

    sample[i] = sample;

    49 Data smoothing. Moving average.

    50 Data smoothing. Smoothing with parabolas.

    51 Data smoothing. Spencer smoothing.

    52 Data smoothing. median filtering.

    Moving Average, Parabolic Smoothing, Spencer Smoothing, Median Filtering

    When developing methods for determining the parameters of physical processes that slowly change in time, an important task is to eliminate the influence of noise effects or random interference that are superimposed on the processed signal obtained at the output of the primary converter.

    To eliminate this effect, you can apply data smoothing. One of the simplest ways of such smoothing is arithmetic averaging. When it is applied, each -th value of the discrete function (processed data array) is calculated in accordance with the expression:

    where is the number of points for arithmetic averaging (odd integer);

    The value of the function before processing;

    There are other, quite effective methods of smoothing, for example, by second-degree parabolas in five, seven, nine and eleven points in accordance with the expressions:

    or parabolas of the fourth degree in seven, nine, eleven and thirteen points:

    In practical applications, other effective methods give good results, for example, 15-point Spencer smoothing:

    Substituting into these expressions the complex exponent , where, we can determine the transfer function of the corresponding transformation.

    For arithmetic average

    The expression in brackets is a geometric progression with a denominator, so this expression can be written as:

    .

    This formula is the transfer characteristic of the low-pass filter and it can be seen from it that the more terms involved in the averaging, the greater the suppression of high-frequency noise components in the signal (see Figure 6.1).

    However, the semantic concept of frequency in the processing of temporal trends differs from that in signal processing. This is explained by the fact that when studying time trends, it is not their frequency composition that is of interest, but the type of change (increase, decrease, constancy, cyclicality, etc.).

    The use of so-called heuristic algorithms is also quite effective for data smoothing.

    One of them is median filtering. In the course of its implementation in a sliding time window of dimension , where is an odd integer, the central element is replaced by the middle element of the sequence, which are ordered, in ascending order of values, elements of the data array of the smoothed signal that fell into the time window. The advantage of median filtering is the ability to remove impulse noise, the duration of which does not exceed, with virtually no distortion of smoothly varying signals. This method of noise suppression does not have a rigorous mathematical justification, however, the simplicity of calculations and the efficiency of the results obtained have led to its widespread use.

    Figure 6.1 - Graphs of the transfer characteristic

    arithmetic averaging operations for m=5, 7, 9, 11

    Another interesting smoothing algorithm is median averaging. Its essence is as follows. In a sliding time window, dimension (- odd integer), the elements of the data array are sorted in ascending order, and then the first and last elements are removed from the ordered sequence (<). Центральный элемент временного окна из последовательности сглаживаемых данных заменяется значением, вычисляемым как

    This method allows you to suppress impulse and radio frequency interference, as well as achieve good signal smoothing.

    "

    It all started when a friend of a friend of a friend of mine needed help with these same filters. Through Jedi ways, rumors about this reached me, I unsubscribed in the comments to the post at the link. It seems to have helped. Well, I hope.

    This story stirred up in me memories of the third, or something, course, when I myself passed the DSP, and prompted me to write an article for all those who are interested in how digital filters work, but who are naturally afraid of the catchy formulas and psychedelic drawings in (I already I'm not talking about textbooks.

    In general, in my experience, the situation with textbooks is described by the well-known phrase about the fact that you can’t see the forest behind the trees. And then to say, when they immediately start to scare you with the Z-transform and formulas with the division of polynomials, which are often longer than two boards, interest in the topic dries up extremely quickly. We will start with a simple one, since it is not necessary to write long complex expressions to understand what is happening.

    So, for starters, a few simple basic concepts.

    1. Impulse response.

    Let's say we have a box with four leads. We have no idea what is inside, but we know for sure that the two left conclusions are the entrance, and the two right ones are the exit. Let's try to apply a very short impulse of a very large amplitude to it and see what happens at the output. Well, why, it’s all the same what’s inside this quadripole - it’s unclear, because it’s not clear how to describe it, but we’ll see at least something.

    Here it must be said that a short (generally speaking, infinitely short) pulse of large (generally speaking, infinite) amplitude in theory is called a delta function. By the way, the funny thing is that the integral of this endless function is equal to one. Such is the normalization.

    So, what we saw at the output of the quadripole, having applied the delta function to the input, is called impulse response this quadrupole. So far, however, it is not clear how it will help us, but now let's just remember the result obtained and move on to the next interesting concept.

    2. Convolution.

    In short, convolution is a mathematical operation that boils down to integrating the product of functions:

    Denoted, as you can see, with an asterisk. It can also be seen that during convolution, one function is taken in its “direct” order, and we go through the second one “back to front”. Of course, in the more valuable discrete case for humanity, the convolution, like any integral, goes into summation:

    It would seem that some dull mathematical abstraction. However, in fact, the convolution is perhaps the most magical phenomenon of this world, surprisingly inferior only to the birth of a person, with the only difference being that where children come from, most people will know at the very least by the age of eighteen, while about what a convolution is and why it is useful and amazing, a huge part of the world's population has absolutely no idea all their lives.

    So, the power of this operation lies in the fact that if f is any arbitrary input signal, and g is the impulse response of the quadripole, then the result of the convolution of these two functions will be similar to what we would get by passing the signal f through this quadripole.

    That is, the impulse response is a complete cast of all the properties of the quadripole in relation to the input action, and convolution of the input signal with it allows you to restore the corresponding output signal. As for me, it's just amazing!

    3. Filters.

    You can do a lot of interesting things with impulse response and convolution. For example, if the signal is audio, you can organize reverb, echo, chorus, flanger, and much, much more; you can differentiate and integrate ... In general, create anything. For us now, the most important thing is that, of course, with the help of convolution, filters are also easily obtained.

    The actual digital filter is the convolution of the input signal with an impulse response corresponding to the desired filter.

    But, of course, the impulse response must be obtained somehow. Of course, we have already figured out how to measure it above, but in such a task there is little sense in this - if we have already assembled a filter, why measure something else, you can use it as is. And, besides, the most important value of digital filters is that they can have characteristics that are unattainable (or very difficult to achieve) in reality - for example, a linear phase. So there is no way to measure at all, you just need to count.

    4. Obtaining the impulse response.

    At this point, in most publications on the topic, the authors begin to dump mountains of Z-transformations and fractions from polynomials on the reader, completely confusing him. I won't do it, I'll just briefly explain what all this is for and why in practice it is not very necessary for the progressive public.

    Suppose we have decided what we want from the filter, and made an equation that describes it. Further, to find the impulse response, you can substitute the delta function into the derived equation and get the desired one. The only problem is how to do it, because the delta function in time O th region is set by a cunning system, and in general there are all sorts of infinities. So at this stage, everything turns out to be terribly difficult.

    Here, it happens, and they remember that there is such a thing as the Laplace transform. By itself, it is not a pound of raisins. The only reason why it is tolerated in radio engineering is precisely the fact that in the space of the argument to which this transformation is a transition, some things really become simpler. In particular, the same delta function that gave us so much trouble in the time domain is very easy to express - there it's just one!

    The Z-transform (aka Laurent transform) is a version of the Laplace transform for discrete systems.

    That is, by applying the Laplace transform (or Z-transform, if necessary) to the function describing the desired filter, substituting unity into the resulting one and converting back, we get the impulse response. Sounds easy, anyone can try it. I will not risk it, because, as already mentioned, the Laplace transform is a harsh thing, especially the reverse. Let's leave it as a last resort, and we ourselves will look for some simpler ways to get what we are looking for. There are several of them.

    First, we can recall another amazing fact of nature - the amplitude-frequency and impulse responses are interconnected by a kind and familiar Fourier transform. This means that we can draw any frequency response to our taste, take the inverse Fourier transform from it (either continuous or discrete) and get the impulse response of the system that implements it. It's just amazing!

    Here, however, will not do without problems. First, the impulse response we get is likely to be infinite (I won't go into explanations why; that's how the world works), so we'll have to voluntarily cut it off at some point (by setting it to zero beyond that point). But this will not happen just like that - as a result of this, as expected, there will be distortions in the frequency response of the calculated filter - it will become wavy, and the frequency cut will be blurred.

    In order to minimize these effects, various smoothing window functions are applied to the shortened impulse response. As a result, the frequency response is usually blurred even more, but unpleasant (especially in the passband) oscillations disappear.

    Actually, after such processing, we get a working impulse response and can build a digital filter.

    The second calculation method is even simpler - the impulse responses of the most popular filters have long been expressed in an analytical form for us. It remains only to substitute your values ​​​​and apply the window function to the result to taste. So you can not even count any transformations.

    And, of course, if the goal is to emulate the behavior of a particular circuit, you can get its impulse response in the simulator:

    Here, I applied a 100500 volt (yes, 100.5 kV) 1 µs pulse to the input of the RC circuit and got its impulse response. It is clear that in reality this cannot be done, but in the simulator this method, as you can see, works great.

    5. Notes.

    The foregoing about the shortening of the impulse response referred, of course, to the so-called. filters with a finite impulse response (FIR / FIR filters). They have a bunch of valuable properties, including a linear phase (under certain conditions for building an impulse response), which gives no signal distortion during filtering, as well as absolute stability. There are filters with infinite impulse response (IIR / IIR filters). They are less resource-intensive in terms of calculations, but no longer have the listed advantages.

    In the next article, I hope to analyze a simple example of the practical implementation of a digital filter.



    Loading...
    Top