Data Acquisition (DAQ) and Control from Microstar Laboratories

Knowledge Base: DAPstudio

  • See the list of other topics for category DAPstudio

Q10039 Selecting data types for FIR filters

Tags: Help, DAP, DAPL, FIR filters, DSP, DAPstudio, filter design

Applies to: DAPL, FIRFILTER, DAPstudio filter designer

DAPstudio allows me to design finite impulse response (FIR) filters with the filter kernel in any data type I want. Which data type is best?

If dynamic range is an issue, pick a floating point data type because the filtering works well over very wide scaling ranges.

If you have highly precise data, or need an exceptionally long filter kernel, select a float, double, or long integer data type. These do a better job of preserving your significant bits.

If data are already in a special data type for some specific reason, filter using that data type.

Otherwise, the word (short) integer data type is typically the best match for sampled data and works fine. This might not be obvious, because selecting the word data type (right click on the plot) seems to produce erratic differences in the frequency response curve. These effects are not as significant as they might appear.

The following three plots show the same filter design, but with different precision options.

floating point design

With float data type, the regular mathematical progression of the design is clear. This particular filter happens to be increasingly effective at removing higher frequencies... at the expense of allowing a little bit of lower frequencies to leak through just above the cutoff. This is a desirable tradeoff when interfering frequencies are expected to be high.

The three blue lines show the noise levels expected because of digitization, regardless of filtering, for rounding to 12, 14, and 16 bits.


unscaled fixed design

With the fixed-point design, rounding filter coefficients to integers results in small, unpredictable variations. Where these happen to match apparent patterns from digitizing certain frequencies, this produced an elevated response. With response peaks near the second blue line, this means an absolute maximum signal in the stopband could produce an observable effect on the 14th bit. As a practical matter, this cannot happen, or there could be no energy in the signal band you care about. For a more plausible case that the interfering high frequency is 10% of the main band (-20 dB), not even the last bit is affected.


scaled fixed design

The FIRFILTER command in the DAPL system has an additional feature that DAPstudio will apply by default. Filter coefficients tend to be rather small. A scaled design (another option selectable by right-clicking on the plot pane) increases the size of every coefficient. The extra factor is canceled out when the filtering is calculated. The results almost match the higher-precision data types.