Filter Design Toolbox    

Quantizing the IIR Filter

You used the filter design tools in FDATool to design an IIR filter with a passband you defined. To demonstrate the effects of quantization on this filter, we can convert the filter to fixed-point arithmetic and quantize its transfer function coefficients. So, to complete the design process, we need to quantize the IIR filter, keeping its performance intact through the quantization process. You use FDATool in quantization mode to accomplish this operation:

  1. In FDATool, click

    to switch FDATool to quantization mode.
  2. To quantize your IIR filter, click

  1. You have quantized the current filter using the defaults. Under Current Filter Information you see the filter is still stable, eighth-order, and consists of one section. Notice that Source now reads Designed(Quantized). If you import a filter into FDATool, Source changes to read Imported.

    For now the filter uses the default structure -- Direct form II transposed.

  1. Look at the Magnitude Response in the FDATool analysis area, which now shows the response curves for both your original IIR filter (Reference) and the quantized version (Quantized).

  1. While the new filter is stable, quantizing the filter coefficients seriously degraded its response. Truncating some of the coefficients, as you did when you quantized the filter, caused the coefficients to exceed the limits [-1,1) of the fixed data type (called overflow). Those coefficients were truncated to fall within the range -1 to 1. Maybe we can scale the transfer function coefficients of the reference filter so that quantizing the filter does not do such damage.

    If you select Filter Coefficients from the Analysis menu in FDATool, you can review the coefficients of the reference and quantized filters. When you scroll to the bottom of the display in the analysis area, you see that eight coefficients overflowed during quantization. In the left column of the analysis area, the symbols +,-, and 0 appear to indicate which coefficients overflowed or underflowed, and in which direction (toward ±infinity or toward zero. The following table summarizes the meaning of the symbols.

Symbol
Meaning
+
Coefficients marked with this symbol overflowed toward positive infinity. FDATool handled the overflow as directed by the Overflow mode property value for the Coefficient property. In this case the setting is saturate.
-
Coefficients marked with this symbol overflowed toward negative infinity. FDATool handled the overflow as directed by the Overflow mode property value for the Coefficient property. In this case the setting is saturate.
0
Coefficients marked with this symbol underflowed to zero. FDATool handled the underflow as directed by the round mode property value for the Coefficient property. In this case the setting is round toward nearest.

  1. For example, the ninth numerator coefficient underflowed toward zero, and eight of the nine denominator coefficients overflowed toward plus or minus infinity and were saturated to (1-eps) or -1.0. The following data table shows the filter coefficients.

  1. Click Scale transfer-fcn coeffs<=1.

  1. FDATool scales the reference filter coefficients, then quantizes the reference filter again. This time, the coefficients do not overflow or underflow and the filter response in the stop band appears to closely match the reference filter response, as shown in the next figure.

    Your quantized filter is now unstable (check FDATool for the Current Filter Information). When the reference filter poles and zeros are so close to one another, they can be very sensitive to the effects of quantization. In this case, quantizing the filter moved some of the poles outside the unit circle. If you switch to the Pole/Zero plot by selecting Pole/Zero from the Analysis menu in FDATool, you see the poles and zeros for the quantized filter.

    We resolve this problem by converting our filter structure to one that is more robust to quantization effects. For example, we could change from direct form II transposed to a lattice structure, or we could use second-order sections (SOS) to implement our quantized filter. Second-order section form offers a strong option because when we convert to SOSs, we reduce the order of the polynomials that define the filter, and thus reduce the filter sensitivity to quantization.

  1. To convert the filter to second-order section form, select Edit->Convert to Second-Order Sections.

  1. In FDATool, you can keep your filter structure the same and convert to SOS form. Or you can change your filter structure and adopt SOS form. We want to keep the transposed direct form II structure, but use second-order sections to implement the filter.

    When you convert to second-order sections (SOS), you have the option of treating the error between the reference filter magnitude response and the quantized filter magnitude response in one of three ways. The Scale option determines which method FDATool uses:

    FDATool optimizes the order of the second-order sections according to the scaling option you choose. (The tf2sos function that performs the conversion is called with option 'down' for L-2 and 'up' for L-infinity scaling.)

    Our IIR filter does not need to be scaled to meet our needs, so select None from the Scale list and Up from the Direction list.

  1. Click OK to close the dialog and convert the filter according to your settings.
  2. Select Magnitude Response from the FDATool Analysis menu.

  1. Our quantized second-order section filter now has the magnitude response we require, and matches the unquantized filter specifications. In the following figure showing the magnitude response curves for both filters, you cann distinguish between the reference and quantized filter curves only within the beginning of the passband. To emphasize the match between the reference and quantized filters in the passband, use the zoom function to look more closely at the passband as shown.

As you followed this example, you created an arbitrary magnitude IIR filter to match an ideal filter response. Then you quantized the filter and converted it to second-order section form. All of this you accomplished using FDATool, although you could have used the command line to perform the same filter design and quantization operations.

To save the filter you created in FDATool, either select File->Save Session to save the session and your FDATool interface settings, or choose File->Export to export the filter to your MATLAB workspace in transfer function form.


  Designing the IIR Filter Selected Bibliography 

Learn more about the latest releases of MathWorks products:

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