Products & Services Solutions Academia Support User Community Company

Learn more about Signal Processing Blockset   

Biquad Filter - Model biquadratic IIR (SOS) filters

Library

Filtering / Filter Designs

dsparch4

Description

The Biquad Filter block independently filters each channel of the input signal with the specified biquadratic IIR filter. The block implements static filters with fixed coefficients that you can tune during simulation.

This block filters each channel of the input signal independently over time, treating each element of the input as an individual channel. The output dimensions always equal those of the input signal. The outputs of this block numerically match the outputs of the Signal Processing Toolbox dfilt function.

The Biquad Filter block supports the Simulink state logging feature. See States in the Simulink User's Guide for more information. The Digital Filter block also has direct feedthrough. Therefore, if you connect the output of this block back to its input, you get an algebraic loop. For more information on direct feedthrough and algebraic loops, see Algebraic Loops in the Simulink documentation.

Coefficient Source and Filter Structures

The Biquad Filter block can operate in three different modes. Select the mode in the Coefficient source group box.

Specifying the SOS Matrix and Scale Values

The SOS matrix (Mx6) is an M-by-6 matrix, where M is the number of sections in the second-order section filter. Each row of the SOS matrix contains the numerator and denominator coefficients (bik and aik) of the corresponding section in the filter.

You can use the ss2sos and tf2sos functions from Signal Processing Toolbox software to convert a state-space or transfer function description of your filter into the second-order section description used by this block.

The Scale values parameter specifies the scalar or vector of M+1 scale values to be used between SOS sections.

Select the Optimize unity scale values check box to optimize your simulation when one or more scale values equal 1. Selecting this option removes the unity gains so that the values are treated like Simulink lines or wires. In some fixed-point cases when there are unity scale values, selecting this parameter also omits certain casts. Refer to Filter Structure Diagrams for more information.

Specifying Initial Conditions

The Biquad Filter block initializes the internal filter states to zero by default. You can optionally use the Initial conditions or Initial conditions on zeros side and Initial conditions on poles side parameters to specify nonzero initial states for the filter delays.

To determine the number of initial conditions you must specify and how to specify them, see the following table on valid initial conditions.

Valid Initial Conditions

Initial ConditionDescription

Scalar

The block initializes all delay elements in the filter to the scalar value.

Vector or matrix
(for applying different delay elements to each channel)

Each vector or matrix element specifies a unique initial condition for a corresponding delay element in a corresponding channel. Where M is the number of sections and N is the number of input channels:

  • The vector length must equal the number of delay elements in the filter, max(#_of_zeros, #_of_poles)-1, or M*2.

  • The matrix must have the same number of rows as the number of delay elements in the filter, max(#_of_zeros, #_of_poles)-1, or (M*2)*N. The matrix must also have one column for each channel of the input signal.

Fixed-Point Data Types

See Filter Structure Diagrams. The following constraints apply when you process a fixed-point signal with any of the filter structures supported by this block:

Examples

Open an example model by typing doc_biquad_filter_ref at the MATLAB® command line.

Dialog Box

Coefficient Source

The Biquad Filter block can operate in three different modes. Select the mode in the Coefficient source group box.

Specify Filter Characteristics in Dialog

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

Filter structure

Select the filter structure.

This parameter is only visible when Dialog parameters or Input port(s) is selected.

SOS Matrix

Specify an M-by-6 matrix, where M is the number of sections in the second-order section filter. Each row of the SOS matrix contains the numerator and denominator coefficients (bik and aik) of the corresponding section in the filter.

You can use the ss2sos and tf2sos functions from Signal Processing Toolbox software to check whether your SOS matrix is valid.

This parameter is only visible when Dialog parameters is selected.

Scale values

The Scale values parameter specifies the scalar or vector of M+1 scale values to be used between SOS sections.

  • When you enter a scalar, the value specifies the gain value before the first section of the second-order filter. The rest of the gain values default to 1.

  • When you enter a vector of M+1 values, each value specifies a separate section of the filter. For example, the first element is the first gain value, the second element is the second gain value, and so on.

    This parameter is only visible when Dialog parameters is selected.

Initial conditions

Specify the initial conditions of the filter states. To learn how to specify initial conditions, see Specifying Initial Conditions.

This parameter is only visible when Dialog parameters or Input port(s) is selected and the filter structure is Direct form II or Direct form II transposed.

Initial conditions on zeros side

Specify the initial conditions for the filter states on the side of the filter structure with the zeros (b0, b1,b2, ...); see the next diagram.

This parameter is only visible when Dialog parameters or Input port(s) is selected and the filter structure is Direct form I or Direct form I transposed. To learn how to specify initial conditions, seeSpecifying Initial Conditions.

Initial conditions on poles side

Specify the initial conditions for the filter states on the side of the filter structure with the poles (a0, a1,a2, ...); see the next diagram.

This parameter is only visible when Dialog parameters or Input port(s) is selected and the filter structure is Direct form I or Direct form I transposed. To learn how to specify initial conditions, see Specifying Initial Conditions.

Action when the a0 values of the SOS matrix are not one

Specify the action the block should perform when the SOS matrix a0j values do not equal one; None, Error, or Warn.

This parameter is only visible when Dialog parameters is selected.

Optimize unity scale values

Select this check box to optimize your simulation when one or more scale values equal 1. Selecting this option removes the unity gains so that the values are treated like Simulink lines or wires. In some fixed-point cases when there are unity scale values, selecting this parameter also omits certain casts. Refer to Filter Structure Diagrams for more information.

This parameter is only visible when Dialog parameters is selected.

Specify Filter Characteristics via Input Port

The Main pane of the Biquad Filter block dialog appears as follows when Input port(s) is selected in the Coefficient source group box.

Filter structure

Select the filter structure.

This parameter is only visible when Dialog parameters or Input port(s) is selected.

Initial conditions

Specify the initial conditions of the filter states. To learn how to specify initial conditions, see Specifying Initial Conditions.

This parameter is only visible when Dialog parameters or Input port(s) is selected and the filter structure is Direct form II or Direct form II transposed.

Initial conditions on zeros side

Specify the initial conditions for the filter states on the side of the filter structure with the zeros (b0, b1,b2, ...); see the next diagram.

This parameter is only visible when Dialog parameters or Input port(s) is selected and the filter structure is Direct form I or Direct form I transposed. To learn how to specify initial conditions, see Specifying Initial Conditions.

Initial conditions on poles side

Specify the initial conditions for the filter states on the side of the filter structure with the poles (a0, a1,a2, ...); see the next diagram.

This parameter is only visible when Dialog parameters or Input port(s) is selected and the filter structure is Direct form I or Direct form I transposed. To learn how to specify initial conditions, see Specifying Initial Conditions.

Scale values mode

Choose how to specify the scale values to use between filter sections. When you select Specify via input port (g), you enter the scale values as a 2-D vector at port g. When you select Assume all are unity and optimize, all scale values are removed and treated like Simulink lines or wires.

This parameter is only visible when Input port(s) is selected.

Specify Discrete-Time Filter Object

The Main pane of the Biquad Filter block dialog appears as follows when Discrete-time filter object (DFILT) is selected in the Coefficient source group box.

Filter

Specify the discrete-time filter object (dfilt) that you would like the block to implement. You can do so in one of three ways:

  • You can fully specify the dfilt object in the block mask.

  • You can enter the variable name of a dfilt object that is defined in any workspace.

  • You can enter a variable name for a dfilt object that is not yet defined.

For more information on creating dfilt objects, see the dfilt function reference page in the Signal Processing Toolbox documentation.

View filter response

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

Specify Fixed-Point Parameters

The Fixed-point pane of the Biquad Filter block dialog appears as follows. This pane only appears when Dialog parameters or Input port(s) is selected in the Coefficient source group box.

Rounding mode

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

Overflow mode

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

Section input

Choose how you specify the word length and the fraction length of the fixed-point data type going into each section of a biquadratic filter. See Fixed-Point Data Types for illustrations depicting the use of the section input data type in this block.

  • When you select Same as input, these characteristics match those of the input to the block.

  • When you select Binary point scaling, you can enter the word and fraction lengths of the section input and output, in bits.

  • When you select Slope and bias scaling, you can enter the word lengths, in bits, and the slopes of the section input and output. This block requires power-of-two slope and a bias of zero.

Section output

Choose how you specify the word length and the fraction length of the fixed-point data type coming out of each section of a biquadratic filter. See Fixed-Point Data Types for illustrations depicting the use of the section input data type in this block.

  • When you select Same as input, these characteristics match those of the input to the block.

  • When you select Binary point scaling, you can enter the word and fraction lengths of the section input and output, in bits.

  • When you select Slope and bias scaling, you can enter the word lengths, in bits, and the slopes of the section input and output. This block requires power-of-two slope and a bias of zero.

Coefficients

Choose how you specify the word length and the fraction length of the filter coefficients (numerator, denominator, and scale value) when Dialog parameters is selected in the Coefficient source group box. See Fixed-Point Data Types for illustrations depicting the use of the coefficient data types in this block:

  • When you select Same word length as input, the word length of the filter coefficients match that of the input to the block. In this mode, the block automatically sets the fraction length of the coefficients to the binary-point only scaling that provides you with the best precision possible given the value and word length of the coefficients.

  • When you select Specify word length, you can enter the word length of the coefficients, in bits. In this mode, the block automatically sets the fraction length of the coefficients to the binary-point only scaling that provides you with the best precision possible given the value and word length of the coefficients.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the coefficients, in bits. If applicable, you can enter separate fraction lengths for the numerator and denominator coefficients.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the coefficients. If applicable, you can enter separate slopes for the numerator and denominator coefficients. This block requires power-of-two slope and a bias of zero.

  • The filter coefficients do not obey the Rounding mode and the Overflow mode parameters; instead, 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:

  • When you select Same as input, these characteristics match those of the input to the block.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the product output, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the product output. This block requires power-of-two slope and a bias of zero.

Accumulator

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

  • When you select Same as input, these characteristics match those of the input to the block.

  • When you select Same as product output, these characteristics match those of the product output.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the accumulator, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the accumulator. This block requires power-of-two slope and a bias of zero.

State

Use this parameter to specify how you would like to designate the state word and fraction lengths when Dialog parameters is selected in the Coefficient source group box. See Fixed-Point Data Types for illustrations depicting the use of the state data type in this block.

This parameter is not visible for Direct form I and Direct form I transposed filter structures.

  • When you select Same as input, these characteristics match those of the input to the block.

  • When you select Same as accumulator, these characteristics match those of the accumulator.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the accumulator, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the accumulator. This block requires power-of-two slope and a bias of zero.

Output

Choose how you specify the output word length and fraction length. See Fixed-Point Data Types for illustrations depicting the use of the output data type in this block.

  • When you select Same as input, these characteristics match those of the input to the block.

  • When you select Same as accumulator, these characteristics match those of the accumulator.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the output, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the output. This block requires power-of-two slope and a bias of zero.

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.

Filter Structure Diagrams

The diagrams in the following sections show the filter structures supported by the Biquad Filter block. They also show the data types used in the filter structures for fixed-point signals. You can set the data types shown in these diagrams in the block dialog box. This is discussed in Dialog Box.

Direct Form I

The following diagram shows the data types for one section of the filter for fixed-point signals.

The following diagrams show the fixed-point data types between filter sections.

When the data is not optimized:

When you select Optimize unity scale values and scale values equal 1:

Direct Form I Transposed

The following diagram shows the data types for one section of the filter for fixed-point signals.

The dashed casts are omitted when Optimize unity scale values is selected and scale values equal one.

The following diagrams show the fixed-point data types between filter sections.

When the data is not optimized:

When you select Optimize unity scale values and scale values equal 1:

Direct Form II

The following diagram shows the data types for one section of the filter for fixed-point signals.

The dashed casts are omitted when Optimize unity scale values is selected and scale values equal one.

The following diagrams show the fixed-point data types between filter sections.

When the data is not optimized:

When you select Optimize unity scale values and scale values equal 1:

Direct Form II Transposed

The following diagram shows the data types for one section of the filter for fixed-point signals.

The following diagrams show the fixed-point data types between filter sections.

When the data is not optimized:

When you select Optimize unity scale values and scale values equal 1:

Supported Data Types

PortSupported Data Types

Input

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed only)

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

Output

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed only)

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

See Also

dfilt.df1sosFilter Design Toolbox
dfilt.df1tsosFilter Design Toolbox
dfilt.df2sosFilter Design Toolbox
dfilt.df2tsosFilter Design Toolbox

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

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