Products & Services Solutions Academia Support User Community Company

Learn more about Filter Design Toolbox   

Designing Multirate Filters in FDATool

Introduction

Not only can you design multirate filters from the MATLAB command prompt, FDATool provides the same design capability in a graphical user interface tool. By starting FDATool and switching to the multirate filter design mode you have access to all of the multirate design capabilities in the toolbox — decimators, interpolators, and fractional rate changing filters, among others.

Switching FDATool to Multirate Filter Design Mode

The multirate filter design mode in FDATool lets you specify and design a wide range of multirate filters, including decimators and interpolators.

With FDATool open, click Create a Multirate Filter, , on the side bar. You see FDATool switch to the design mode showing the multirate filter design options. Shown in the following figure is the default multirate design configuration that designs an interpolating filter with an interpolation factor of 2. The design uses the current FIR filter in FDATool.

When the current filter in FDATool is not an FIR filter, the multirate filter design panel removes the Use current FIR filter option and selects the Use default Nyquist FIR filter option instead as the default setting.

Controls on the Multirate Design Panel

You see the options that allow you to design a variety of multirate filters. The Type option is your starting point. From this list you select the multirate filter to design. Based on your selection, other options change to provide the controls you need to specify your filter.

Notice the separate sections of the design panel. On the left is the filter type area where you choose the type of multirate filter to design and set the filter performance specifications.

In the center section FDATool provides choices that let you pick the filter design method to use.

The rightmost section offers options that control filter configuration when you select Cascaded-Integrator Comb (CIC) as the design method in the center section. Both the Decimator type and Interpolator type filters let you use the Cascaded-Integrator Comb (CIC) option to design multirate filters.

Here are all the options available when you switch to multirate filter design mode. Each option listed includes a brief description of what the option does when you use it.

Selecting and Configuring Your Filter

Option

Description

Type

Specifies the type of multirate filter to design. Choose from Decimator, Interpolator, or Fractional-rate convertor.

  • When you choose Decimator, set Decimation Factor to specify the decimation to apply.

  • When you choose Interpolator, set Interpolation Factor to specify the interpolation amount applied.

  • When you choose Fractional-rate convertor, set both Interpolation Factor and Decimation Factor. FDATool uses both to determine the fractional rate change by dividing Interpolation Factor by Decimation Factor to determine the fractional rate change in the signal. You should select values for interpolation and decimation that are relatively prime. When your interpolation factor and decimation factor are not relatively prime, FDATool reduces the interpolation/decimation fractional rate to the lowest common denominator and issues a message in the status bar in FDATool. For example, if the interpolation factor is 6 and the decimation factor is 3, FDATool reduces 6/3 to 2/1 when you design the rate changer. But if the interpolation factor is 8 and the decimation factor is 3, FDATool designs the filter without change.

Interpolation Factor

Use the up-down control arrows to specify the amount of interpolation to apply to the signal. Factors range upwards from 2.

Decimation Factor

Use the up-down control arrows to specify the amount of decimation to apply to the signal. Factors range upwards from 2.

Sampling Frequency

No settings here. Just Units and Fs below.

Units

Specify whether Fs is specified in Hz, kHz, MHz, GHz, or Normalized (0 to 1) units.

Fs

Set the full scale sampling frequency in the frequency units you specified in Units. When you select Normalized for Units, you do not enter a value for Fs.

Designing Your Filter

Option

Description

Use current FIR filter

Directs FDATool to use the current FIR filter to design the multirate filter. If the current filter is an IIR form, you cannot select this option. You cannot design multirate filters with IIR structures.

Use a default Nyquist Filter

Tells FDATool to use the default Nyquist design method when the current filter in FDATool is not an FIR filter.

Cascaded Integrator-Comb (CIC)

Design CIC filters using the options provided in the right-hand area of the multirate design panel.

Hold Interpolator (Zero-order)

When you design an interpolator, you can specify how the filter sets interpolated values between signal values. When you select this option, the interpolator applies the most recent signal value for each interpolated value until it processes the next signal value. This is similar to sample-and-hold techniques. Compare to the Linear Interpolator option.

Linear Interpolator (First-order)

When you design an interpolator, you can specify how the filter sets interpolated values between signal values. When you select this option, the interpolator applies linear interpolation between signal value to set the interpolated value until it processes the next signal value. Compare to the Linear Interpolator option.

To see the difference between hold interpolation and linear interpolation, the following figure presents a sine wave signal s1 in three forms:

You see in the bottom figure the sample and hold nature of hold interpolation, and the first-order linear interpolation applied by the linear interpolator.

We used FDATool to create interpolators similar to the following code for the figure:

Options for Designing CIC Filters

Description

Differential Delay

Sets the differential delay for the CIC filter. Usually a value of one or two is appropriate.

Number of Sections

Specifies the number of sections in a CIC decimator. The default number of sections is 2 and the range is any positive integer.

Example — Design a Fractional Rate Convertor

To introduce the process you use to design a multirate filter in FDATool, this example uses the options to design a fractional rate convertor which uses 7/3 as the fractional rate. Begin the design by creating a default lowpass FIR filter in FDATool. You do not have to begin with this FIR filter, but the default filter works fine.

  1. Launch FDATool.

  2. Select the settings for a minimum-order lowpass FIR filter, using the Equiripple design method.

  3. When FDATool displays the magnitude response for the filter, click in the side bar. FDATool switches to multirate filter design mode, showing the multirate design panel, shown in the following figure.

  4. To design a fractional rate filter, select Fractional-rate convertor from the Type list. The Interpolation Factor and Decimation Factor options become available.

  5. In Interpolation Factor, use the up arrow to set the interpolation factor to 7.

  6. Using the up arrow in Decimation Factor, set 3 as the decimation factor.

  7. Select Use a default Nyquist FIR filter. You could design the rate convertor with the current FIR filter as well.

  8. Enter 24000 to set Fs.

  9. Click Create Multirate Filter.

    After designing the filter, FDATool returns with the specifications for your new filter displayed in Current Filter Information, and shows the magnitude response of the filter.

You can test the filter by exporting it to your workspace and using it to filter a signal. For information about exporting filters, refer to Importing and Exporting Quantized Filters.

Example — Design a CIC Decimator for 8 Bit Input/Output Data

Another kind of filter you can design in FDATool is Cascaded-Integrator Comb (CIC) filters. FDATool provides the options needed to configure your CIC to meet your needs.

  1. Launch FDATool and design the default FIR lowpass filter. Designing a filter at this time is an optional step.

  2. Switch FDATool to multirate design mode by clicking on the side bar.

  3. For Type, select Decimator, and set Decimation Factor to 3.

  4. To design the decimator using a CIC implementation, select Cascaded-Integrator Comb (CIC). This enables the CIC-related options on the right of the panel.

  5. Set Differential Delay to 2. Generally, 1 or 2 are good values to use.

  6. Enter 2 for the Number of Sections. Settings in the multirate design panel should look like this.

  7. Click Create Multirate Filter.

    FDATool designs the filter, shows the magnitude response in the analysis area, and updates the current filter information to show that you designed a tenth-order cascaded-integrator comb decimator with two sections. Notice the source is Multirate Design, indicating you used the multirate design mode in FDATool to make the filter. FDATool should look like this now.

Designing other multirate filters follows the same pattern.

To design other multirate filters, do one of the following depending on the filter to design:

Quantizing Multirate Filters

After you design a multirate filter in FDATool, the quantization features enable you to convert your floating-point multirate filter to fixed-point arithmetic.

With your multirate filter as the current filter in FDATool, you can quantize your filter and use the quantization options to specify the fixed-point arithmetic the filter uses.

To Quantize and Configure Multirate Filters

Follow these steps to convert your multirate filter to fixed-point arithmetic and set the fixed-point options.

  1. Design or import your multirate filter and make sure it is the current filter in FDATool.

  2. Click the Set Quantization Parameters button on the side bar.

  3. From the Filter Arithmetic list on the Filter Arithmetic pane, select Fixed-point. If your filter is a CIC filter, the Fixed-point option is enabled by default and you do not set this option.

  4. In the quantization panes, set the options for your filter. Set options for Coefficients, Input/Output, and Filter Internals.

  5. Click Apply.

When you current filter is a CIC filter, the options on the Input/Output and Filter Internals panes change to provide specific features for CIC filters.

Input/Output

The options that specify how your CIC filter uses input and output values are listed in the table below.

Option Name

Description

Input Word Length

Sets the word length used to represent the input to a filter.

Input fraction length

Sets the fraction length used to interpret input values to filter.

Input range (+/-)

Lets you set the range the inputs represent. You use this instead of the Input fraction length option to set the precision. When you enter a value x, the resulting range is -x to x. Range must be a positive integer.

Output word length

Sets the word length used to represent the output from a filter.

Avoid overflow

Directs the filter to set the fraction length for the input to prevent the output values from exceeding the available range as defined by the word length. Clearing this option lets you set Output fraction length.

Output fraction length

Sets the fraction length used to represent output values from a filter.

Output range (+/-)

Lets you set the range the outputs represent. You use this instead of the Output fraction length option to set the precision. When you enter a value x, the resulting range is -x to x. Range must be a positive integer.

The available options change when you change the Filter precision setting. Moving from Full to Specify all adds increasing control by enabling more input and output word options.

Filter Internals

With a CIC filter as your current filter, the Filter precision option on the Filter Internals pane includes modes for controlling the filter word and fraction lengths.

There are four usage modes for this (the same mode you select for the FilterInternals property in CIC filters at the MATLAB prompt).

Exporting the Individual Phase Coefficients of a Polyphase Filter to the Workspace

After designing a polyphase filter in Filter Design Analysis Tool (FDATool), you can obtain the individual phase coefficients of the filter by:

  1. Exporting the filter to an object in the MATLAB workspace.

  2. Using the polyphase method to create a matrix of the filter's coefficients.

Exporting the Polyphase Filter to an Object

To export a polyphase filter to an object in the MATLAB workspace, complete the following steps.

  1. In FDATool, open the File menu and select Export.... This opens the dialog box for exporting the filter coefficients.

  2. In the Export dialog box, for Export To, select Workspace.

  3. For Export As, select Object.

  4. (Optional) For Variable Names, enter the name of the Multirate Filter object that will be created in the MATLAB workspace.

  5. Click the Export button. The multirate filter object, Hm in this example, appears in the MATLAB workspace.

Using polyphase() to Create a Matrix of Coefficients

To create a matrix of the filter's coefficients, enter p=polyphase(Hm) at the command line. The polyphase method creates a matrix, p, of filter coefficients from the filter object, Hm. Each row of p consists of the coefficients of an individual phase subfilter. The first row contains to the coefficients of the first phase subfilter, the second row contains those of the second phase subfilter, and so on.

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS