Main Content

IIR Filter

Implement infinite impulse response (IIR) filter

Libraries:
Motor Control Blockset / Signal Management
Motor Control Blockset HDL Support / Signal Management

Description

The IIR Filter block implements a discrete first-order infinite impulse response (IIR) filter on the specified input signal. The block supports fixed-point and floating-point data types. The block is also optimized for code generation when you use it with the model settings and configuration adopted by the examples shipped with Motor Control Blockset™.

It is recommended that you use a fixed-step discrete solver for this block to enable code generation and ensure accurate simulation.

Equations

You can configure the IIR filter by using the filter coefficient (a) block parameter to set the required cutoff frequency (fc) for the filter. Optionally, you can also provide the filter coefficient value through an input port.

If you know the cutoff frequency of the filter, you can compute the required filter coefficient using this equation:

a= ( 2πTsfc2πTsfc+1 )

The block also includes the option of displaying the cutoff frequency for a given filter coefficient and sample time on the block mask.

Use the Filter type parameter to configure the block either as a lowpass or highpass filter.

The following two equations describe how the block computes its output.

Lowpass Filter:

y(k)=au(k)+(1a)y(k1)

Highpass Filter:

y(k)=(1a)[u(k)u(k1)+y(k1)]

where:

  • fc is the cutoff frequency of the IIR filter.

  • a is the filter coefficient (0 < a ≤ 1).

  • y(k) is the output value at time k.

  • y(k1) is the output value at time k1.

  • x(k) is the input value at time k.

  • x(k1) is the input value at time k1.

  • Ts is the sample time of the IIR Filter block.

Both lowpass and highpass IIR filters can be modeled as RC filters, where the state value corresponds to the voltage drop across the capacitor.

The following equations describe how the block computes the initial output y0 from the initial input u0 and initial state x0.

Lowpass Filter:

y0=x0

Highpass Filter:

y0=u0x0

Ports

Input

expand all

Sampled values of the raw input signal in the time domain.

Data Types: single | double | fixed point

Filter coefficient of the IIR filter. The data type of this signal must be same as that of the input signal x. This may restrict the signal precision when used with fixed point data type.

Dependencies

To enable this port, set the Filter coefficient parameter to Input port.

Data Types: single | double | fixed point

Initial value of the IIR filter state signal.

Dependencies

To enable this parameter, set the Initial state parameter to Input port.

Data Types: single | double | fixed point

External signal that resets the block to deliver the Initial state when in an active-high state.

Dependencies

To enable this parameter, set the External reset parameter to active high resets to initial condition.

Data Types: single | double | fixed point

Output

expand all

Filtered output signal returned by the IIR Filter block in the time domain.

Data Types: single | double | fixed point

Parameters

expand all

Type of IIR filter.

Select one of these methods to specify the filter coefficient:

  • Specify via dialog — Select this option if you want to specify the filter coefficient value using the block parameters dialog box.

  • Input port — Select this option if you want to specify the filter coefficient value using an input port.

Filter coefficient of the IIR filter. The data type of this signal must be same as that of the input signal x. This may restrict the signal precision when used with fixed point data type.

Dependencies

To enable this parameter, set the Filter coefficient parameter to Specify via dialog.

Specify whether to provide the initial state value as a block parameter or as an input port.

Set this parameter to one of these options:

  • Specify via dialog — Select this option if you want to specify the initial state value using the block parameters dialog box.

  • Input port — Select this option if you want to specify the initial state value using an input port.

Initial value of the IIR filter state.

Dependencies

To enable this parameter, set the Initial state parameter to Specify via dialog.

Specify whether to provide an external reset signal as an input port.

Set this parameter to one of these options:

  • none — Select this option if you do not want to provide an external reset signal.

  • active high resets to initial condition — Select this option if you want to provide an external reset signal using an input port.

Select this parameter for the block to display the Theoretical cutoff frequency (Hz) parameter.

Dependencies

To enable this parameter, set the Filter coefficient parameter to Specify via dialog.

The fixed time interval (in seconds) between every two consecutive instances of block execution.

Note

The block uses this value to compute and display the Theoretical cutoff frequency (Hz) in the block dialog box. This parameter does not set the sample time of the block. The block inherits the sample time from the model.

Dependencies

To display this parameter:

  • Set the Filter coefficient parameter to Specify via dialog.

  • Select the Display cutoff frequency parameter.

Computed theoretical cutoff frequency (in Hertz) of the IIR filter. This parameter is not configurable.

Dependencies

To display this parameter:

  • Set the Filter coefficient parameter to Specify via dialog.

  • Select the Display cutoff frequency parameter.

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced in R2020a

expand all