MOTDSP566 Blockset |
|
Search Help Desk |
MOTDSP566 FIR Interpolation | Contents See Also |
Purpose
Upsample and filter an input signal.
Library
Motdsp566lib
Description
The MOTDSP566 FIR Interpolation block resamples the input at an integer rate L times faster than the input sample rate, where L is specified by the Interpolation factor parameter. This process consists of two steps:
The MOTDSP566 FIR Interpolation block implements the upsampling and FIR filtering steps together using a polyphase filter structure, which is more efficient than straightforward upsample-then-filter algorithms.
In practice, the filter specified by the FIR filter coefficients vector (in descending powers of z) should be a lowpass FIR with a normalized cutoff frequency no greater than 1/L. The coefficients are scaled by L.
The Frame-based inputs parameter allows you to choose between sample-based and frame-based operation.
Sample-Based Operation
When the check box is not selected (default), the block assumes that the input is a 1-by-N sample vector or M-by-N sample matrix. Each of the N vector elements (or M*N matrix elements) is treated as an independent channel, and the block interpolates each channel over time.
Frame-Based Operation
When the Frame-based inputs check box is selected, the block assumes that the input is an M-by-N frame matrix. Each of the N frames in the matrix contains M sequential time samples from an independent signal. The illustration below shows a 6-by-4 matrix input:
The Number of channels parameter specifies the number of independent channels (columns, N) in the matrix, and the block interpolates each channel independently over time. Frame-based operation provides substantial increases in throughput rates, at the expense of greater model latency.
In frame-based operation, the Framing parameter determines how the block adjusts the rate at the output. There are two available options:
The block generates the output at the faster (interpolated) rate by using a proportionally larger frame size than the input. For interpolation by a factor of L, the output frame size is L times larger than the input frame size, but the input and output frame rates are equal.
The example below shows a single-channel input of frame size 16 being upsampled by a factor of 4 to a frame size of 64. The block's input and output frame rates are identical.
The block generates the output at the faster (interpolated) rate by using a proportionally shorter frame period at the output port than at the input port. For interpolation by a factor of L, the output frame period is L times shorter than the input frame period, but the input and output frame sizes are equal.
The example below shows a single-channel input (frame size = 64) with a frame period of 1 second being upsampled by a factor of 4 to a frame period of 0.25 seconds. The input and output frame sizes are identical.
Latency
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 Mode | Parameter 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 Simulink's 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 above table. The amount of latency for multirate operation depends on Simulink's tasking mode and the block's sampling mode, as shown in the table below.
Multirate... | Sample-Based Latency | Frame-Based Latency |
Single-tasking | None | One frame (Mi samples) |
Multitasking | One sample | One frame (Mi samples) |
In cases of one-sample latency, a zero initial condition appears as the first output sample in each channel, followed immediately by the first filtered input sample, L-1 interpolated values, and so on.
In cases of one-frame latency, the first Mi 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 Mi+1, followed by L-1 interpolated values, the second filtered input sample, and so on. See the example below for an illustration of this case.
See "Excess Algorithmic Delay (Tasking Latency)" in Chapter 2 and "The Simulation Parameters Dialog Box" in Chapter 4 of Using Simulink for more information about block rates and Simulink's tasking modes.
Example
Construct the frame-based model shown below.
Adjust the block parameters as follows.
Configure the Signal From Workspace block to generate a two-channel signal with frame size of 4 and sample period of 0.25. This represents an output frame period of 1 (0.25*4). The first channel should contain the positive ramp signal 1, 2, ..., 100, and the second channel should contain the negative ramp signal -1, -2, ..., -100.
Configure the FIR Interpolation block to interpolate the two-channel input by increasing
the output frame rate by a factor of 2 relative to the input frame rate. Use a
third-order filter (m=3) with normalized cutoff frequency, fn0,
of 0.25. (Note that fn0 and m satisfy fn0
1/L and m>L.)
Configure the Signal To Workspace block for the two-channel input.
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 Simulink's multitasking mode, select Fixed-step
and discrete from the Type controls in the Solver
panel of the Simulation Parameters dialog box, and select MultiTasking
from the Mode parameter. 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.
yout = 0 0 0 0 0 0 0 0 0.00038576126099 -0.00038576126099 0.00461423397064 -0.00461423397064 0.00538575649261 -0.00538575649261 0.00961422920227 -0.00961422920227 0.01038587093353 -0.01038587093353
Since we ran this frame-based multirate model in multitasking mode, the first four (Mi) output rows are zero. The first filtered input matrix row appears in the output as sample 5 (i.e., sample Mi+1). Every second row is an interpolated value.
The filter coefficient vector generated by fir1(3,0.25)
is
[0.0386 0.4614 0.4614 0.0386]
or, equivalently,
Dialog Box
MOTDSP566 FIR Decimation | FIR decimation |