24-09-2013, 02:41 PM
Implementing IIR Digital Filters
Implementing IIR .pdf (Size: 221.63 KB / Downloads: 75)
INTRODUCTION
This application note describes the implementation of
various digital filters using the PIC17C42, the first
member of Microchip’s 2nd generation of 8-bit
microcontrollers. The PIC17C42 is a very high speed
8-bit microcontroller with an instruction cycle time of
250 ns (@ 16 MHz input clock). Even though the
PIC17C42 is an 8-bit device, it’s high speed and effi-
cient instruction set allows implementation of digital fil-
ters for practical applications. Traditionally digital filters
have been implemented using expensive Digital Signal
Processors (DSPs). In a system the DSP is normally a
slave processor being controlled by either an 8-bit or
16-bit microcontroller. Where sampling rates are not
high (especially in mechanical control systems), a sin-
gle chip solution is possible using the PIC17C42.
IMPLEMENTATION
A 4th order IIR Filter is implemented by cascading two
of the structures shown in Figure 1. The output Y (out-
put of each filter stage) is computed by direct imple-
mentation of Equation 1 and Equation 2. Since each
stage is similar algorithmically, it is implemented as a
macro using Microchip’s, Assembler/Linker for
PIC17C42. This Macro (labelled BIQUAD) is called
twice for implementing a 4th order filter. The output of
the 1st stage is directly fed to the input of the second
stage without any scaling.
Scaling may be required depending on the particular
application. The user can modify the code very easily
without any penalty on speed. Also, saturation
arithmetic is not used. Overflows can be avoided by lim-
iting the input sequence amplitude. All numbers are
assumed to be 16 bits in Q15 format (15 decimal points,
MSb is sign bit). Thus the user must scale and sign
extend the input sequence accordingly. For example, if
the input is from a 12-bit A/D converter, the user must
sign extend the 12-bit input if bit 11 is a one.
PERFORMANCE
The resource requirements for filter implementations
using a PIC17C42 is given in Table 3. These numbers
can be used to determine whether a higher order filter
can be executed in real-time. The same information
may be used to determine the highest sampling rate
possible.