This example uses ScopeFIR’s Parks-McClellan method for band-pass FIR filter design.
ScopeFIR’s Advanced Filter Specification Editor allows you to enter the desired filter specifications by describing each passband and stopband. Compared to ScopeFIR’s Simple Specification Editor, the Advanced Specification Editor is primarily useful when:
- You need multiple passbands and stopbands.
- You need to design Differentiator or Hilbert responses.
- You need to specify the gain of passbands individually.
- You want to work in linear, rather than dB units.
The Advanced Filter Specification Editor is shown below:
Each band you Add in the “Band Editor” section is either a passband or a stopband, that is, the filter either passes or stops signals within the frequency range. For each band you must specify the following:
- Lower and Upper Frequency. These fields specify the frequency range of the band.
- Desired. Generally, you will set this field to “1” or “0” to specify passband or stopband, while leaving “in dB” unchecked. Alternatively, you can enter “p” and “s”. In advanced applications, this field can be used to individually set the gain of each passband.
- Attn/Ripple. This sets the attenuation of stopbands and the ripple of passbands. Note that ScopeFIR can automatically set the “Desired” field to “1” or “0” based on whether the Attn/Ripple exceeds the “Max Passband dB” threshold value, set using the “View/Preferences” menu. The default threshold value is 10 dB; values less than or equal to to 10 are assumed to be passbands, values greater than 10 are assumed to be stopbands. To use this feature, just tab past the Desired field.
Now that you understand each field, using the Band Editor is straight-forward. Simply fill in the fields for each band and hit the “Add” button. Select bands using the mouse. You can delete a selected band with–you guessed it–the “Delete” button. If you make a mistake, click on the band, correct the error, and hit “Add” again. Note that whenever you enter a band that overlaps an existing band, ScopeFIR replaces the existing band. This can be a little confusing at first, but it makes for a quick and easy way to correct band entries: since a corrected band will generally overlap the incorrect entry, the new version you “Add” will simply replace the old.
We just said that ScopeFIR prevents you from actually entering bands that overlap (which they can’t logically do), and that brings us to the next important point. Likewise, for your own good, ScopeFIR doesn’t allow bands to touch. When you enter bands that touch, ScopeFIR produces an error message and ignores the new band. This behavior can be confusing to new users who think of bands as being “next to each other”. But in fact, bands cannot touch, because there must be a transition band, that is, a frequency gap between any two bands. This follows directly from FIR filter theory: the number of taps required to implement a filter increases as the transition bands narrow (as a fraction of the sampling frequency). So without transition bands, your filter requires an infinite number of taps! (Let’s face it: none of us has the time.) So the moral of the story is: you must provide a transition band, that is, a frequency gap between any two adjacent bands. Sorry, son, it’s not just a good idea, it’s the law.
Designing the Bandpass Filter
Now, back to our mission. We wanted to make a CD player sound like a telephone. We do this by designing a filter with the following bands:
- A stopband from 0 Hz (DC) to 30 Hz with 40 dB minimum attenuation.
- A passband from 300 Hz to 3000 Hz (3 kHz) with 1 dB maximum ripple.
- A stopband from 3300 Hz to 22000 Hz with 40 dB minimum attenuation.
These specifications have been entered at the top. To try this yourself, you can either manually type them in or just open the Project “bandpass.sfa” which is included in the ScopeFIR distribution file. Next, hit the “Design FIR” button. The “Attn/Ripple” column will be filled in. It shows that we have more than the minimum attenuation in both stopbands and less than the maximum ripple in the passband, so our filter design is a success. The Frequency Response of the filter is:
This one requires more taps than the previous low-pass and high-pass combined. That isn’t surprising, for two reasons. First, it is doing the job of both filters. Second, compared to the other two, this one tightens the passband ripple specification from 3 dB to 1 dB.
But why didn’t we just use the Simple Specification Editor to design this one? Well, mostly because you wouldn’t have learned as much. But also, notice that the SSE designs band-pass filters with symmetrical transition bands (the same on both sides) but our transition bands here aren’t symmetrical. On the low side, the transition is from 30 to 300 Hz, so it occurs over 270 Hz. But on the high side, the transition is from 3000 to 3300 Hz, so it occurs over 300 Hz.
Our next example designs a similar band-pass filter using the Windowed Sinc method rather than Parks-McClellan method.