Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Dec 20, 2006


Feedback


Yes No

Related Categories

Development Topic

Related Links - Developer Zone

Related Links - Products and Services

digital filter

2 ratings | 4.50 out of 5
Print

A filter that is built by converting the analog signals to digital values, and then implementing the filter using digital circuits, such as delay lines, accumulators, and feedback elements.

Digital filtering involves the inherent inter-linking between modulation and signal filtering. Whether you are in the analog or digital domain, most often modulation operations will not properly function if they are not (usually) preceded, combined with, or followed by, the appropriate filter. One of the problems most of us encounter when designing and using digital filters is that, at least at the start, their forms and functions are not intrinsically intuitive. The following topics and examples are certainly NOT meant to be a tutorial on the design and use of digital filter. Rather, they are intended to provide, what is hoped, some unique perspective on the concepts and operations of these essential tools for contemporary circuit design and oppression. Many of the ideas presented were given to the author by the late Robert Hurst, (then) manager of the newly-formed digital television group of the RCA Broadcast Television Division.

Figure 45 shows a fundamental filter building block. What is intriguing about this circuit configuration is that, in principle, it can be used both in the analog and digital domains.

Figure 45. The prototype comb filter. The combination of the just two elements, an analog delay line and a summing circuit, forms a device that can remove certain periodic signals in the signal’s spectrum.

For years, the general type of circuit shown in Figure 45 has been routinely used in NTSC color television to separate or isolate the luminance (black and white) and the chroma (color) signals so that they do not interfere with, and thus degrade, each other. Without providing the background, it can be shown that the makeup (the spectrum) of both the luminance and chroma signals is built in discrete "chunks." If the spectrum is analyzed, it resembles the repeating teeth of a comb.

Figure 46 The line spectra of the NTSC luminance (darker lines) and chrominance (lighter lines). The lines in each spectrum are separated by 15,750 Hz. However, the chrominance line spectrum is centered around the 3.58 color signal (burst) reference and is offset one-half line time or 7,875 Hz. The amplitude spectrum of this comb filter is shown in Figure 47.


Figure 47 The output spectrum of the comb filter show in Figure 45. Here one of the filter’s half-sinusoidal comb "teeth" is show centered around some frequency "n." For a television chrominance filter, this frequency would be 3.58 Mhz.

To filter out, that is, separate, both the luminance and chrominance, an additional element would need to be added to this prototype comb filter. This combination luminance and chrominance filter is shown in Figure 48.



Figure 48 A composite analog comb filter that can separate (filter) out the luminance and the chrominance from an NTSC video signal. It shows the comb filter and the response of each section of the filter.

The salient point about this comb filter is that it is operating on discrete (line-spectrum) signals. Although these signals are not in the digital domain, their carefully orchestrated repetition presents us with the first requirement for representing most digital-domain signals. There are many other examples of discrete series in the analog domain. We are so used to using our pocket calculator to find the number for the sine of an angle, it is often forgotten that trigonometric functions can be represented by a series function. For example, sin x = x - x3/3! + x5/5! - x7/7! + ... Besides trig functions, including hyperbolics, common and natural log functions, e, binomials, interest rates, and more and more functions can be represented as discrete series. Thus, the analog world can provide a fine foundation for an introduction to the digital world.

Using some of the ideas just presented, it is time to design a "first attempt" digital filter. This design will use one of the most common digital filter design processes: find an appropriate analog filter design and tailor it to fit in the digital world. This first attempt model will be the very common analog, low-pass R-C filter shown in Figure 7 below.



Figure 7 A simple low-pass RC filter.

The problem statement for producing its digital equivalent can be divided into three questions. First, what is the input (function) to the network? Second, what is the makeup of the digital network and how can its effect on the input signal be described? Third, what is the resulting output of the network? For a first attempt, we will guess that the following are the answers to these three questions. (1) The input will be the sampled equivalent of a step function. (2) The network will be the digital equivalent of the comb filter. (3) Since the input is a step function, the output quite possibly will be an exponential function. Figure 49 shows a schematic of this attempt.


Figure 49 The idea for the first attempt digital-domain design of the analog filter shown in Figure 7. This design will necessitate converting the input step, the comb delay, and the adder to their digital equivalents.

The digital equivalent of an amplitude-of-one step function is a series of samples that each has an amplitude of 1 (unity). The comb delay must be transferred from a transmission-line type device to a digital component such as a D-flipflop or a delay represented by a line of software code. (It will be represented by the Z-1 symbol.)

The adder will likewise be a digital component or a line of code. Figure 50 shows this idea.


A First-Try Digital Filter

Figure 50 The first-attempt implementation of the comb filter in the digital domain. Is the output shown correct?

Using the digitized step function in Figure 50, we can now check on the accuracy of the filter design. When the first impulse comes (is clocked) to the filter input, a 1 (the first unit pulse) will go to the delay function. However, no signal will yet be outputted from the delay. Nevertheless, this first impulse 1 will also appear at the bottom input of the adder. This 1, and only this 1, will be the first signal output.

The second clocking will produce a (second) 1 at the bottom of the adder and also the (first) delayed 1 at the top of the adder. Thus this (second) output of the adder will be 1+1 which will be a pulse with an amplitude of 2. The third clocking will again produce a direct 1 and a delayed 1 for a sum of 2, and on and on. But, something is wrong. Rather than get the desired set of exponentially rising pulses, we get a simple 1 2 2 2 . . . , which is really the pattern shown in the above graph. There are two problems with this first design exponential (?) pattern: the "exponential" is rising too fast and the first term is not zero as our knowledge of circuit theory says it should be. Obviously, this first design of the digital filter was incorrect.

We need some way to "trick" the first pulse into being zero and also to find a way to make the next series of pulses fit the required exponential envelope. The solution is to first add more filter functions (the digital equivalent of the comb delay functions) and also add a fudge factor, termed a coefficient, to each of these delay functions. The second-try filter is shown in Figure 51.

A Second-Try Digital Filter

Figure 51 This schematic, based upon Figures 49 and 50, uses several delay elements, rather than one. It also has fast multipliers, shown as "X," that use weighting coefficient values (A0, A1, A2, ...) to change the magnitude of the output of each delay.

This new filter configuration, with the first coefficient A0 equal to zero, will definitely produce a first output pulse with the desired amplitude of zero. Also, it appears that it should be possible to insert successive coefficients to make the amplitudes of the next pulses fit the desired rising exponential envelope. But how can the values of these next coefficients be obtained?

Previously it was stated that one way to start the design of a digital filter is to recall the design, or some aspects of the design, of an analog filter and adapt those principles to the digital world. Remember that if an (analog) step pulse is fed into an R-C filter, the output will be a rising exponential, starting at zero. This will be the basic mode The following is a very elementary way (an elementary algorithm) used to illustrate the steps in designing a digital filter based on both an analog step function and a simple R-C analog circuit.

1. Assume a simple analog R-C low pass filter with an RC time constant equal to 600 nanoseconds.

2. In the analog domain, assume that this "t" is the amount of (rise) time the circuit is to run or has run so far. This "t" is in seconds or in fractions of seconds such as nanoseconds. In the digital domain this time changes to a clocking or delay time "t" and is likewise in seconds or in fractions of seconds such as nanoseconds.

3. Recall, from basic analog circuit theory, that when a step function excites an R-C circuit, with the capacitor uncharged, the exponential voltage rises across the capacitor can be described by the following equation:

.
Now, substituting T for t:

If this equation is solved using RC = 600 ns and T = 69.84 ns, (a standard clocking number for digital television), the first six values for this vc = 1-e-x becomes 0.0000, 0.1099, 0.2077, 0.2947, 0.3723 and 0.4412. If these six numbers are plotted, they will give 0.0000 and the first five points on the desired rising 1-e-x exponential.

4. Now that we have reviewed the analog-filter background and produced the output exponential values (points) required for the digital equivalent of the analog exponential, what is needed to make the digital filter operate? Referring to Figure 51, this is the sequence of events that transpires.
a. At start of the sequence, assume that the first value of 1 pulse from the digital step function sequence [X(n)], appears at the input of the first Z-1 delay. However, since there is no clocking as yet, it has no effect on this first Z-1 delay or any of the other delay units. However, this value of 1 does go down to the first multiplier and is multiplied by our assigned coefficient of 0. That resulting multiplier output of 0 goes to the accumulator and on out to [Y(0)] for an output of 0. The first requirement is met.

b. Next, the first trick of the clock will transfer this first value of 1 through the first delay and to the A1 multiplier to be multiplied by a yet unspecifiedcoefficient A1. The output of this multiplier will likewise go the accumulator and be added to any previous data (which, in this case is the 0).

c. At the second tick of the clock, the above process is repeated. Now the original value of 1 is clocked through the second Z-1 delay, down to the A2 multiplier where it is multiplied by the second yet unspecifiedcoefficient, A2. That resultant goes to the accumulator. At the third tick of the clock, the original value of 1 is clocked through the third Z-1 delay, and so on. If we can find a way to calculate the proper A1, A2, A3 ... coefficients, the digital filter should give results equivalent to its analog counterpart. Remember, as these value-of-1s, from the digital step function, proceed through the filter, their value MUST be reduced by appropriate coefficients to produce the correct exponential rise time.
To review, remembering that the required vc = 1-e-x values are 0.0000, 0.1099, 0.2077, 0.2947, 0.3723 and 0.4412, the sequence will be:

1. Send the first pulse in and multiply it by 0.
2. Now send this pulse through the first delay and multiply it by a coefficient to give an output of the desired exponential value of 0.1099.
3. Send the pulse through the second delay and multiply it by a coefficient so that the resultant value and the last 0.1099 will add to 0.2077.
4. Send the pulse through the third delay and multiply it by a coefficient so that its resultant value + 0.1099 + 0.2077 will add to 0.2947 ...
5. Using the desired exponential values 0.0000, 0.1099, 0.2077, 0.2947, 0.3723 and 0.4412, each coefficient number can be calculated using the following formula:

CoefA n = This Exponential Value - The Last Exponential Value

For example:
A0 = 0 (by definition)
A1 = 0.1099 - 0 = 0.1099
A2 = 0.2077 - 0.1099 = 0.0977 and
A3 = 0.2947 - 0.2077 = 0.0870 and so on

Calculating the Coefficients for the Example FIR Digital Filter
Table 2 gives a summary of the timing of the digital filter process. The pulses that progressively “march in cadence” through the filter are denoted as X0, X1, X2 ... The coefficients are A0, A1, A2 ... At each value of T, the each value-of-one is multiplied by the appropriate coefficient, as the calculated value is added to the previous multiplication in the accumulator and that sum is output as Y(n).

Table 2 The exponentials and results of the coefficient calculations for the digital filter shown in Figure 51.
Ticks
ns
Solve the Equation
Derive the Coefficient
n
nT
Vc=1-e ^ -(T/RC)
Coeff
0
0.00
0.0000
0.0000
1
69.84
0.1099
0.1099
2
139.68
0.2077
0.0977
3
209.52
0.2947
0.0870
4
279.36
0.3722
0.0776
5
349.20
0.4412
0.0689


The Step-by-Step Operation of the Example FIR Digital Filter
Since the filter that was just completed has no feedback (recursive) elements, it falls in the digital filter category termed finite impulse response (FIR) filters.

Table 3 Marching through the table “T” at a time. The sum of each column will show the amplitude of the rising exponent at that increment of “T.” (Note: There again may be rounding errors in the fourth decimal place)
T=0
T=1
T=2
T=3
T=4
T=5
X0A0=0
X0A0=0
X0A0=0
X0A0=0
X0A0=0
X0A5=0
X1A1=0.1099
X1A1=0.1099
X1A1=0.1099
X1A1=0.1099
X1A4=0.1099
X2A2=0.0977
X2A2=0.0977
X2A2=0.0977
X2A3=0.0977
X3A3=0.0870
X3A3=0.0870
X3A2=0.0870
X4A4=0.0776
X4A1=0.0776
X5A0=0.0689
e -xT=0 ®
0.1099
0.2077
0.2947
0.3722
0.4411

Now let’s try an infinite impulse response (IIR) filter with recursive elements. IIR filters have distinct advantages over FIR filters. Because they use less hardware or less code, they are usually less expensive. Often they operate much faster. However, if the user needs linear phase response, a FIR filter is usually the best choice.


Figure 52 The prototype digital IIR filter. Here the signal is progressively fed back to circuits that delay it and multiply it by filter coefficients. Note that the output of the filter can go “on and on” to infinity. Thus, it is named an Infinite Impulse Response filter.


Calculating the Coefficients for the Example IIR Digital Filter
Table 4 shows “N” ticks of the clock for this IIR filter just as Table 3 showed the step-by-step results for the FIR filter. Because the IIR filter uses a much simpler configuration, the table is simpler. Also, to reduce the housekeeping for the IIR filter table, the first exponential value of 0.1099 was normalize to unity or 1. However, except for rounding errors, if the final IIR coefficient values (1, 1.89011, 2.68242, 3.38767 and 4.01601) are divided by the normalizing constant of 9.1075, they should, and will, equal the original FIR exponential values of 0.1099, 0.2077, 0.2947, 0.3723 and 0.4412.

Table 4 The calculations for the exponential output pulse values for the IIR filter. These output values are identical to the output values of the FIR filter except that these values are normalized by a factor of 9.1075. (Note: These values may also have rounding errors in the fourth decimal place.)
Nth Pulse
Calculate This Nth Output
IIR Coefficients
0
0
0
1
1 (No feedback yet)
1
2
1 + (1 * 0.89011)
1.89011
3
1 + (1.89011* 0.89011)
2.68242
3
1 + (2.68242 * 0.89011)
3.38767
4
1 + (3.38767 * 0.89011)
4.01601


Summary
After creating both a digital-domain FIR filter and its corresponding IIR filter, we can conclude the following:

1. A digital filter uses some algorithm to progressively alter the input sequential terms of a discrete-time signal.

2. If the reference design model is an analog filter, there can be a very close relationship between the performance of an FIR digital filter and an IIR digital filter.

3. If the input is a discrete-time unit step function, the output of a simple digital filter becomes somewhat intuitive in the same manor that an input continuous-time unit step function produces a somewhat intuitive output from an analog filter. Although it is beyond the scope of this discussion, it can be shown that, again for simple filters, the impulse function shows a similar relationship.

4. The quintessential elements in the digital filter are its unique filter coefficients.

Based upon the above conclusions, the following can also be inferred or developed.

5. The two low-pass filters that were developed had a relatively slow frequency cutoff. In a majority of practical applications, a much more rapid cutoff is desired. You should be able to (and can) obtain a set of filter coefficients for polynomial filters. These filter types, such as Bessel, Butterworth, Chebychev, and so on, provide a wide range of choices for cutoff, in-band ripple, and even phase linearity. Most contemporary IIR filter programs allow the user to choose between these filter types (and more). Once a polynomial filter type is selected, the program will allow the user to select the desired in-band ripple, the stop-band attenuation, and the number of taps (the order). Most digital filter references, including the LabVIEW User Manual, will give the details on these parameters. In addition, they usually show methods for calculating the coefficients for the various filter types.

6. The real-world design of FIR filters usually does not follow the general procedures that were used for that example. Because both the hardware and the software implementations of FIR filters require so many stages to produce any realistic cutoffs, the techniques used must be more efficient than the aforementioned common polynomial designs. To obtain optimum efficiency, most FIR filters, including LabVIEW’s FIR Windowed Filter Design Example, use the Parks-McClellan algorithm. Likewise, most of the FIR designs include an additional technique termed windowing. The details of both the Parks-McClellan algorithm and the technique of windowing are outside the scope of this document. You can find them in most references on digital filters, including the LabVIEW User Manual.

For an interactive demonstration of digital filters using the LabVIEW Player, click demo.



Additional References

Helpful Web Sites:

Information Contributed By: Bob Libbey, Retired RCA Engineer and Adjunct Professor, New Jersey Institute of Technology

2 ratings | 4.50 out of 5
Print

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).