Engee documentation

FIR Rate Conversion

Polyphase sampling rate converter based on FIR filter.

fir rate conversion

Description

The block FIR Rate Conversion performs efficient polyphase sampling rate conversion with usage of a rational factor along the first dimension. The block treats each column of the input signal as a separate channel and resamples the data therein independently.

Conceptually, the frequency converter combines a FIR interpolator and a FIR decimator. The circuit shown below contains a boost element that combines a reconstruction and anti-aliasing filter, and a downsampling element.

The frequency converter performs the following actions:

  • Raises the sampling frequency of the input data to a higher frequency by adding zeros between the input samples.

  • Passes the sampled data through the FIR filter.

  • Decreases the sampling rate of the filtered data to a lower sampling rate by discarding consecutive samples following each sample that the block stores.

fir rate conversion 1 en

Note that the actual block algorithm is performed with usage of polyphase decomposition, which is more efficient compared to the concept presented above. More details are given in Sect. Algorithms.

Ports

Input

In - input signal
scalar | vector | matrix

The input signal can be specified as a scalar, vector or matrix of size by . In the latter case, the columns of the input signal represent independent channels.

For details, refer to Frame-based processing.

Data types: Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64

Support for complex numbers: Yes.

Output

Out - converted signal
scalar | vector | matrix

The output data after frequency conversion can be represented as a scalar, vector or matrix.

The block behaviour depends on the value of the Rate options parameters:

  • Enforce single-rate processing - the block keeps the sampling frequency of the input signal, but transforms the dimensionality so that the channel size in the output signal differs by times relative to the input one. The output has an upper bound of size to for an input of size to .

  • Allow multirate processing - The block decimates the signal so that the sample rate of the output signal is times the sample rate of the input signal. The output frame size is the same as the input frame size, but the sampling rate is .

All blocks connected to the output operate at the sampling frequency , and all blocks connected to the input operate at the sampling frequency .

Data types: Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64

Support for complex numbers: Yes.

Parameters

Coefficient source - method of setting filter coefficients
Dialog parameters (by default)

If the parameter has the Dialog parameters value, the filter coefficients are set in the parameters settings window.

Interpolation factor - interpolation factor
3 (By default) | positive scalar

Specify an integer factor . The block increases the sampling rate of the input sequence according to this factor before filtering.

Dependencies

To use this parameter, set the Coefficient source parameter to Dialog parameters.

Data types: Int8, Int16, Int32, Int64

FIR filter coefficients - coefficients of low-pass FIR filter
[0 -0.000129061486199961 -0.000228040316280948 0 0.000554613738572437 0.000802607430267054 0 -0.00152912350278902 -0.00203638780675590 0 0.00342230705979440 0.00433928347039265 0 -0.00673109372352446 -0.00825637814441869 0 0.0121125402586868 0.0145130044012328 0 -0.0204721583515830 -0.0241392529239787 0 0.0332125142618354 0.0388230898504630 0 -0.0529640018790903 -0.0619837024555044 0 0.0860610417481775 0.102712774109103 0 -0.154048515452570 -0.197567026018057 0 0.408837525145054 0.824655115145336 1 0.824655115145336 0.408837525145054 0 -0.197567026018057 -0.154048515452570 0 0.102712774109103 0.0860610417481775 0 -0.0619837024555044 -0.0529640018790903 0 0.0388230898504630 0.0332125142618354 0 -0.0241392529239787 -0.0204721583515830 0 0.0145130044012328 0.0121125402586868 0 -0.00825637814441869 -0.00673109372352446 0 0.00433928347039265 0.00342230705979440 0 -0.00203638780675590 -0.00152912350278902 0 0.000802607430267054 0.000554613738572437 0 -0.000228040316280948 -0.000129061486199961] (By default) | vector

Specify the FIR filter coefficients in descending order from .

Dependencies

To use this parameter, set the Coefficient source parameter to Dialog parameters.

Data types: Int8, Int16, Int32, Int64

Support for complex numbers: Yes.

Decimation factor - decimation factor
2 (By default) | positive scalar

Specify an integer factor . The block reduces the sampling rate of the input sequence according to this factor after filtering.

Dependencies

To use this parameter, set the Coefficient source parameter to Dialog parameters.

Data types: Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64

Rate options - Enforce single-rate processing or allow multirate processing
Enforce single-rate processing (by default) | Allow multirate processing

Specify which processing to use. Options to select:

  • Enforce single-rate processing - the output frame size is equal to the input frame size , multiplied by , where is the interpolation factor and is the decimation factor.

.

Sampling frequency of the output signal is equal to the sampling frequency of the input signal:

.

  • Allow multirate processing - the output frame size is equal to the input frame size:

.

The output sampling rate is equal to the input sampling rate multiplied by :

.

All blocks connected to the output operate at the sampling frequency , and all blocks connected to the input operate at the sampling frequency .

Allow arbitrary frame length for fixed-size input signals - allow arbitrary frame length for fixed-size input signals
off (by default) | on

Specify whether fixed-size input signals (whose size does not change during simulation) can be converted to an arbitrary frame length input signal, in this case the input frame length does not have to be a multiple of the decimation factor.

For input signals of fixed size:

  • Select the Allow arbitrary frame length for fixed-size input signals check box if the input signal frame length does not have to be a multiple of the decimation factor. If the first dimension of the input signal is not a multiple of the decimation factor, the output is usually a variable-sized signal. Therefore, to support arbitrary-size input signals, the block must also support variable-size signal operations, which is achieved by selecting the Allow arbitrary frame length for fixed-size input signals checkbox.

  • Uncheck Allow arbitrary frame length for fixed-size input signals if the input frame length must be a multiple of the decimation factor.

Dependencies

To use this parameter, set the Rate options parameter to Enforce single-rate processing.

Read more

Setting FIR filter coefficients

In the FIR filter coefficients parameters it is necessary to set the FIR filter numerator coefficients as a vector.

The transfer function of the FIR filter is set as:

The coefficient vector must have a length greater than the interpolation factor ( ). The FIR filter must be a low-pass filter with a normalised cut-off frequency not exceeding . The block internally initialises all filter states with zero.

Setting the sampling frequency

This section applies only to single-rate processing mode when the Rate options parameter is set to Enforce single-rate processing.

The sampling rate of the block FIR Rate Conversion is set using the Decimation factor and Interpolation factor parameters. For the input matrix to , the parameters Decimation factor and Interpolation factor must meet the following requirements:

  • and must be mutually prime numbers. That is, the relation cannot be reduced to the relation of smaller integers.

  • , where and are the integer sizes of the input and output frames, respectively. We can satisfy the second requirement by setting the Decimation factor equal to the input frame size . In this case, the output frame size will be equal to Interpolation factor .

By varying the frame size in this way, the block is able to keep the frame period constant ( ) and achieve the desired sampling period conversion, such that

where is the output sampling period.

The figure below shows how the block FIR Rate Conversion converts an input signal of dimension 4 by 1 with sampling period 3/4 into an output signal of dimension 3 by 1 with sampling period 1. The frame period ( ) of 3 is held constant. The parameter values for this example are:

  • Interpolation factor has a value of 3;

  • Decimation factor has a value of 4;

  • Rate options is set to Enforce single-rate processing.

fir rate conversion 2 en

Frame-based processing

Block FIR Rate Conversion performs repeated sampling of each column of the input signal by time. In this mode, the block can perform either single-speed or multi-speed processing. You can use the Rate options parameters to specify how the block will resample the input data:

  • If the Rate options parameters are set to Enforce single-rate processing, the block’s input and output data have the same sampling rate. To resample the output while maintaining the sampling rate of the input, the block transforms the data in each input column so that the output frame length has an upper bound on the size , where is the interpolation factor specified in the Interpolation factor parameter, is the input frame length, and is the decimation factor specified in the Decimation factor parameter.

In this mode, if a fixed-size signal is input (the frame length does not change during simulation) and the Allow arbitrary frame length for fixed-size input signals checkbox is selected, the input frame length can be arbitrary and does not have to be a multiple of the decimation factor. If the Allow arbitrary frame length for fixed-size input signals checkbox is unchecked, the input frame length must be a multiple of the decimation factor.

  • If the Rate options parameters are set to Allow multirate processing, the input and output data have the same size, but the sampling rate of the output signal is times higher than the input signal. In this mode, the block processes the input matrix to as independent channels. The block decimates each column of the input signal in time, keeping the frame size constant and making the period of the output frame ( ) times the period of the input frame ( ).

Algorithms

Frequency conversion with FIR filter can be efficiently performed by relying on polyphase representation.

To get to the polyphase representation, we start by defining the transfer function of the FIR filter, which is a combination of a reconstruction filter and a smoothing filter:

where is the length of the FIR filter.

We can rearrange this equation as follows:

where is the number of polyphase components, this value is equal to the interpolation factor, which is set in the parameters settings window.

We can write this equation in the form:

where , , …​, are the polyphase components of the FIR filter .

Conceptually, a FIR filter frequency converter contains an upsampling element followed by a combined FIR filter , followed by a downsampling element.

fir rate conversion 1 en

Let’s replace with its polyphase representation.

fir rate conversion 3

The identity for multivariate interpolation is presented here.

fir rate conversion 4 en

Applying the identity for interpolation moves the zero samples addition operation (upsampling operation) after the filtering operation. This move allows the signal to be filtered at a slower rate.

fir rate conversion 5

You can replace the upsampling element, delay unit and adder with a switching switch. To accommodate the subsequent downsampling element, the switch is moved in increments of . The switch receives the first sample from branch 0 and moves anti-clockwise, skipping the branch each time.

As an example, consider a rate converter with , set to 5, and , set to 3. The polyphase components are: , , , , and . The switch starts on the first branch 0, skips branches 1 and 2, gets the next sample from branch 3, then skips branches 4 and 0, gets the next sample from branch 2, and so on. The sequence of branches from which the switch gets a data sample is [0, 3, 1, 4, 2, 0, 3, 1, …​.].

Thus, the frequency conversion process first applies an interpolation factor to the input data , and then uses the switch to extract only 1 out of M data samples, which effectively accounts for the decimation factor . The final sampling frequency at the output of the converter is .

fir rate conversion 6 en

References

[1] Orfanidis, Sophocles J. Introduction to Signal Processing. Upper Saddle River, NJ: Prentice-Hall, 1996.

Additional options

C code generation: Yes