Digital Filter Design Toolkit Reference Manual: August 1995 Edition Part Number 320953A-01
Digital Filter Design Toolkit Reference Manual: August 1995 Edition Part Number 320953A-01
GPIB: gpib.support@natinst.com
DAQ: daq.support@natinst.com
VXI: vxi.support@natinst.com
LabVIEW: lv.support@natinst.com
LabWindows: lw.support@natinst.com
HiQ: hiq.support@natinst.com
FaxBack Support
International Offices
Warranty
The media on which you receive National Instruments software are warranted not to fail to execute programming
instructions, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as evidenced
by receipts or other documentation. National Instruments will, at its option, repair or replace software media that do
not execute programming instructions if National Instruments receives notice of such defects during the warranty
period. National Instruments does not warrant that the operation of the software shall be uninterrupted or error free.
A Return Material Authorization (RMA) number must be obtained from the factory and clearly marked on the outside
of the package before any equipment will be accepted for warranty work. National Instruments will pay the shipping
costs of returning to the owner parts which are covered by warranty.
National Instruments believes that the information in this manual is accurate. The document has been carefully
reviewed for technical accuracy. In the event that technical or typographical errors exist, National Instruments
reserves the right to make changes to subsequent editions of this document without prior notice to holders of this
edition. The reader should consult National Instruments if errors are suspected. In no event shall National Instruments
be liable for any damages arising out of or related to this document or the information contained in it.
EXCEPT AS SPECIFIED HEREIN, NATIONAL INSTRUMENTS MAKES NO WARRANTIES, EXPRESS OR
IMPLIED, AND SPECIFICALLY DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR
A PARTICULAR PURPOSE. CUSTOMER'S RIGHT TO RECOVER DAMAGES CAUSED BY FAULT OR
NEGLIGENCE ON THE PART OF NATIONAL INSTRUMENTS SHALL BE LIMITED TO THE AMOUNT
THERETOFORE PAID BY THE CUSTOMER. NATIONAL INSTRUMENTS WILL NOT BE LIABLE FOR
DAMAGES RESULTING FROM LOSS OF DATA, PROFITS, USE OF PRODUCTS, OR INCIDENTAL OR
CONSEQUENTIAL DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. This limitation of the
liability of National Instruments will apply regardless of the form of action, whether in contract or tort, including
negligence. Any action against National Instruments must be brought within one year after the cause of action accrues.
National Instruments shall not be liable for any delay in performance due to causes beyond its reasonable control. The
warranty provided herein does not cover damages, defects, malfunctions, or service failures caused by owner's failure
to follow the National Instruments installation, operation, or maintenance instructions; owner's modification of the
product; owner's abuse, misuse, or negligent acts; and power failure or surges, fire, flood, accident, actions of third
parties, or other events outside reasonable control.
Copyright
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical,
including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part,
without the prior written consent of National Instruments Corporation.
Trademarks
LabVIEW is a trademark of National Instruments Corporation.
Product and company names listed are trademarks or trade names of their respective companies.
Chapter 1
Overview of the Digital Filter Design Toolkit
Package Contents ..........................................................................................................1-1
Installation .....................................................................................................................1-1
Macintosh and Power Macintosh ....................................................................1-1
Windows .........................................................................................................1-2
Sun and HP-UX ..............................................................................................1-2
Introduction to Digital Filtering ....................................................................................1-3
IIR and FIR Filters ..........................................................................................1-4
Chapter 2
Digital Filter Design Application
Introduction ...................................................................................................................2-1
Operation: the Main Menu ..............................................................................2-3
Opening the Filter Design Panels ...................................................................2-3
Directly Loading a Filter Specification File ...................................................2-3
Editing the DFD Preferences ..........................................................................2-4
Quitting the DFD Application ........................................................................2-4
Digital Filter Design Panels ..........................................................................................2-4
Common Controls and Features .....................................................................2-4
Using the DFD Menu ........................................................................2-4
Saving Filter Specifications ........................................2-5
Loading Filter Specifications .....................................2-6
Saving Filter Coefficients ..........................................2-6
Analyzing Filter Designs ...........................................2-7
DAQ and Filter: Real-World Testing .........................2-7
Transferring Filter Designs ........................................2-7
Returning to the Main Menu ......................................2-8
Chapter 3
IIR and FIR Implementation
Infinite Impulse Response Filters ................................................................................. 3-1
Cascade Form IIR Filtering ............................................................................ 3-2
Finite Impulse Response Filters ................................................................................... 3-4
Format of the Filter Coefficient Text Files ................................................................... 3-5
FIR Coefficient File Format ........................................................................... 3-5
IIR Coefficient File Format ............................................................................ 3-6
Chapter 4
Using Your Coefficient Designs: DFD Utilities
LabVIEW DFD Utilities ............................................................................................... 4-1
Read DFD Coefficients .................................................................................. 4-1
DFD Filter ...................................................................................................... 4-2
LabWindows/CVI Utilities .......................................................................................... 4-3
The DFD Instrument Driver ........................................................................... 4-3
AllocCoeffDFD............................................................................................... 4-4
ReadCoeffDFD ............................................................................................... 4-5
FreeCoeffDFD................................................................................................. 4-5
FilterDFD........................................................................................................ 4-6
Using the DFD Instrument Driver ................................................................. 4-6
Windows DLL DFD Utilities ....................................................................................... 4-7
Appendix A
References
Appendix B
Customer Communication
Glossary
Figures
Figure 2-1. Conceptual Overview of the Digital Filter Design Toolkit...................... 2-2
Figure 2-2. Filter Design Main Menu Panel .............................................................. 2-3
Figure 2-3. DFD Menu Popup ................................................................................... 2-5
Figure 2-4. Classical IIR Filter Design Panel ............................................................ 2-11
Figure 2-5. Magnitude vs. Frequency ........................................................................ 2-13
Figure 2-6. Classical FIR Design Panel ..................................................................... 2-17
Figure 2-7. Frequency Response Magnitude .............................................................. 2-19
Figure 2-8. Pole-Zero Placement Filter Design Panel ............................................... 2-23
Figure 2-9. Z-Plane plot of Filter Poles and Zeros .................................................... 2-24
Figure 2-10. Arbitrary FIR Design Panel .................................................................... 2-29
Figure 2-11. Desired and Actual Magnitude Response ............................................... 2-30
Figure 2-12. Analysis of Filter Design Panel ............................................................... 2-35
Figure 2-13. The DAQ and Filter Panel ....................................................................... 2-41
Figure 2-14. Switching Displays .................................................................................. 2-42
Tables
Table 2-1. Suggested Specification Filename Extensions......................................... 2-6
Table 2-2. Filter Specification Transfers................................................................... 2-7
This manual describes the Digital Filter Design Toolkit package. You can
use this program to design digital filters.
Related Documentation
The following documents contain information that you may find
helpful as you read this manual:
• LabVIEW Analysis VI Reference Manual
• LabVIEW Data Acquisition VI Reference Manual
• LabVIEW Tutorial
• LabVIEW User Manual
• LabWindows/CVI Advanced Analysis Library Reference Manual
• Getting Started with LabWindows/CVI
• LabWindows/CVI User Manual
Customer Communication
National Instruments wants to receive your comments on our products
and manuals. We are interested in the applications you develop with
our products, and we want to help if you have problems with them. To
make it easy for you to contact us, this manual contains comment and
configuration forms for you to complete. These forms are in
Appendix B, Customer Communication, at the end of this manual.
Package Contents
Your Digital Filter Design Toolkit should contain the following
materials.
• The Digital Filter Design Toolkit diskettes.
• LabVIEW Digital Filter Design Toolkit Reference Manual, part
number 320953A-01.
Installation
The following sections contain instructions for installing the Digital Filter
Design Toolkit on the Macintosh, Windows, Sun SPARCstation, and HP-
UX platforms.
Windows
Complete the following steps to install the toolkit.
1. Launch Windows.
2. Insert disk 1 of the Digital Filter Design Toolkit into your 3.5 in.
disk drive.
3. From the File Manager, run setup.exe.
4. Follow the instructions on your screen.
You can obtain the sampling rate or sampling frequency fs from the
sampling interval
1
f s = ----- ,
∆t
which means that, according to the sampling theorem, the highest
frequency that the digital system can process is
f
f Nyq = -----s .
2
∆t = 0.001 sec,
fs = 1000 Hz,
FIR filters, however, process only input samples and can be designed
to have only linear phase distortion. The linear phase distortion can be
compensated by simple delays in the system. FIR filters may require
more coefficients than IIR filters to meet similar design specifications.
Introduction
The Digital Filter Design (DFD) application is a complete filter design
and analysis tool you can use to design digital filters to meet your
precise filter specifications. You can graphically design your IIR and
FIR filters, interactively review filter responses, save your filter design
work, and load your design work from previous sessions.
You can save digital filter coefficients for later implementation from
within LabVIEW and LabWindows CVI. Also, you can call Windows
DFD Dynamic Link Libraries (DLLs) from other applications, or other
applications can load the filter coefficient files directly. This manual
includes all required filter coefficient forms and implementation
equations.
Digital Filter
Design
Application
LabWindows/CVI
After designing your filter, you can move from the design panels to the
Analysis of Filter Design panel to view various frequency domain and
time domain filter responses. Then you can save these responses to text
files for use in other applications. You can also perform real-world
testing of your filter designs by moving to the DAQ and Filter panel,
which performs data acquisition and filtering in parallel with your filter
designing.
If you designed the selected spec file in a different design panel than
the present panel, the DFD application prompts you to open the
appropriate design panel for that specification file. For example, if you
are using the Pole-Zero Placement panel and you load a specification
file saved from within the Classical FIR Design panel, the DFD
application prompts you to open the Classical FIR Design panel to
resume work on the loaded filter specifications.
After you select the format of the coefficient file, the DFD application
prompts you for the name of the filter coefficient file to save. You
should name your coefficient files appropriately for a given filter
design. For example, if you save bandpass IIR filter coefficients, a
Graph
Palette
If you press the x autoscale button, shown at the left, the DFD
application autoscales the X data of the graph. If you press the
y autoscale button, shown at the left, the DFD application autoscales
the Y data of the graph. If you want the graph to autoscale either of the
scales continuously, click on the lock switch, shown at the left, to lock
autoscaling on.
The scale format buttons, shown left, give you run-time control over
the format of the X and Y scale markers respectively.
You use the remaining three buttons to control the operation mode for
the graph.
If you press the panning tool, shown to the left, you switch to a mode
in which you can scroll the visible data by clicking and dragging
sections of the graph.
If you press the zoom tool, shown at the left, you can zoom in on a
section of the graph by dragging a selection rectangle around that
section. If you click on the zoom tool, you get a pop-up menu you can
use to choose some other methods of zooming. This menu is shown in
the following illustration.
Zoom by rectangle.
Zoom in about a point. If you hold down the mouse on a specific point,
the graph continuously zooms in until you release the mouse button.
Zoom out about a point. If you hold down the mouse on a specific
point, the graph continuously zooms out until you release the mouse
button.
Note: For the last two modes, you can zoom in and zoom out about a point .
Shift-clicking zooms in the other direction.
Graph Cursors
Following are illustrations of a waveform graph showing two cursors
and the cursor movement control.
Use this panel to design classical IIR digital filters. These filters
include the classic types (lowpass, highpass, bandpass, and bandstop)
and the classic designs (Butterworth, Chebyshev, Inverse Chebyshev,
and Elliptic).
The lower passband frequency fp1, and upper passband frequency fp2,
and the passband response Gp, define the passband specification. For
the bandpass filter, the passband ranges from fp1 to fp2. The passband
is the region in the frequency domain with a response near 1.0. Gp is
the minimum allowable passband gain or filter magnitude response. In
Figure 2-4, the passband is specified as having a minimum gain of -5
dB between the frequencies of fp1 = 1900 Hz and fp2 = 2600 Hz.
where:
fp1 = passband frequency 1
fp2 = passband frequency 2
fsamp = sampling rate
The lower stopband frequency, fs1 and the upper stopband frequency
fs2, and the stopband attenuation, Gs, define the stopband
specification. For the bandpass filter, the stopband ranges from 0.0
(DC) to the lower stopband frequency, fs1, and from the upper
stopband frequency, fs2, to half the sampling rate (Nyquist). The
stopband is that region in the frequency domain with a response near
0.0. Gs is the minimum acceptable stopband attenuation or filter
magnitude response. In Figure 2-4, Classical IIR Filter Design Panel,
the stopband specification is a minimum attenuation of -40 dB between
the frequencies of 0 and
fs1 = 1500 Hz and between the frequencies of
fs2 = 2600 Hz and 4000 Hz.
where:
fs1 = stopband frequency 1
fs2 = stopband frequency 2
fsamp = sampling rate
In this panel, the DFD application estimates the minimum filter order
that the selected type and design require to meet or exceed the modified
filter specifications. The DFD application computes other appropriate
filter parameters and designs and plots the IIR filter automatically. You
The graph in Figure 2-5, Magnitude vs. Frequency, plots the frequency
response H(f) magnitude of the designed digital filter.
The y-axis is in linear or decibel units, depending on how you set the
button in the upper left corner of the graph.
The x-axis is in units of hertz. The full scale ranges from 0.0 to Nyquist
(sampling rate/2).
By moving the blue cursor lines or crosshairs, you control the passband
response (horizontal lines) and the passband frequencies (vertical
lines).
By moving the red cursor lines, you control the stopband attenuation
(horizontal lines) and the stopband frequencies (vertical lines).
These cursors represent the filter design specifications for the selected
classical IIR filter. In the passband, the filter has a gain of ≥ specified
passband response. In the stopband, the filter has a gain of ≤ specified
stopband attenuation.
Use the linear/dB button to control the display units (linear or dB) of
dB
all magnitude and gain controls and displays. These controls and
displays include Magnitude vs. Frequency plot (y-axis), passband
response, stopband attenuation, and tracking cursor magnitude.
The complete filter specifications can be entered using the text entry
portion at the upper right-hand side of the design panel.
The sampling rate control specifies the sampling rate in samples per
second (hertz).
The type control specifies one of four classical filter types according
to the following values:
0:lowpass
1:highpass
2:bandpass
3:bandstop
The filter order indicator, shown below, displays the estimated filter
order of the classical IIR filter. The DFD application automatically
estimates the filter order as the lowest possible order that meets or
exceeds the desired filter specifications.
The message window displays errors that occur during the IIR design
procedure. Usually these errors reflect filter specifications which are
inconsistent with the chosen filter type.
message
Use the Classical FIR Design panel to design classical FIR digital
filters. These filters include the classic types (lowpass, highpass,
bandpass, and bandstop) and use the Parks-McClellan equiripple FIR
filter design algorithm.
The lower passband frequency, fp1 and upper passband frequency fp2,
and the passband response, Gp, define the passband specification. For
the bandpass filter, the passband ranges from fp1 to fp2. The passband
is the region in the frequency domain with a response near 1.0. Gp is
the minimum acceptable passband gain or filter magnitude response. In
Figure 2-6, the passband specification is a minimum gain of -5 dB
between the frequencies of fp1 = 1900 Hz and fp2 = 2600 Hz.
where:
fp1 = passband frequency 1
fp2 = passband frequency 2
fsamp = sampling rate
The stopband frequencies, fs1 and fs2, and the stopband attenuation, Gs,
define the stopband specification. For the bandpass filter, the stopband
ranges from 0.0 (DC) to the lower stopband frequency, fs1, and from the
upper stopband frequency, fs2, to half the sampling rate (Nyquist). The
stopband is the region in the frequency domain with a response near 0.0.
Gs is the minimum acceptable stopband attenuation or filter magnitude
response. In Figure 2-6, the stopband specification is a minimum
attenuation of -40 dB between the frequencies of 0 and fs1 = 1500 Hz and
between the frequencies of fs2 = 2600 Hz and 4000 Hz.
where:
fs1 = stopband frequency 1
fs2 = stopband frequency 2
fsamp = sampling rate
The Classical FIR Design panel estimates the minimal filter order that
the selected type and design require to meet or exceed the modified
filter specifications. The DFD application automatically computes
other appropriate filter parameters and designs and plots the FIR filter.
You see immediate graphical feedback to help you determine whether
the filter meets your specifications.
Use the design panel DFD Menu to save your filter specifications and
coefficients, load filter designs from previous work, open the Analysis
or the DAQ and Filter panels, transfer the FIR design specifications to
the IIR design panel, or return to the Filter Design Main Menu.
The graph in Figure 2-7 plots the frequency response H(f) magnitude
of the designed digital filter.
The y-axis is in linear or decibel units, depending on how you set the
button in the upper left corner of this graph.
The x-axis is in hertz. The full scale ranges from 0.0 to Nyquist
(sampling rate/2).
The blue cursor lines control the passband response (gain in the
passband and horizontal lines) and the passband frequencies (vertical
lines).
The red cursor lines control the stopband attenuation (gain in the
stopband and horizontal lines) and the stopband frequencies (vertical
lines).
These cursors represent the filter design specifications for the selected
classical IIR filter. In the passband, the filter has a gain of ≥ specified
passband response. In the stopband, the filter has a gain of ≤ specified
stopband attenuation.
The complete filter specifications can be entered using the text entry
portion at the upper right-hand side of the design panel.
The sampling rate control specifies the sampling rate in samples per
second (hertz).
The type control specifies one of four classical filter types according
to the following values:
0: lowpass
1: highpass
2: bandpass
3: bandstop
The filter order indicator displays the estimated filter order of the
classical FIR filter.
The minimize filter order button controls whether the DFD application
minimizes the estimated filter order. If this button is off, the DFD
application uses a fast formula to estimate the filter order to meet or
exceed the desired filter specifications. If this button is on, the DFD
application iteratively adjusts the filter order until it finds the minimum
order that meets or exceeds the filter specifications.
The message window displays errors that occur during the FIR design
procedure. These errors occur when the filter specifications are
inconsistent with the chosen filter type.
message
Use the Pole-Zero Placement Filter Design panel to design IIR digital
filters by manipulating the filter poles and zeros in the z plane. The
poles and zeros initially may have come from classical IIR designs.
Use this panel to move existing poles and zeros directly on the z plane
plot. You can add and delete poles and zeros and accurately control
their important characteristics.
You can fully describe the poles and zeros by using either the text entry
or the cursors in the z-plane plot. As you change the cursors, the text
entries update automatically. Likewise, as you modify the text entries,
the pole/zero cursors update automatically.
The pole and zero locations in the z-plane, the characteristics of each
pole and zero, the gain, and the sampling rate fully describe pole-zero
filter designs. Any change in these parameters corresponds to a change
in the filter coefficients. The DFD application matches the poles and
zeros and creates stable second-order stages for IIR filter coefficients.
The DFD application then uses these coefficients to compute the filter
magnitude response. The Magnitude vs. Frequency plot updates
automatically whenever you change the poles or zeros, for immediate
graphical feedback to your pole-zero filter designs.
Figure 2-9 shows the z-plane plot of the filter poles and zeros. You can
move each pole (red “x”) anywhere within the unit circle, along and
above the x-axis. You can move each zero (blue “o”) anywhere along
and above the x-axis.
delete Click on the delete selected button to delete the selected pole or zero.
selected Click on poles and zeros to select them.
add pole Click on the add pole button to add a pole to the z-plane. The new pole
is located at the origin.
Click on the add zero button to add a zero to the z-plane. The new zero
add zero
is located at the origin.
If you click in the real check box, the zero becomes purely real and is
limited to real-axis movement.
If you click in the lp check box, the zero has linear phase. That is, if the
zero is not real or on the unit circle, the DFD application matches it
with another zero at a radius of 1/r, where r is the radius of the original
zero (the radius is the distance from the origin). Linear phase zeros are
important in linear phase FIR filters. If your z-plane plot contains only
zeros, and all the zeros have linear phase, then the FIR filter you
designed has an overall linear phase response.
If you click on the uc check box, the zero is forced to be located on the
unit circle (radius of 1.0) and is limited to movement along the unit
circle.
The order text entry is the order of the zero, or the number of actual
zeros at this location in the z plane.
The order text entry specifies the pole order, or the number of actual
poles at this location in the z plane.
The y-axis is in linear or decibel units, depending on how you set the
button in the upper left corner of this graph.
The x-axis is in hertz. The full scale ranges from 0.0 to Nyquist
(sampling rate/2).
The sampling rate control specifies the sampling rate in samples per
second (hertz).
sampling rate
8.0000E+3
The gain control specifies the gain constant for the designed filter.
Increasing this gain increases the overall gain of the designed filter.
generate the desired response between your specified points. The DFD
application automatically designs and plots the equiripple FIR filter.
You get immediate graphical feedback to help determine whether the
filter meets your specifications.
The graph in Figure 2-11 plots the desired and actual magnitude
response of the designed FIR filter.
The y-axis is in linear or decibel units, depending on how you set the
button in the upper left corner of the graph. The x-axis is in hertz. The
full scale ranges from 0.0 to Nyquist (sampling rate/2).
The dB button controls the display units (linear or decibel) of all the
dB magnitude controls and displays.
These controls and displays include the Magnitude vs. Frequency plot
(y-axis) and the magnitudes in the array of frequency-magnitude
points.
# points
10
Reducing this number deletes points from the end of the frequency-
magnitude array, while increasing this number inserts the additional
number of points to the right of the selected point.
linear interpolation
The DFD application inserts new points at halfway along the line
connecting the two outer points.
You can select points in this array by clicking in the circle to the right
of each point. You can then delete the selected points by clicking on
the delete button, or move them by clicking on the desired direction
diamond in the lower right corner of the Arbitrary Magnitude Response
graph.
The filter order control specifies the total number of coefficients in the
digital FIR filter.
The ripple indicator displays the largest absolute error (linear) between
the desired and actual filter responses.
ripple 1.3709E-2
The Message window displays errors that occurred during the FIR
design procedure.
message
Click in the uniform spacing box to space the frequency values of the
frequency-magnitude points. The DFD application spaces the
frequency-magnitude points uniformly from 0.0 to sampling rate/2,
inclusive.
The sampling rate control specifies the sampling rate in samples per
second (hertz).
sampling rate 8000.00
Use the DFD Menu to load filter designs from previous work, open the
DAQ and Filter panel, go to the selected filter design panel, or return
to the Filter Design Main Menu.
Analysis Displays
Each of the five filter plots has a zoom box in the upper right corner.
Clicking in this box brings up a full-screen version of that plot. In the
zoom full-screen versions of these plots, you can change the units from linear
box to decibel (magnitude response), from radians to degrees (phase
response) or from seconds to samples (impulse and step responses).
From each full screen view, you can save the response data to text files.
Magnitude Response
The magnitude response is the magnitude of the filter’s response H(f)
as frequency caries from zero to half the sampling rate.
Phase Response
The phase response is the phase of the filter’s response H(f) as
frequency varies from zero to the sampling rate.
The following figure illustrates the phase response of the selected filter
design.
Impulse Response
The impulse response of a digital filter is the filter’s output when the
input is a unit sample sequence (1, 0, 0,...). The input before the unity
sample is also zero.
The following figure illustrates the phase response of the selected filter
design.
Step Response
The step response of a digital filter is the filter’s output when the input
is a unit step sequence (1, 1, 1, ...). The input samples before the step
sequence is defined as zero.
The following figure illustrates the step response of the designed filter.
Z-Plane Plot
The following figure illustrates the z-plane plot of the filter poles and
zeros.
You can view the N(z) and D(z) polynomials for other stages by
incrementing the index shown in the upper left hand side of the H(z)
display.
∑
–j
H(z) = h jz
j=0
where
j=0, 1, ... order -1
hj= FIR filter coefficients
order = number of FIR coefficients
acquired data then passes through the currently designed filter, and the
DFD application plots the input and output waveforms and spectrums.
If you select DFD Menu»DAQ and Filter from a filter design panel,
the DAQ and Filter panel uses that particular set of filter coefficients
when filtering the acquired signals. You can also use any of the four
filter designs from the Filter Design ring selector; the DAQ and Filter
panel uses the filter parameters from the selected design specifications.
Use the DFD Menu to load and test filter designs from previous work,
open Analysis panel, goto the selected filter design panel, or return to
the Filter Design Main Menu.
Use the Filter Design control to set the Filter Design to use in filtering
of the acquired signal. From the DFD menu select “Goto Design” to
load and run the corresponding filter design panel.
Use the on/off switch to control whether you want the DFD to acquire
blocks continuously or on demand.
Click on the DAQ Setup button to change the data acquisition settings
such as the device number, number of samples to acquire, triggering
parameters, or sampling rate.
switching displays for the spectrum of both the input and filtered
signals:
N –1 Na – 1
b
y i = ------ ∑ b j x i – j – ∑ a k y i – k
1
(3-1)
a0
j=0 k=1
The advantage of digital IIR filters over finite impulse response (FIR)
filters is that IIR filters usually require fewer coefficients to perform
similar filtering operations. Thus, IIR filters execute much faster and
do not require extra memory, because they execute in place.
signal monitoring, IIR filters may be appropriate. You should use FIR
filters for those applications requiring linear phase responses.
b0 + b1 z –1 + … + b N – 1 z –( N b – 1 )
H ( z ) = --------------------------------------------------------------------------------
b
- (3-2)
1 + a1 z –1 + … + a N – 1 z –( N a – 1 )
a
Ns
b 0k + b 1k z –1 + b 2k z –2
H(z) = ∏ ----------------------------------------------------
1 + a z –1 + a z –2
(3-3)
k=1 1k 2k
For each stage, you must maintain two past inputs (x[i-1], x[i-2]) and
two past outputs (y[i-1], y[i-2])
n–1
yi = ∑ hk xi – k (3-4)
k=0
You can implement the FIR filter using equation 3-4 directly.
You can implement the IIR filter in cascade stages by using equation
3-1 (maintaining two past inputs and two past outputs for each stage),
or by using the direct form II equations (maintaining two past internal
states).
There are two DFD utility VIs, Read DFD Coefficients and DFD Filter.
To use these VIs, connect the file path of your coefficient file to Read
DFD Coefficients. The output Coefficient Cluster is then connected to
DFD Filter, along with your input signal. Once this sequence is
followed and the VIs have executed, your filtered data will be available
at the DFD Filter output Filtered X.
coefficient file path is the LabVIEW path to the DFD coefficient file.
This file can either be in log or text file format. If coefficient file path
is empty, you will be able to select a coefficient file from an open file
dialog.
new file path is the file path to the coefficient file read. If coefficient
file path was empty, then the new file path contains the path to the file
selected from the open file dialog.
DFD Filter
The DFD Filter VI filters the input array X using the Digital Filter
Design (DFD) coefficient cluster. You should use the Read DFD
Coefficients VI to read your DFD coefficient files and properly
initialize the input Coefficient Cluster.
error is the error code returned from the filtering VIs. You can wire
this output to the Find First Error VI to produce an error cluster. This
cluster can then be wired to the Simple Error Handler VI or the General
Error Handler VI for an immediate report on any errors. You can also
look up error codes in the Error Codes Appendix in the LabVIEW
Cross Reference Manual.
LabWindows/CVI Utilities
This section contains descriptions of the DFD utilities that you can use
from within your LabWindows/CVI applications to read DFD filter
coefficient files and to filter your data using the coefficients.
AllocCoeffDFD
FilterPtr fptr = AllocCoeffDFD (void);
Return Value
ReadCoeffDFD
long err = ReadCoeffDFD (char coeffPath[],
FilterPtr filterCoefficients, double *samplingRate);
Use ReadCoeffDFD to read your DFD filter coefficient file. You must
always call AllocCoeffDFD once before calling this function.
Parameters
Return Value
FreeCoeffDFD
long err = long FreeCoeffDFD (FilterPtr filterCoefficients);
Use FreeCoeffDFD to free the DFD filter coefficient structure and all
of its coefficient arrays.
Parameters
Return Value
FilterDFD
long err = FilterDFD (double inputArray[], long n,
FilterPtr filterCoefficients, double outputArray[]);
Use FilterDFD to filter the input samples using the DFD filter coefficients.
You must always call AllocCoeffDFD and ReadCoeffDFD once before
calling this function.
Parameters
Return Value
See the descriptions for each function and its parameters in the
previous section LabWindows/CVI Utilities . Call these functions the
same way in your code as you call other DLL functions.
The Digital Filter Design Toolkit also provides an example for Visual
Basic 3.0 showing you how to call the DFD utility functions. The
source code is located under the subdirectory
DFDUTILS\WINSRC\EXAMPLE\VB of your installation directory.
Before you run the Visual Basic example, copy DFD16.DLL to your
Windows directory.
References A
This appendix lists the reference material used to produce the Digital Filter
Design Toolkit. For more information about the theories and algorithms
implemented in the Digital Filter Design Toolkit, refer to the following
documents.
1. A. V. Oppenheim and R. W. Schafer, Discrete-Time Signal
Processing, Englewood Cliffs, NJ: Prentice-Hall, 1989
2. T. W. Parks and C. S. Burrus, Digital Filter Design, John Wiley &
Sons, Inc., 1987
3. L. B. Jackson, Digital Filters and Signal Processing, Boston:
Kluwer, 1986
4. A. B. Williams and F. J. Taylor, Electronic Filter Design
Handbook, New York: McGraw-Hill, 1988
5. T. W. Parks and J. H. McClellan, “Chebyshev Approximation for
Nonrecursive Digital Filters with Linear Phase”, IEEE Trans.
Curcuit Theory, Vol. CT-19, pp 189-194, Mar. 1972a
6. T. W. Parks and J. H. McClellan, “A Program for the Design of
Linear Phase Finite Impulse Response Filters”, IEEE Trans. Audio
Electroacoustics, Vol. AU-20, No. 3, pp.195-199, Aug. 1972a
Customer Communication B
For your convenience, this appendix contains forms to help you gather the information necessary
to help us solve your technical problems and a form you can use to comment on the product
documentation. When you contact us, we need the information on the Technical Support Form
and the configuration form, if your manual contains one, about your system configuration to
answer your questions as quickly as possible.
National Instruments has technical assistance through electronic, fax, and telephone systems to
quickly provide the information you need. Our electronic services include a bulletin board
service, an FTP site, a FaxBack system, and e-mail support. If you have a hardware or software
problem, first try the electronic support systems. If the information available on these systems
does not answer your questions, we offer fax and telephone support through our technical support
centers, which are staffed by applications engineers.
Electronic Services
FTP Support
To access our FTP site, log on to our Internet host, ftp.natinst.com, as anonymous and use
your Internet address, such as joesmith@anywhere.com, as your password. The support files
and documents are located in the /support directories.
Fax Telephone
Australia 03 9 879 9422 03 9 879 9179
Austria 0662 45 79 90 0 0662 45 79 90 19
Belgium 02 757 00 20 02 757 03 11
Canada (Ontario) 519 622 9310 519 622 9311
Canada (Quebec) 514 694 8521 514 694 4399
Denmark 45 76 26 00 45 76 71 11
Finland 90 527 2321 90 502 2930
France 1 48 14 24 24 1 48 14 24 14
Germany 089 741 31 30 089 714 60 35
Hong Kong 2645 3186 2686 8505
Italy 02 48301892 02 48301915
Japan 03 5472 2970 03 5472 2977
Korea 02 596 7456 02 596 7455
Mexico 5 202 2544 5 520 3282
Netherlands 03480 33466 03480 30673
Norway 32 84 84 00 32 84 86 00
Singapore 2265886 2265887
Spain 91 640 0085 91 640 0533
Sweden 08 730 49 70 08 730 43 70
Switzerland 056 20 51 51 056 20 51 55
Taiwan 02 377 1200 02 737 4644
U.K. 01635 523545 01635 523154
Technical Support Form
Photocopy this form and update it each time you make changes to your software or hardware, and
use the completed copy of this form as a reference for your current configuration. Completing
this form accurately before contacting National Instruments for technical support helps our
applications engineers answer your questions more efficiently.
If you are using any National Instruments hardware or software products related to this problem,
include the configuration forms from their user manuals. Include additional pages if necessary.
Name _________________________________________________________________________
Company ______________________________________________________________________
Address _______________________________________________________________________
______________________________________________________________________________
Fax (___ )___________________ Phone (___ ) ______________________________________
Computer brand ________________ Model ________________ Processor __________________
Operating system (include version number) ___________________________________________
Clock speed ______MHz RAM _____MB Display adapter _________________________
Mouse ___yes ___no Other adapters installed ______________________________________
Hard disk capacity _____MB Brand ____________________________________________
Instruments used ________________________________________________________________
______________________________________________________________________________
National Instruments hardware product model __________ Revision_______________________
Configuration___________________________________________________________________
National Instruments software product ___________________________ Version_____________
Configuration___________________________________________________________________
The problem is: _________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
List any error messages: __________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
The following steps reproduce the problem: ___________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
Documentation Comment Form
National Instruments encourages you to comment on the documentation supplied with our
products. This information helps us provide quality products to meet your needs.
Title: Digital Filter Design Toolkit Reference
Edition Date: August 1995
Part Number: 320953A-01
If you find errors in the manual, please record the page numbers and describe the errors.
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
m- milli- 10-3
µ- micro- 10-6
n- nano- 10-9
Numbers
1D One-dimensional.
2D Two-dimensional.
A
ASCII American Standard Code for Information Interchange.
D
DAQ Data acquisition.
F
FFT Fast Fourier transform.
I
IIR Infinite Impulse Response.
M
MB Megabytes of memory.
N
Nyquist Rate Half the sampling rate.
O
oversampling rate The ratio between the number of Gabor coefficients and the
number of test samples.
S
sampling rate The rate at which a continuous waveform is digitized.
V
VI Virtual instrument.