FIR Interpolation - Upsample and filter input signals

Library

Filtering / Multirate Filters

dspmlti4

Description

The FIR Interpolation block resamples the discrete-time input at a rate L times faster than the input sample rate, where the integer L is specified by the Interpolation factor parameter. This process consists of two steps:

The FIR Interpolation block implements the above upsampling and FIR filtering steps together using a polyphase filter structure, which is more efficient than straightforward upsample-then-filter algorithms. See N.J. Fliege, Multirate Digital Signal Processing: Multirate Systems, Filter Banks, Wavelets for more information.

The FIR filter coefficients parameter specifies the numerator coefficients of the FIR filter transfer function H(z).

The coefficient vector, [b(1) b(2) ... b(m)], can be generated by one of the Signal Processing Toolbox filter design functions (such as fir1), and should have a length greater than the interpolation factor (m>L). The filter should be lowpass with normalized cutoff frequency no greater than 1/L. All filter states are internally initialized to zero.

The FIR Interpolation block supports real and complex floating-point and fixed-point inputs except for complex unsigned fixed-point inputs. This block supports triggered subsystems when you select Maintain input frame rate for the Framing parameter.

Sample-Based Operation

An M-by-N sample-based matrix input is treated as M*N independent channels, and the block interpolates each channel over time. The output sample period is L times shorter than the input sample period (Tso = Tsi/L), and the input and output sizes are identical.

Frame-Based Operation

An Mi-by-N frame-based matrix input is treated as N independent channels, and the block interpolates each channel over time. The Framing parameter determines how the block adjusts the rate at the output to accommodate the added samples. There are two available options:

Zero Latency

The FIR Interpolation block has zero-tasking latency for all single-rate operations. The block is single rate for the particular combinations of sampling mode and parameter settings shown in the table below.

Sampling ModeParameter Settings

Sample based

Interpolation factor parameter, L, is 1.

Frame based

Interpolation factor parameter, L, is 1, or

Framing parameter is Maintain input frame rate.

Note that in sample-based mode, single-rate operation occurs only in the trivial case of factor-of-1 interpolation.

The block also has zero latency for sample-based multirate operations in the Simulink single-tasking mode. Zero-tasking latency means that the block propagates the first filtered input (received at t=0) as the first input sample, followed by L-1 interpolated values, the second filtered input sample, and so on.

Nonzero Latency

The FIR Interpolation block is multirate for all settings other than those in the previous table. The amount of latency for multirate operation depends on the Simulink tasking mode and the block's sampling mode, as shown in the following table.

Multirate...Sample-Based LatencyFrame-Based Latency

Single-tasking

None

None

Multitasking

L samples

L frames (Mi samples per frame)

When the block exhibits latency, the default initial condition is zero. Alternatively, you can enter a value in the Output buffer initial conditions text box. This value is divided by the Interpolation factor and output at the output port until the first filtered input sample is available.

In sample-based cases, the scaled initial conditions appear at the start of each channel, followed immediately by the first filtered input sample, L-1 interpolated values, and so on.

In frame-based cases, with the default initial condition, the first MiL output rows contain zeros, where Mi is the input frame size. The first filtered input sample (first filtered row of the input matrix) appears in the output as sample MiL+1, followed by L-1 interpolated values, the second filtered input sample, and so on. See the following example for an illustration of this case.

Fixed-Point Data Types

The following diagram shows the data types used within the FIR Interpolation block for fixed-point signals.

You can set the coefficient, product output, accumulator, and output data types in the block dialog as discussed in Dialog Box. The diagram shows that input data is stored in the input buffer in the same data type and scaling as the input. Filtered data is stored in the output buffer in the output data type and scaling that you set in the block dialog. Any initial conditions are also stored in the output buffer in the output data type and scaling you set in the block dialog.

The output of the multiplier is in the product output data type when at least one of the inputs to the multiplier is real. When both of the inputs to the multiplier are complex, the result of the multiplication is in the accumulator data type. For details on the complex multiplication performed, see Multiplication Data Types.

Examples

Example 1

Construct the frame-based model shown below.

Adjust the block parameters as follows:

This model is multirate because there are at least two distinct sample rates, as shown by the two Probe blocks. To run this model in the Simulink multitasking mode, open the Configuration Parameters dialog box. In the Select pane, click Solver. From the Type list, select Fixed-step, and from the Solver list, select Discrete (no continuous states). From the Tasking mode for periodic sample times list, select MultiTasking. Also set the Stop time to 30.

Run the model and look at the output, yout. The first few samples of each channel are shown below.

dsp_examples_yout =
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
    0.0386   -0.0386
    0.4614   -0.4614
    0.5386   -0.5386
    0.9614   -0.9614
    1.0386   -1.0386

Since we ran this frame-based multirate model in multitasking mode, the first eight (MiL) output rows are zero. The first filtered input matrix row appears in the output as sample 9 (that is, sample MiL+1). Every other row is an interpolated value.

Example 2

The doc_polyphaseinterp model illustrates the underlying polyphase implementations of the FIR Interpolation block. Run the model and view the results on the scope. The output of the FIR Interpolation block is the same as the output of the Polyphase Interpolation Filter block.

Example 3

The doc_mrf_nlp model illustrates the use of the FIR Interpolation block in a number of multistage multirate filters.

Dialog Box

The FIR Interpolation block can operate in two different modes. Select the mode in the Coefficient source group box. If you select

Different items appear on the FIR Interpolation block dialog depending on whether you select Dialog parameters or Multirate filter object (MFILT) in the Coefficient source group box. See the following sections for details:

Specify Filter Characteristics in Dialog

The Main pane of the FIR Interpolation block dialog appears as follows when Dialog parameters is selected in the Coefficient source group box.

FIR filter coefficients

Specify the FIR filter coefficients, in descending powers of z.

Interpolation factor

Specify the integer factor, L, by which to increase the sample rate of the input sequence.

Framing

For frame-based operation, specify the method by which to implement the interpolation: increase the output frame rate, or increase the output frame size. This parameter cannot be set to Maintain input frame rate for sample-based signals.

Output buffer initial conditions

When the block exhibits latency, enter a value in the Output buffer initial conditions text box to specify the value to output at the output port until the first filtered input sample is available. The default initial condition value is 0.

Output buffer initial conditions are stored in the output data type and scaling.

View filter response

This button opens the Filter Visualization Tool (fvtool) from the Signal Processing Toolbox product and displays the filter response of the filter defined in the block. For more information on FVTool, see the Signal Processing Toolbox documentation.

The Fixed point pane of the FIR Interpolation block dialog appears as follows when Dialog parameters is specified in the Coefficient source group box.

Rounding mode

Select the rounding mode for fixed-point operations. The filter coefficients do not obey this parameter; they always round to Nearest.

Overflow mode

Select the overflow mode for fixed-point operations. The filter coefficients do not obey this parameter; they are always saturated.

Coefficients

Choose how you specify the word length and fraction length of the filter coefficients:

The filter coefficients do not obey the Rounding mode and the Overflow mode parameters; they are always saturated and rounded to Nearest.

Product output

Use this parameter to specify how you would like to designate the product output word and fraction lengths. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the product output data type in this block:

Accumulator

As depicted above, inputs to the accumulator are cast to the accumulator data type. The output of the adder remains in the accumulator data type as each element of the input is added to it. Use this parameter to specify how you would like to designate this accumulator word and fraction lengths.

You also use this parameter to specify the accumulator word and fraction lengths resulting from a complex-complex multiplication in the block. See Multiplication Data Types for more information:

Output

Choose how you specify the output word length and fraction length:

Lock scaling against changes by the autoscaling tool

Select this parameter to prevent any fixed-point scaling you specify in this block mask from being overridden by the autoscaling tool in the Fixed-Point Tool.

Specify Multirate Filter Object

The Main pane of the FIR Interpolation block dialog appears as follows when Multirate filter object (MFILT) is specified in the Coefficient source group box.

Multirate filter variable

Specify the multirate filter object (mfilt) that you would like the block to implement. You can do this in one of three ways:

For more information on creating mfilt objects, see the mfilt function reference page in the Filter Design Toolbox documentation.

Framing

For frame-based operation, specify the method by which to implement the interpolation: increase the output frame rate, or increase the output frame size. This parameter cannot be set to Maintain input frame rate for sample-based signals.

View filter response

This button opens the Filter Visualization Tool (fvtool) from the Signal Processing Toolbox product and displays the filter response of the mfilt object specified in the Multirate filter variable parameter. For more information on FVTool, see the Signal Processing Toolbox documentation.

The Fixed-point pane of the FIR Interpolation block dialog appears as follows when Multirate filter object (MFILT) is specified in the Coefficient source group box.

The fixed-point settings of the filter object specified on the Main pane are displayed on the Fixed-point pane. You cannot change these settings directly on the block mask. To change the fixed-point settings you must edit the filter object directly.

For more information on multirate filter objects, see the mfilt function reference page in the Filter Design Toolbox documentation.

References

Fliege, N. J. Multirate Digital Signal Processing: Multirate Systems, Filter Banks, Wavelets. West Sussex, England: John Wiley & Sons, 1994.

Supported Data Types

PortSupported Data Types

Input

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

Output

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

See Also

FIR DecimationSignal Processing Blockset
FIR Rate ConversionSignal Processing Blockset
UpsampleSignal Processing Blockset
fir1Signal Processing Toolbox
fir2Signal Processing Toolbox
firlsSignal Processing Toolbox
interpSignal Processing Toolbox

  


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