Description
The FIR Rate Conversion block resamples the discrete-time input
such that its sample period is K/L times
the input sample period (T_{si}). K is
the integer value you specify for the Decimation factor parameter,
and L is the integer value you specify for the Interpolation
factor parameter.
The block treats each column of the input as a separate channel,
and resamples the data in each channel independently over time. To
do so, the block implements a polyphase filter structure and performs
the following operations:
Upsamples the input to a higher rate
by inserting L-1
zeros between
input samples.
Passes the upsampled data through a
direct-form II transpose FIR filter.
Downsamples the filtered data to a
lower rate by discarding K-1
consecutive
samples following each sample that the block retains.
The polyphase filter implementation is more efficient than a
straightforward upsample-filter-decimate algorithm. See Orfanidis [1] for more information.
Specifying the Resampling Rate
You specify the resampling rate of the FIR Rate Conversion block
using the Decimation factor and Interpolation
factor parameters. For an M_{i}-by-N matrix
input, the Decimation factor, K,
and the Interpolation factor, L,
must satisfy the following requirements:
K and L must
be relatively prime integers; that is, the ratio K/L cannot
be reduced to a ratio of smaller integers.
$$\frac{K}{L}=\frac{{M}_{i}}{{M}_{o}}$$,
where M_{i} and M_{o} are
the integer frame sizes of the input and output, respectively.
You can satisfy the second requirement by setting the Decimation
factor, K, equal to the input frame
size, M_{i}. When you do so,
the output frame size, M_{o},
equals the Interpolation factor, L.
By changing the frame size in this way, the block is able to
hold the frame period constant (T_{fi} = T_{fo})
and achieve the desired conversion of the sample period, such that
$${T}_{so}=\frac{K}{L}\times {T}_{si}$$
where T_{so} is the output
sample period.
Specifying the FIR Filter Coefficients
To specify the filter coefficients, select the mode you want
the FIR Rate Conversion block to operate in. Select the mode in the Coefficient
source group box.
Dialog parameters — Enter
information about the filter, such as coefficients, in the block dialog
box.
Filter object — Specify
the filter using a dsp.FIRRateConverter
System object™.
Auto (default) — Choose
the filter coefficients automatically.
When you select the Dialog parameters option,
you use the FIR filter coefficients parameter
to specify the numerator coefficients of the FIR filter transfer function H(z).
$$H(z)=B(z)={b}_{1}+{b}_{2}{z}^{-1}+\dots +{b}_{m}{z}^{-(m-1)}$$
You can generate the FIR filter coefficient vector, [b(1)
b(2) ... b(m)]
, using one of the DSP System Toolbox™ filter
design functions such as designMultirateFIR
, firnyquist
, firhalfband
, firgr
or firceqrip
.
The coefficient vector you specify must have a length greater
than the interpolation factor (m>L).
The FIR filter must be a lowpass filter with a normalized cutoff frequency,
no greater than min
(1
/L,1/K).
The block internally initializes all filter states to zero.
When you select Auto, the block designs
an FIR multirate filter with the decimation factor specified in Decimation
factor and interpolation factor specified in Interpolation
factor. The designMultirateFIR
function
designs the filter and returns the coefficients used by the block.
For more information on the filter design, see Orfanidis [1].
Fixed-Point Data Types
The following diagram shows the data types used within the FIR
Rate Conversion block for fixed-point signals.
You can set the coefficient, product output, accumulator, and
output data types in the block dialog box 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 resides
in the output buffer in the output data type and scaling that you
set in the block dialog. The block stores any initial conditions in
the output buffer using the output data type and scaling that you
set in the block dialog box.
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.
Note:
When the block input is fixed point, all internal data types
are signed fixed point. |
Dialog Box
Coefficient Source
The FIR Rate Conversion block can operate in three different
modes. Select the mode in the Coefficient source group
box.
Dialog parameters — Enter
information about the filter, such as coefficients, in the block mask.
Filter object — Specify
the filter using a dsp.FIRRateConverter
System object.
Auto (default) — Choose
the filter coefficients automatically.
Different items appear on the FIR Rate Conversion block dialog
box depending on whether you select Dialog parameters, Filter
object, or Auto in the Coefficient
source group box.
Specify Filter Characteristics in Dialog
The Main pane of the FIR Rate Conversion
block dialog appears as follows when Dialog parameters is
selected in the Coefficient source group box.
- Interpolation factor
Specify the integer factor, L, by which to
upsample the signal before filtering. The default is 3
.
- FIR filter coefficients
Specify the FIR filter coefficients in descending powers of z.
By default, designMultirateFIR(3,2)
computes the
filter coefficients.
- Decimation
factor
Specify the integer factor, K, by which to
downsample the signal after filtering. The default is 2
.
- 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 Data Types pane of the FIR Rate
Conversion 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
.
Note:
The Rounding mode and Saturate
on integer overflow settings have no effect on numerical
results when all the following conditions exist: Product output data type is Inherit:
Inherit via internal rule Accumulator data type is Inherit:
Inherit via internal rule Output data type is Inherit:
Same as accumulator
With these data type settings, the block is effectively operating
in full precision mode. |
- Saturate on integer overflow
When you select this check box, the block saturates the result
of its fixed-point operation. When you clear this check box, the block
wraps the result of its fixed-point operation. By default, this check
box is cleared. For details on saturate
and wrap
,
see overflow
mode for fixed-point operations. The filter coefficients do
not obey this parameter; they are always saturated.
- Coefficients
data type
Specify the coefficients data type. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting
the use of the coefficients data type in this block. You can set it
to:
A rule that inherits a data type, for example, Inherit:
Same word length as input
An expression that evaluates to a valid data type,
for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Coefficients
data type parameter.
See Specify Data Types Using Data Type Assistant for more information.
- Coefficients Minimum
Specify the minimum value of the filter coefficients. The default
value is []
(unspecified). Simulink^{®} software
uses this value to perform:
- Coefficients Maximum
Specify the maximum value of the filter coefficients. The default
value is []
(unspecified). Simulink software
uses this value to perform:
- Product
output data type
Specify the product output data type. See Fixed-Point Data Types and Multiplication Data Types for
illustrations depicting the use of the product output data type in
this block. You can set it to:
A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
. For more information on this
rule, see Inherit via Internal Rule.
An expression that evaluates to a valid data type,
for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Product
output data type parameter.
See Specify Data Types Using Data Type Assistant for more information.
- Accumulator
data type
Specify the accumulator data type. See Fixed-Point Data Types for illustrations depicting the use
of the accumulator data type in this block. You can set this parameter
to:
A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
. For more information on this
rule, see Inherit via Internal Rule.
An expression that evaluates to a valid data type,
for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Accumulator
data type parameter.
See Specify Data Types Using Data Type Assistant for more information.
- Output
data type
Specify the output data type. See Fixed-Point Data Types for illustrations depicting the use
of the output data type in this block. You can set it to:
A rule that inherits a data type, for example, Inherit:
Same as accumulator
An expression that evaluates to a valid data type,
for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Output
data type parameter.
See Control Signal Data Types for more information.
- Output Minimum
Specify the minimum value that the block should output. The
default value is []
(unspecified). Simulink software
uses this value to perform:
- Output Maximum
Specify the maximum value that the block should output. The
default value is []
(unspecified). Simulink software
uses this value to perform:
- Lock
data type settings against changes by the fixed-point tools
Select this parameter to prevent the fixed-point tools from
overriding the data types you specify on the block mask.
Specify Multirate Filter Object
The Main pane of the FIR Rate Conversion
block dialog appears as follows when Filter object is
specified in the Coefficient source group box.
- Filter
object
Specify the name of the multirate filter object that you want
the block to implement. You must specify the filter as a dsp.FIRRateConverter
System object.
You can define the System object in the block mask or in
a MATLAB^{®} workspace variable.
For information on creating System objects, see Define Basic System Objects.
- View filter response
This button opens the Filter Visualization Tool (fvtool
) from the Signal Processing Toolbox product
and displays the filter response of the System object specified
in the Filter object parameter. For more information
on FVTool, see the Signal Processing Toolbox documentation.
Note:
If you specify a filter in the Filter object parameter,
you must apply the filter by clicking the Apply button
before using the View filter response button. |
The Data Types pane of the FIR Rate
Conversion block dialog appears as follows when you select Filter
object in the Coefficient source group
box.
The fixed-point settings of the filter object specified on the Main pane
are displayed on the Data Types 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 System objects, see the Define System Objects reference
page.
Choose Filter Coefficients Automatically
When you select Auto in the Coefficient
source group box, the block chooses the filter coefficients
automatically. For more information on the filter design algorithm
the block uses, see Specifying the FIR Filter Coefficients.
The Main pane of the FIR Rate Conversion
block dialog box appears as follows when you select Auto in
the Coefficient source group box.
- Interpolation factor
Specify the integer factor, L, by which to
upsample the signal before filtering. The default is 3
.
- Decimation factor
Specify the integer factor, K, by which to
downsample the signal after filtering. The default is 2
.
- 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 Data Types pane of the FIR Rate
Conversion block dialog box appears as follows when you select Auto 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
.
Note:
The Rounding mode and Saturate
on integer overflow settings have no effect on numerical
results when all the following conditions exist: Product output data type is Inherit:
Inherit via internal rule Accumulator data type is Inherit:
Inherit via internal rule Output data type is Inherit:
Same as accumulator
With these data type settings, the block is effectively operating
in full precision mode. |
- Saturate on integer
overflow
When you select this check box, the block saturates the result
of its fixed-point operation. When you clear this check box, the block
wraps the result of its fixed-point operation. By default, this check
box is cleared. For details on saturate
and wrap
,
see overflow
mode for fixed-point operations. The filter coefficients do
not obey this parameter; they are always saturated.
- Coefficients data
type
Specify the coefficients data type. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting
the use of the coefficients data type in this block. You can set it
to:
A rule that inherits a data type, for example, Inherit:
Same word length as input
An expression that evaluates to a valid data type,
for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Coefficients
data type parameter.
See Specify Data Types Using Data Type Assistant for more information.
- Coefficients Minimum
Specify the minimum value of the filter coefficients. The default
value is []
(unspecified). Simulink software
uses this value to perform:
- Coefficients Maximum
Specify the maximum value of the filter coefficients. The default
value is []
(unspecified). Simulink software
uses this value to perform:
- Product output
data type
Specify the product output data type. See Fixed-Point Data Types and Multiplication Data Types for
illustrations depicting the use of the product output data type in
this block. You can set it to:
A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
. For more information on this
rule, see Inherit via Internal Rule.
An expression that evaluates to a valid data type,
for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Product
output data type parameter.
See Specify Data Types Using Data Type Assistant for more information.
- Accumulator data
type
Specify the accumulator data type. See Fixed-Point Data Types for illustrations depicting the use
of the accumulator data type in this block. You can set this parameter
to:
A rule that inherits a data type, for example, Inherit:
Inherit via internal rule
. For more information on this
rule, see Inherit via Internal Rule.
An expression that evaluates to a valid data type,
for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Accumulator
data type parameter.
See Specify Data Types Using Data Type Assistant for more information.
- Output data type
Specify the output data type. See Fixed-Point Data Types for illustrations depicting the use
of the output data type in this block. You can set it to:
A rule that inherits a data type, for example, Inherit:
Same as accumulator
An expression that evaluates to a valid data type,
for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Output
data type parameter.
See Control Signal Data Types for more information.
- Output Minimum
Specify the minimum value that the block should output. The
default value is []
(unspecified). Simulink software
uses this value to perform:
- Output Maximum
Specify the maximum value that the block should output. The
default value is []
(unspecified). Simulink software
uses this value to perform:
- Lock
data type settings against changes by the fixed-point tools
Select this parameter to prevent the fixed-point tools from
overriding the data types you specify on the block mask.