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.

Designing an FIR Band Pass Filter with Remez
September 24, 2021

Table of Contents

Introduction

A band pass filter is characterized by having attenuation at both high frequency and low frequency with a pass-band in between. Band-pass filters can designed to have real coefficients which have an even-symmetric response or they can be upconverted to complex band-pass to have non-symmetric response which is useful in channelization or in applying a Hilbert transform.

Additional examples for BPF Remez filter design can be found in the SciPy documentation.

More blog posts on filter design:

Design a Real Band Pass Filter with Remez

An example pass-band filter can be designed with remez() by

import scipy.signal
fCenter = 0.25
passbandWidth = 0.25
transBandBPF = 0.2
fPassLeft = fCenter - (passbandWidth/2)
fPassRight = fCenter + (passbandWidth/2)
fStopLeft = fPassLeft - (transBandBPF/2)
fStopRight = fPassRight + (transBandBPF/2)
fVec = [0, fStopLeft, fPassLeft, fPassRight, fStopRight, 0.5]
aVec = [0, 1, 0]
BPFRemez = scipy.signal.remez(filterLength,fVec,aVec)

Figure 1 displays the design parameters of the BPF and the desired shape of the magnitude of the frequency response, Figure 2 gives the actual frequency response in linear units. A BPF has two transition bands (Figure 1 and Figure 2), one to the left and one to the right of the passband. Therefore the transition bandwidth of 0.2 is divided to both, 0.1 to the left and 0.1 to the right.

Figure 3 gives the magnitude of the frequency response for the BPF in dB and Figure 4 displays the double sided spectrum from -f_s/2 to f_s/2, or -\pi to \pi in radians.

Figure 1: The parameters of the BPF for remez(), defining locations in frequency along with their associated magnitudes.
Figure 1: The parameters of the BPF for remez(), defining locations in frequency along with their associated magnitudes.
Figure 2: The linear magnitude of the frequency response of the Remez-designed BPF filter.
Figure 2: The linear magnitude of the frequency response of the Remez-designed BPF filter.
Figure 3: The magnitude (in dB) of the frequency response of the Remez-designed BPF filter.
Figure 3: The magnitude (in dB) of the frequency response of the Remez-designed BPF filter.
Figure 4: The double-sided spectrum from Figure 3.
Figure 4: The double-sided spectrum from Figure 3.

Figure 5 gives the impulse response for the Remez-designed LPF and BPF filters.

Figure 5: The impulse response of the BPF appears to have a periodic element applied where the LPF does not.
Figure 5: The impulse response of the BPF appears to have a periodic element applied where the LPF does not.

Problems with Upconverting a Low Pass Filter to a Real Band Pass Filter

Similar to the process from the high-pass filter design blog an LPF is designed and then upconverted to band-pass. The LPF is designed with

import scipy.signal
filterLength = 21
cutoffLPF = 0.125
transBand = 0.1 
fPassLPF = cutoffLPF - (transBand/2)
fStopLPF = cutoffLPF + (transBand/2)
fVec = [0, fPassLPF, fStopLPF, 0.5]
aVec = [1, 0]
LPFRemez = scipy.signal.remez(filterLength,fVec,aVec)

The filter weights are then upconverted to f_s/4 or \pi/2 in radians,

(1)   \begin{equation*}h_{BPF}[n] = h_{LPF}[n] \cdot cos(\pi n/2).\end{equation*}

Figure 6 gives the frequency responses for the BPF designed with Remez as well as the LPF upconverted to band-pass.

Figure 6: The frequency responses for the Remez-designed BPF as well as the LPF upconverted to BPF.
Figure 6: The frequency responses for the Remez-designed BPF as well as the LPF upconverted to BPF.

The first thing to note from Figure 6 is that the magnitude is 6 dB lower than the Remez version. Why?

Taking another look at the math, cosine can be expressed as the summation of two complex exponentials,

(2)   \begin{equation*}cos(\theta n) = \frac{1}{2} \left( e^{j\theta n} + e^{-j\theta n} \right).\end{equation*}

Substituting (2) into (1),

(3)   \begin{equation*}\begin{split}h_{BPF}[n] & = h_{LPF}[n] \cdot \frac{1}{2} \left( e^{j\pi n/2} + e^{-j \pi n/2} \right) \\& = \left( \frac{1}{2} h_{LPF}[n] \cdot e^{j\pi n/2} \right ) + \left( \frac{1}{2} h_{LPF}[n] \cdot e^{-j\pi n/2} \right ).\end{split}\end{equation*}

The LPF is turned into two copies at different frequencies whose magnitude is divided by 1/2. Scaling the upconverted BPF by 2 accounts for the relative loss compared to the Remez design,

(4)   \begin{equation*}h_{BPF}[n] = 2 \cdot h_{LPF}[n] \cdot cos(\pi n/2).\end{equation*}

Figure 7 gives the frequency response for (4).

Figure 7: The upconverted BPF is scaled by 2 to match the pass-band magnitude of the Remez-designed BPF.
Figure 7: The upconverted BPF is scaled by 2 to match the pass-band magnitude of the Remez-designed BPF.

The scaling by 2 has matched the magnitude levels of the two filters in Figure 7 however the sidelobes now show a difference. The sidelobes are higher at f/f_s = 0, -0.5, +0.5. Why?

The problem is h_{LPF}[n] \cdot e^{j\pi n/2} and h_{LPF}[n] \cdot e^{-j\pi n/2} interfere with one another in the frequency domain when they are summed. Figure 8 shows the two frequency responses of the complex upconversion to positive and negative frequencies of the BPF.

Figure 8: The upconverted BPF is the summation of two complex-upconverted LPFs which interfere with one another when summed. The BPF upconversion in Figure 8 is the result of the summation of these two responses.
Figure 8: The upconverted BPF is the summation of two complex-upconverted LPFs which interfere with one another when summed. The BPF upconversion in Figure 8 is the result of the summation of these two responses.

Due to the interference between the two copies of the filter it is better to design a BPF using Remez rather than attempt to build an LPF and upconvert it.

Upconvert Low-Pass to Complex Band-Pass

Real signals have an evenly symmetric magnitude [oppenheim1999, p.56], that is

(5)   \begin{equation*}|X\left( e^{j\omega} \right)| = |X \left( e^{-j\omega} \right) |.\end{equation*}

Equation (5) is the reason why h_{LPF}[n] \cdot cos(\pi n/2) has a passband in both the positive frequencies and negative frequencies. Such an even-symmetric respond may be acceptable when processing real signals but much of DSP is done at complex baseband and non-symmetric band-pass filters may be required in the case of channelizers, for selecting specific signals from a broad spectrum or applying a Hilbert transform [carrick2011].

Where h_{BPF}[n] in (4) uses real upconversion complex upconversion can be used to translate a LPF into complex band-pass. Rather than use a cosine to perform the upconversion, a complex-exponential will allow the selection of one of the two BPF responses as in Figure 8.

The positive and negative frequency complex upconverted band-pass filter is given by

(6)   \begin{equation*}h_{+BPF}[n] = h_{LPF}[n] \cdot e^{j \phi n}\end{equation*}

(7)   \begin{equation*}h_{-BPF}[n] = h_{LPF}[n] \cdot e^{-j \phi n}\end{equation*}

where \phi and \(-\phi)\ is the center frequency of the band-pass filter. The filters can be upconverted using the following code:

import numpy as np
n = np.arange(-(filterLength-1)/2,(filterLength-1)/2+1)
BPFPosUpconvert = LPFRemez*np.exp(1j*2*np.pi*n*(1/4))
BPFNegUpconvert = LPFRemez*np.exp(-1j*2*np.pi*n*(1/4))

The downside of the complex upconversion is that the filter weights are transformed from real to complex and therefore the filter now requires complex multiplication to implement it which requires more operations.

Figure 9 is the impulse response of the LPF being upconverted to complex pass-band at positive frequencies from (6) and Figure 10 is after being upconverted to negative frequencies from (7). Note that the imaginary portion of the impulse response is delayed with respect to the real for the positive frequency BPF in Figure 9. The real portion of the impulse response is delayed with respect to the imaginary in Figure 10 which is characteristic of a negative frequency sinusoid.

Figure 9: The impulse response of an LPF upconverted to complex band-pass with a positive center frequency.
Figure 9: The impulse response of an LPF upconverted to complex band-pass with a positive center frequency.
Figure 10: The impulse response of an LPF upconverted to complex band-pass with a negative center frequency.
Figure 10: The impulse response of an LPF upconverted to complex band-pass with a negative center frequency.

Conclusion

Real BPF filters are better designed with Remez rather than designing an LPF and upconverting it to pass-band due to the degradation in frequency response. However, designing a LPF and then performing a complex upconversion to complex pass-band creates the ability to have a non-symmetric frequency response which is useful in channelization and applying a Hilbert transform.

Don’t forget to check out these posts on filter design:

More blog posts on filter design:

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
Previous slide
Next slide

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

© 2021-2024 Wave Walker DSP