Wednesday, December 26, 2007

Analog and digital filters BASICS

In signal processing, the function of a filter is to remove unwanted parts of the signal, such as random noise, or to extract useful parts of the signal, such as the components lying within a certain frequency range.

There are two main kinds of filter, analog and digital. They are quite different in their physical makeup and in how they work.

An analog filter uses analog electronic circuits made up from components such as resistors, capacitors and op amps to produce the required filtering effect. Such filter circuits are widely used in such applications as noise reduction, video signal enhancement, graphic equalisers in hi-fi systems, and many other areas.
There are well-established standard techniques for designing an analog filter circuit for a given requirement. At all stages, the signal being filtered is an electrical voltage or current which is the direct analogue of the physical quantity (e.g. a sound or video signal or transducer output) involved.
A digital filter uses a digital processor to perform numerical calculations on sampled values of the signal. The processor may be a general-purpose computer such as a PC, or a specialised DSP (Digital Signal Processor) chip.

The analog input signal must first be sampled and digitised using an ADC (analog to digital converter). The resulting binary numbers, representing successive sampled values of the input signal, are transferred to the processor, which carries out numerical calculations on them. These calculations typically involve multiplying the input values by constants and adding the products together. If necessary, the results of these calculations, which now represent sampled values of the filtered signal, are output through a DAC (digital to analog converter) to convert the signal back to analog form.
Note that in a digital filter, the signal is represented by a sequence of numbers, rather than a voltage or current.

Introduction

The importance of digital filters is well established. Digital filters, and more generally digital signal processingalgorithms, are classified as discrete-time systems. They are commonly implemented on a general purpose computeror on a dedicated digital signal processing (DSP) chip. Due to their well-known advantages, digital filters are oftenreplacing classical analog filters.
In this application note, we introduce a new digital filter design and analysis toolimplemented in LabVIEW with which developers can graphically design classical IIR and FIR filters, interactivelyreview filter responses, and save filter coefficients. In addition, real-world filter testing can be performed within thedigital filter design application using a plug-in data acquisition board.Digital Signal Processing (DSP) affords greater flexibility, higherperformance (in terms of attenuation and selectivity), bettertime and environment stability and lower equipment productioncosts than traditional analog techniques. Additionally, more andmore microprocessor circuitry is being displaced with costeffectiveDSP techniques and products; an example of this isthe emergence of DSP in cellular base stations.
Componentsavailable today let DSP extend from baseband to intermediatefrequencies (IFs). This makes DSP useful for tuning and signalselectivity, and frequency up and down conversion.These new DSP applications result from advances in digitalfiltering. This Application Note will overview digital filtering byaddressing concepts which can be extended to basebandprocessing on programmable digital signal processors.

Classical FIR Filter Design

The classical FIR Design panel (Fig. 2) is used to design FIR filters.
These filters include the classic types such aslowpass, highpass, bandpass, and bandstop and employ the Parks-Mclellan equiripple FIR filter design algorithm.This panel is very similar to the Classical IIR Design panel and operates in much the same way. The panel includesa graphical interface with the Magnitude vs Frequency cursors and plot on the left side and a text-based interface withdigital controls on the right side. You design classical FIR filters adjusting the desired filter specifications.
Thedesired passband and stopband requirements define a filter specification. You define the filter requirements by usingeither text entry or the cursors in the Magnitude vs Frequency graph. As the cursors are moved, the text entries areupdated accordingly.

Advantages of using digital filters

The following list gives some of the main advantages of digital over analog filters.

1. A digital filter is programmable, i.e. its operation is determined by a program stored in the processor'smemory. This means the digital filter can easily be changed without affecting the circuitry (hardware).An analog filter can only be changed by redesigning the filter circuit.
2. Digital filters are easily designed, tested and implemented on a general-purpose computer orworkstation.
3. The characteristics of analog filter circuits (particularly those containing active components) aresubject to drift and are dependent on temperature. Digital filters do not suffer from these problems,and so are extremely stable with respect both to time and temperature.
4. Unlike their analog counterparts, digital filters can handle low frequency signals accurately. As thespeed of DSP technology continues to increase, digital filters are being applied to high frequencysignals in the RF (radio frequency) domain, which in the past was the exclusive preserve of analogtechnology.
5. Digital filters are very much more versatile in their ability to process signals in a variety of ways; thisincludes the ability of some types of digital filter to adapt to changes in the characteristics of thesignal.
6. Fast DSP processors can handle complex combinations of filters in parallel or cascade (series),making the hardware requirements relatively simple and compact in comparison with the equivalentanalog circuitry.

Recursive and non-recursive filters

For all the examples of digital filters discussed so far, the current output (yn) is calculated solely from thecurrent and previous input values (xn, xn-1, xn-2, ...). This type of filter is said to be non-recursive.A recursive filter is one which in addition to input values also uses previous output values. These, like theprevious input values, are stored in the processor's memory.The word recursive literally means "running back", and refers to the fact that previously-calculated outputvalues go back into the calculation of the latest output.
The expression for a recursive filter therefore containsnot only terms involving the input values (xn, xn-1, xn-2, ...) but also terms in yn-1, yn-2, ...From this explanation, it might seem as though recursive filters require more calculations to be performed,since there are previous output terms in the filter expression as well as input terms.

In fact, the reverse isusually the case:
to achieve a given frequency response characteristic using a recursive filter generally requiresa much lower order filter (and therefore fewer terms to be evaluated by the processor) than the equivalent nonrecursivefilter. This will be demonstrated later.

Analog Filters, Software-Based FILTERS

Analog Filters, Software-Based and
Owing to the way that analog and digital filters are physicallyimplemented, an analog filter is inherently more size-andpower-efficient, although more component-sensitive, than itsdigital counterpart - if it can be implemented in astraightforward manner. In general, as signal frequencyincreases, the disparity in efficiency increases.Characteristics of applications where digital filters are moresize and power efficient than analog filters are: linear phase,very high stop band attenuation, very low pass band ripple;the filter’s response must be programmable or adaptive; thefilter must manipulate phase and, very low shape factors (adigital filter’s shape factor is the ratio of the filter’s pass bandwidth plus the filter’s transition band width to the filter’s passband width).
General-purpose digital signal microprocessors, nowcommodity devices, are used in a broad range ofapplications and can implement moderately complex digitalfilters in the audio frequency range. Many standard signalprocessing algorithms, including digital filters, are availablein software packages from digital signal processor and thirdparty vendors. As a result, software development costs aretrivial when amortized over production quantities.The architectures of digital signal microprocessors areusually optimized to perform a sum-of-products calculationwith data from RAM or ROM. They are not optimized for anyspecific DSP function.
However, to get extended samplingrate performance from a digital filter requires hardwaredesigned to perform the intended filter function at thedesired sampling frequencies.For example, Intersil Corporation offers a family of standarddigital filter products with several others in development.Some hardware-specific digital filters can now sample atrates approaching 75 Megasamples Per Second (MSPS).Higher performance is possible for high volume applicationsby limiting the range of parameters. Standard filter productsstrike a balance between optimized filter architectures andprogrammability by offering a line of configurable filters. Thatis, these products are function-specific, with optimizedarchitectures and programmable parameters.

Frequency-Domain Versus Time Domain Thinking

Thinking about analog filters, most engineers arecomfortable in the time domain. For example, the operationof an RC lowpass filter can easily be envisioned as acapacitor charging and discharging through a resistor.
Likewise, it is easy to envision how a negative-feedbackactive filter uses phase shift as a function of frequency,which is a time domain operation.A digital filter is better conceptualized in the frequencydomain. The filter implementation simply performs aconvolution of the time domain impulse response and thesampled signal.
A filter is designed with a frequency domainimpulse response which is as close to the desired idealresponse as can be generated given the constraints of theimplementation. The frequency domain impulse response isthen transformed into a time domain impulse responsewhich is converted to the coefficients of the filter.

STRENGTH AND WEAKNESSES

Because an IIR filter uses both a feed-forward polynomialzeros as the roots) and a feedback polynomial (poles as theroots), it has a much sharper transition characteristic for agiven filter order. Like analog filters with poles, an IIR filterusually has nonlinear phase characteristics. Also, thefeedback loop makes IIR filters difficult to use in adaptivefilter applications.Due to its all zero structure, the FIR filter has a linear phaseresponse when the filter’s coefficients are symmetric, as isthe case in most standard filtering applications.
A FIR’simplementation noise characteristics are easy to model,especially if no intermediate truncation is used. In thiscommon implementation, the noise floor is at - 6.02 B + 6.02log2NdB where B is the number of actual bits used in thefilter’s coefficient quantization and N is again the filter order.This is why most Intersil filter ICs have more coefficient bitsthan data bits.An IIR filter’s poles may be close to or outside the unit circlein the Z plane.
This means an IIR filter may have stabilityproblems, especially after quantization is applied. An FIRfilter is always stable. FIR filters also allow development ofcomputationally efficient architectures in decimating orinterpolating applications, which will be described in moredetail later.

FILTER RESPONSE DESIGN METHODS

The total specification of the ideal filter includes the locationof passbands and stopbands, the minimum stopbandattenuation, the maximum passband ripple, the filter order,and perhaps the shape of the response in some of thespecified bands.Typically, there are three stages to the design of digital filterresponses for passband filters. First, the ideal filter responseis specified. Next, a floating point response is designed.Finally, the floating point coefficients are quantized to yield afixed point response.Creating a floating-point IIR filter response starts with aprototype analog filter. Then an s-domain to z-domaintransformation is used to generate a set of digital filtercoefficients.
Common methods of designing floating-pointFIR filter responses are windowing, frequency sampling, andoptimal. All are described in general digital signal processingtexts and are standard in most commercially available digitalfilter design software packages.Converting floating-point coefficients into fixed-pointcoefficients requires quantizing the coefficients andcalculating the frequency domain impulse response of thefilter or filter model to verify that the filter meets the requiredspecification.
If it does not, either the number of coefficientbits can be increased, the filter response can be redefinedand step two repeated, or the filter arithmetic can beredesigned, or a combination of these procedures can beperformed. When filter hardware is at a premium,sophisticated simulated annealing techniques can be usedfor both fixed-point FIR and IIR filters to produce the best setof filter coefficients, given a fixed filter order and coefficientwidth.