DSP Algorithms for RF Systems

Trending

Buy the Book!

DSP for Beginners: Simple Explanations for Complex Numbers! The second edition includes a new chapter on complex sinusoids.

Digital Signal Processing through the Lens of the FIR Filter
September 1, 2021

Table of Contents

Introduction

Digital signal processing has two components: signals and filters.

A signal is a time-series which has information (RF vocabulary) and filters are useful in applying a desired affect to a signal. These affects can be:

  • enhancing information elements of a signal,
  • attenuating or minimizing noise,
  • or some other modification.

The following sections will highlight how an FIR filter can be used to minimize noise in a receive signal which enhances the information content. Trade-offs will be discussed between how much noise can be minimized with how much distortion can be applied to the underlying signal.

More posts on FIR filtering:

Time Invariant Filters

The introductory type of filter encountered in the undergraduate education is the time-invariant (TI) filter. A TI filter is one whose impulse-response does not change with time. Applying the filter against the same signal a nanosecond from now or 15 years from now will produce the same response. A signal x[n] is related to the filter output y[n] through discrete-time convolution,

(1)   \begin{equation*}y[n] = x[n] \circledast h[n],\end{equation*}

or equivalently,

(2)   \begin{equation*}y[n] = \sum_{k=-\infty}^{\infty} x[k]h[n-k],\end{equation*}

Delaying a signal x[n] by k samples, x[n-k], and passing it through a time-invariant filter h[n] results in the same delay of the output with no other modifications,

(3)   \begin{equation*}y[n-k] = x[n-k] \circledast h[n].\end{equation*}

Moving Average FIR Filters

There are two types of TI filters; infinite impulse response (IIR) filters which have feedback and finite impulse response (FIR) filters which do not have feedback. A moving average (MA) filter is an example of an FIR filter. Consider a length-3 moving average filter

(4)   \begin{equation*}y[n] = \left(x[n] + x[n-1] + x[n-2])\right /3,\end{equation*}

where x[n] is the input signal and y[n] is the output of the MA filter. Each output is the average of the three last inputs. For example,

(5)   \begin{equation*}y[0] = \left(x[0] + x[-1] + x[-2])\right /3,\end{equation*}

(6)   \begin{equation*}y[1] = \left(x[1] + x[0] + x[-1])\right /3,\end{equation*}

(7)   \begin{equation*}y[2] = \left(x[2] + x[1] + x[0])\right /3.\end{equation*}

Visually the filter can be represented by the blog diagram in Figure 1.

Figure 1: A moving average filter is implemented by delaying the input signal x[n] and then scaling by 1/3 and summing all results.
Figure 1: A moving average filter is implemented by delaying the input signal x[n] and then scaling by 1/3 and summing all results.

Each of the filter weights are 1/3 and the MA filter can be represented by

(8)   \begin{equation*}h[n] = \begin{cases}1, & n = 0, 1, 2 \\0, & \text{otherwise}.\end{cases}\end{equation*}

A moving average filter will reduce noise fluctuations in a receive signal. Figure 2 is an example of a pulse train signal. Noise is added to the pulse train and then the length-3 MA filter is applied to reduce the variations in the signal due to noise.

Figure 2: A pulse train signal without noise.
Figure 2: A pulse train signal without noise.
Figure 3: A pulse train corrupted by noise. A length-3 moving average filter is applied to reduce noise fluctuations.
Figure 3: A pulse train corrupted by noise. A length-3 moving average filter is applied to reduce noise fluctuations.

The impact of the MA filter can be seen in the time domain. How does it work in the frequency domain?

Moving Average Filter in Frequency Domain

The Z-transform Z{} can be used to translate the difference equation h[n] into the frequency domain H(z),

(9)   \begin{equation*}Z\{ y[n] \} = Z\left\{ \left( x[n] + x[n-1] + x[n-2] \right) /3 \},\end{equation*}

(10)   \begin{equation*}Z\{ y[n] \} = Y(z),\end{equation*}

(11)   \begin{equation*}Z\{ x[n-k] \} = X(z) z^{-k}.\end{equation*}

Substituting (10) and (11) into (9),

(12)   \begin{equation*}Y(z) = \frac{1}{3} X(z) + \frac{1}{3} X(z)z^{-1} + \frac{1}{3} X(z)z^{-2}.\end{equation*}

Gathering like terms in X(z)

(13)   \begin{equation*}Y(z) = \frac{1}{3} X(z) \left(1 + z^{-1} + z^{-2}\right)\end{equation*}

allows the transfer function H(z) to be written as

(14)   \begin{equation*}H(z) = \frac{Y(z)}{X(z)} = \frac{1}{3} \left(1 + z^{-1} + z^{-2}\right).\end{equation*}

Substituting

    \[z=e^{j\omega}\]

into (14),

(15)   \begin{equation*}H(e^{j\omega}) = \frac{1}{3} \left(1 + e^{-j\omega} + z^{-2j\omega})\right.\end{equation*}

The magnitude-squared response |H(e^{j\omega})|^2 can by found by

(16)   \begin{equation*}|H(e^{j\omega})|^2 = H(e^{j\omega}) \cdot H(e^{j\omega})^*\end{equation*}

where * is the conjugation operator. Substituting (15) into (16),

(17)   \begin{equation*}\begin{split}|H(e^{j\omega})|^2 & = \left( 1 + e^{-j\omega} + e^{-2j\omega}\right)/3 \cdot \left( 1 + e^{-j\omega} + e^{-2j\omega}\right)^* /3, \\& = \left( 1 + e^{-j\omega} + e^{-2j\omega}\right) \cdot \left( 1 + e^{-j\omega} + e^{-2j\omega}\right)/9, \\& = 1/3 + (2/9)\left(e^{j\omega} + e^{-j\omega}\right) + (1/9)\left(e^{2j\omega} + e^{-2j\omega}\right).\end{split}\end{equation*}

Substituting (reference)

    \[cos(\alpha) = (e^{j\alpha} + e^{-j\alpha})/2\]

into (17),

(18)   \begin{equation*}|H(e^{j\omega})|^2 = 1/3 + (4/9)cos(\omega) + (2/9)cos(2\omega),\end{equation*}

and converting into dB,

(19)   \begin{equation*}10\text{log}_{10}(|H(e^{j\omega})|^2) = 10\text{log}_{10}\left(1/3 + (4/9)cos(\omega) + (2/9)cos(2\omega)\right).\end{equation*}

Figure 4 gives the magnitude-squared response of the filter H(z) in dB

Figure 4: The length-3 moving average filter has a low-pass effect with about 9 dB worth of attenuation at high frequencies.
Figure 4: The length-3 moving average filter has a low-pass effect with about 9 dB worth of attenuation at high frequencies.

The low-pass nature of the MA filter reduces the impact of high frequency noise, which is the affect seen in Figure 3. The following section will analyze how the MA filter effects the signal and noise in the frequency domain.

Analyzing Filter Impact in Frequency Domain

The input signal x[n] contains both signal s[n] and noise w[n],

(20)   \begin{equation*}x[n] = s[n] + w[n].\end{equation*}

The filter h[n] low-pass filters both s[n] and w[n],

(21)   \begin{equation*}\begin{split}y[n] & = (s[n] + w[n]) \circledast h[n] \\& = (s[n] \circledast h[n]) + (w[n] \circledast h[n]),\end{split}\end{equation*}

or equivalently in the frequency domain,

(22)   \begin{equation*}Y(e^{j\omega}) = S(e^{j\omega}) H(e^{j\omega}) + W(e^{j\omega}) H(e^{j\omega}.\end{equation*}

Figure 5 shows how the MA filter reduces the noise at high frequencies in the frequency domain. Similarly Figure 6 shows the frequency response of the pulse train signal is much less effected by the MA filter.

Figure 5: The noise has a large amount of high frequency content and therefore is substantially effected by the MA filter.
Figure 5: The noise has a large amount of high frequency content and therefore is substantially effected by the MA filter.
Figure 6: The energy of the pulse train signal is mostly concentrated at low frequencies and is therefore only marginally effected by the MA filter.
Figure 6: The energy of the pulse train signal is mostly concentrated at low frequencies and is therefore only marginally effected by the MA filter.

Increasing Filter Length

The previous section showed that a length-3 MA filter reduces the impact of noise by filtering out the high frequency content with little impact to the pulse train signal. If 3 filter weights are good, more are better … right? What will happen if we increase to length 63? Will there be any unintended consequences? (Yes.)

Figure 7 gives the output of a length-63 MA filter in the time domain with the same input pulse train signal.

Figure 7: A length length-63 MA filter further reduces the noise fluctuations at the cost of distorting the underlying pulse train signal.
Figure 7: A length length-63 MA filter further reduces the noise fluctuations at the cost of distorting the underlying pulse train signal.

Increasing the filter length from 3 to 63 has created noticeable distortion of the underlying pulse train signal. A period of ramp up and ramp down between pulses can now be seen in the filtered signal as well as a time-shift. Where did this come from? Let’s look to the time domain first.

Analyzing Moving Average in Time Domain

An input signal x[n] is defined to have a single cycle of a pulse,

(23)   \begin{equation*}x[n] =\begin{cases}1 & 1 \le n \le 7 \\0 & \text{otherwise}. \\\end{cases}\end{equation*}

Figure 8 demonstrates the starting values for all elements in the block diagram.

Figure 8: The starting state of the MA filter when x[n] = 0 for n
Figure 8: The starting state of the MA filter when x[n] = 0 for n

The first 1 is passed into the filter for x[1] = 1 and Figure 9 shows the state of the filter. Figures 10 and 11 also show the response for x[2] = 1 and x[3] = 1.

Figure 9: The state of the filter at n=1 when x[1] = 1.
Figure 9: The state of the filter at n=1 when x[1] = 1.
Figure 10: The state of the filter at n=2 when x[2] = 1.
Figure 10: The state of the filter at n=2 when x[2] = 1.
Figure 10: The state of the filter at n=1 when x[1] = 1.
Figure 11: The state of the filter at n=3 when x[3] = 1.

Figure 12 gives the output y[n] for all x[n].

Figure 12: Filtering a pulse with an MA creates transition periods.
Figure 12: Filtering a pulse with an MA creates transition periods.

Correcting for Filter Delay

The input signal x[n] is 6 samples of 1’s. Figure 12 shows y[n] has has 4 samples of 1’s and multiple transition samples. The four 1 values obviously belong to the pulse train, as well as the two adjacent 2/3 samples at n=1 and n=6. The delay due to the filter can be corrected for by removing the first (3-1)/2 = 1 samples from y[n], shown in Figure 13.

Figure 13: The filter output y[n] has been realigned with the input x[n] by removing 1 sample of delay.
Figure 13: The filter output y[n] has been realigned with the input x[n] by removing 1 sample of delay.

Similarly, the delay of the length-63 filter can be corrected by removing the first (63-1)/2 samples from the time-series as shown in Figure 14.

Figure 14: The length-63 MA filter output has been realigned with the pulse train input by removing the filter delay.
Figure 14: The length-63 MA filter output has been realigned with the pulse train input by removing the filter delay.

Frequency Domain Analysis of Longer MA Filter

The distortion of the underlying pulse train is also due to the much narrower bandwidth of the MA filter. Figure 15 shows the length-63 MA filter has a much narrower bandwidth than the length-3 MA which results in more attenuation of the high frequency components of the pulse train signal. The noise at the output of the MA filter is also significantly reduced, shown in Figure 16. Also note the length-63 MA filter applies about 38 dB worth of attenuation at high frequencies as compared to 9 dB for the length-3 filter.

Figure 15: The pulse train is distorted by the MA filter due to the attenuation of high frequency components.
Figure 15: The pulse train is distorted by the MA filter due to the attenuation of high frequency components.
Figure 16: The noise is significantly attenuated due to the MA filter.
Figure 16: The noise is significantly attenuated due to the MA filter.

Conclusion

The analysis of the FIR filter was used to highlight major concepts within DSP:

  • Noise negatively impacts signals.
  • Filtering can be used to minimize noise in a receive signal to enhance the signal.
  • Trade-offs must be made to balance noise minimization and signal distortion when applying a filter.
  • Longer filters provide tend to provide more attenuation than shorter filters.
  • Time domain effects can also be viewed through the frequency domain.

More posts on FIR filtering:

Leave a Reply

For everything there is a season, and a time for every matter under heaven. A time to cast away stones, and a time to gather stones together. A time to embrace, and a time to refrain from embracing. Ecclesiastes 3:1,5
The earth was without form and void, and darkness was over the face of the deep. And the Spirit of God was hovering over the face of the waters. Genesis 1:2
Behold, I am toward God as you are; I too was pinched off from a piece of clay. Job 33:6
Enter His gates with thanksgiving, and His courts with praise! Give thanks to Him; bless His name! Psalm 100:4
Lift up your hands to the holy place and bless the Lord! Psalm 134:2
Blessed is the man who trusts in the Lord, whose trust is the Lord. He is like a tree planted by water, that sends out its roots by the stream, and does not fear when heat comes, for its leaves remain green, and is not anxious in the year of drought, for it does not cease to bear fruit. Jeremiah 17:7-8
He said to him, “You shall love the Lord your God with all your heart and with all your soul and with all your mind. This is the great and first commandment. And a second is like it: You shall love your neighbor as yourself. On these two commandments depend all the Law and the Prophets.” Matthew 22:37-39
Then He said to me, “Prophesy over these bones, and say to them, O dry bones, hear the word of the Lord. Thus says the Lord God to these bones: Behold, I will cause breath to enter you, and you shall live." Ezekiel 37:4-5
Riches do not profit in the day of wrath, but righteousness delivers from death. Proverbs 11:4
The angel of the Lord appeared to him in a flame of fire out of the midst of a bush. He looked, and behold, the bush was burning, yet it was not consumed. And Moses said, “I will turn aside to see this great sight, why the bush is not burned.” When the Lord saw that he turned aside to see, God called to him out of the bush, “Moses, Moses!” And he said, “Here I am.” Exodus 3:2-3
Daniel answered and said: “Blessed be the name of God forever and ever, to whom belong wisdom and might. He changes times and seasons; He removes kings and sets up kings; He gives wisdom to the wise and knowledge to those who have understanding." Daniel 2:20-21
Now the Lord is the Spirit, and where the Spirit of the Lord is, there is freedom. 2 Corinthians 3:17

This website participates in the Amazon Associates program. As an Amazon Associate I earn from qualifying purchases.

© 2021-2025 Wave Walker DSP