• No se han encontrado resultados

Productos Cosméticos y de Cuidado Personal

Therefore the impulse response of the system defined in (3.1.15) is fb0, b1, b2, 0, 0, . . .g.

The I/O equation given in (3.1.15) can be generalized as the difference equation with L parameters, expressed as

y…n† ˆ b0x…n† ‡ b1x…n 1† ‡    ‡ bL 1x…n L ‡ 1† ˆXL 1

lˆ0

blx…n l† : …3:1:16†

Substituting x…n† ˆ d…n† into (3.1.16), the output is the impulse response expressed as

h…n† ˆXL 1 1

lˆ0

bld…n l† ˆ bn n = 0 , 1, ..., L 0 otherwise.



…3:1:17†

Therefore the length of the impulse response is L for the difference equation defined in (3.1.16). Such a system is called a finite impulse response (FIR) system (or filter). The impulse response coefficients, bl, l ˆ 0, 1, . . . , L 1, are called filter coefficients (weights or taps). The FIR filter coefficients are identical to the impulse response coefficients. Table 3.2 shows the relationship of the FIR filter impulse response h(n) and its coefficients bl.

3.2 Introduction to Digital Filters

As shown in (3.1.17), the system described in (3.1.16) has a finite number of non-zero impulse response coefficients bl, l ˆ 0, 1, . . . , L 1. The signal-flow diagram of the

INTRODUCTION TO DIGITAL FILTERS 83

Table 3.2 Relationship of impulse response and coefficients of an FIR filter

bl b0 b1 b2 . . . bL 1

n x…n† x…n 1† x…n 2† . . . x…n L ‡ 1† y…n† ˆ h…n†

0 1 0 0 . . . 0 h…0† ˆ b0

1 0 1 0 . . . 0 h…1† ˆ b1

2 0 0 1 . . . 0 h…2† ˆ b2

. . . .

L 1 0 0 0 . . . 1 h…L 1† ˆ bL 1

L 0 0 0 . . . 0 0

Σ y(n) + +

z−1 z−1

b1 b0

x(n) x(n−1)

+ x(n−L+1)

bL−1

Figure 3.6 Detailed signal-flow diagram of FIR filter

system described by the I/O Equation (3.1.16) is illustrated in Figure 3.6. The string of z 1 functions is called a tapped-delay-line, as each z 1 corresponds to a delay of one sampling period. The parameter, L, is the order (length) of the FIR filter. The design and implementation of FIR filters (transversal filters) will be discussed in Chapter 5.

3.2.1 FIRFilters and Power Estimators

The moving (running) average filter is a simple example of an FIR filter. Averaging is used whenever data fluctuates and must be smoothed prior to interpretation. Consider an L-point moving-average filter defined as

y…n† ˆ1

L‰x…n† ‡ x…n 1† ‡    ‡ x…n L ‡ 1†Š

ˆ1 L

X

L 1 lˆ0

x…n l†, …3:2:1†

where each output signal y…n† is the average of L consecutive input signal samples. The summation operation that adds all samples of x…n† between 1 and L can be implemented using the MATLAB statement:

yn ˆ sum(xn(1:L));

Implementation of (3.2.1) requires L 1 additions and L memory locations for storing signal sequence x…n†, x…n 1†, . . . , x…n L ‡ 1† in a memory buffer. As illus-trated in Figure 3.7, the signal samples used to compute the output signal at time n are L samples included in the window at time n. These samples are almost the same as those samples used for the previous window at time n 1 to compute y…n 1†, except that the oldest sample x…n L† of the window at time n 1 is replaced by the newest sample x…n† of the window at time n. Thus (3.2.1) can be computed as

y…n† ˆ y…n 1† ‡1

L‰x…n† x…n L†Š: …3:2:2†

Therefore the averaged signal, y…n†, can be computed recursively as expressed in (3.2.2). This recursive equation can be realized by using only two additions.

However, we need L ‡ 1 memory locations for keeping L ‡ 1 signal samples fx…n†x…n 1†    x…n L†g.

The following C5xx assembly code illustrates the implementation of a moving-average filter of L ˆ 8 based on Equation (3.2.2):

L .set 8 ; Order of filter

xin .usect "indata", 1

xbuffer .usect "indata", L ; Length of buffer y .usect "outdata", 2,1,1 ; Long-word format

amov #xbuffer‡L 1, XAR3 ; AR3 points to endof x buffer amov #xbuffer‡L 2, XAR2 ; AR2 points to next sample mov dbl(*(y)), AC1 ; AC1 ˆ y(n 1)in long format

mov *(xin), AC0 ; AC0 ˆ x(n)

sub *AR3, AC0 ; AC0 ˆ x(n) x(n±L)

add AC0, #-3, AC1 ; AC1 ˆ y(n±1) ‡ 1/L[x(n)±x(n±L)]

mov AC1, dbl(*(y)) ; y(n) ˆ AC1

rpt # (L 1) ; Update the tapped-delay-line

mov *AR2 , *AR3 ; X(n±1) ˆ x(n)

mov *(xin), AC0 ; Update the newest sample x(n)

mov AC0, *AR3 ; X(n) ˆ input xin

The strength of a digital signal may be expressed in terms of peak value, energy, and power. The peak value of deterministic signals is the maximum absolute value of the signal. That is,

Mxˆ max

n fjx…n†jg: …3:2:3†

Window at time n

n−L n−1 Time

n−L+1 n

Window at time n−1

Figure 3.7 Time windows at current time n and previous time n 1

INTRODUCTION TO DIGITAL FILTERS 85

The maximum value of the array xn can be found using the MATLAB function Mx ˆ max(xn);

The energy of the signal x…n† is defined as ExˆX

n

jx…n†j2: …3:2:4†

The energy of a real-valued x…n† can be calculated by the MATLAB statement:

Ex ˆ sum(abs(xn).^ 2);

Periodic signals and random processes have infinite energy. For such signals, an appropriate definition of strength is power. The power of signal x…n† is defined as

Pxˆ lim

If x…n† is a periodic signal, we have

x…n† ˆ x…n ‡ kL†, …3:2:6†

where k is an integer and L is the period in samples. Any one period of L samples completely defines a periodic signal. From Figure 3.7, the power of x…n† can be computed by

For example, a real-valued sinewave of amplitude A defined in (3.1.6) has the power Pxˆ 0:5A2.

In most real-time applications, the power estimate of real-valued signals at time n can be expressed as

Note that this power estimate uses L samples from the most recent sample at time n back to the oldest sample at time n L ‡ 1, as shown in Figure 3.7. Following the derivation of (3.2.2), we have the recursive power estimator

P^x…n† ˆ ^Px…n 1† ‡1

L‰x2…n† x2…n L†Š: …3:2:9†

To further simplify the algorithm, we assume L is large enough so that x2…n L†  ^Px…n 1† from a statistical point of view. Thus Equation (3.2.9) can be further simplified to

P^x…n†  1 1 L

 

P^x…n 1† ‡1

Lx2…n†, …3:2:10†

or

P^x…n†  …1 a† ^Px…n 1† ‡ ax2…n†, …3:2:11a†

where

a ˆ1

L: …3:2:11b†

This is the most effective and widely used recursive algorithm for power estimation because only three multiplication operations and two memory locations are needed. For example, (3.2.11a) can be implemented by the C statement

pxn ˆ (1.0-alpha)*pxn ‡ alpha*xn*xn;

where alpha ˆ 1=L as defined in (3.2.11b). This C statement shows that we need three multiplications and only two memory locations for xn and pxn.

For stationary signals, a larger L (longer window) or smaller a can be used for obtaining a better average. However, a smaller L (shorter window) should be used for non-stationary signals for better results. In many real-time applications, the square of signal x2…n† used in (3.2.10) and (3.2.11a) can be replaced with its absolute value jx…n†j in order to reduce further computation. This efficient power estimator will be further analyzed in Chapter 4 using the z-transform.

3.2.2 Response of Linear Systems

As discussed in Section 3.1.3, a digital system can be completely characterized by its impulse response h…n†. Consider a digital system illustrated in Figure 3.8, where x…n† is the input signal and y…n† is the output signal. If the impulse response of the system is h…n†, the output of the system can be expressed as

y…n† ˆ x…n†  h…n† ˆ X1

kˆ 1

x…k†h…n k† ˆ X1

kˆ 1

h…k†x…n k†, …3:2:12†

x(n) y(n) = x(n)∗h(n)

h(n)

Figure 3.8 A simple linear system expressed in time domain

INTRODUCTION TO DIGITAL FILTERS 87

where * denotes the linear convolution operation and the operation defined in (3.2.12) is called the convolution sum. The input signal, x…n†, is convoluted with the impulse response, h…n†, in order to yield the output, y…n†. We will discuss the computation of linear convolution in detail in Chapter 5.

As shown in (3.2.12), the I/O description of a DSP system consists of mathematical expressions, which define the relationship between the input and output signals. The exact internal structure of the system is either unknown or ignored. The only way to interact with the system is by using its input and output terminals as shown in Figure 3.8. The system is assumed to be a `black box'. This block diagram representation is a very effective way to depict complicated DSP systems.

A digital system is called the causal system if and only if

h…n† ˆ 0, n < 0: …3:2:13†

A causal system is one that does not provide a response prior to input application. For a causal system, the limits on the summation of the Equation (3.2.12) can be modified to reflect this restriction as

y…n† ˆX1

kˆ0

h…k†x…n k†: …3:2:14†

Thus the output signal y…n† of a causal system at time n depends only on present and past input signals, and does not depend on future input signals.

Consider a causal system that has a finite impulse response of length L. That is,

h…n† ˆ 0, n < 0

bn, 0  n  L 1 0 n  L . (

…3:2:15†

Substituting this equation into (3.2.14), the output signal can be expressed identically to the Equation (3.1.16). Therefore the FIR filter output can be calculated as the input sequence convolutes with the coefficients (or impulse response) of the filter.

3.2.3 IIRFilters

A digital filter can be classified as either an FIR filter or an infinite impulse response (IIR) filter, depending on whether or not the impulse response of the filter is of finite or infinite duration. Consider the I/O difference equation of the digital system expressed as

y…n† ˆ bx…n† ay…n 1†, …3:2:16†

where each output signal y…n† is dependent on the current input signal x…n† and the previous output signal y…n 1†. Assuming that the system is causal, i.e., y…n† ˆ 0 for n < 0 and let x…n† ˆ d…n†. The output signals y…n† are computed as

y…0† ˆ bx…0† ay… 1† ˆ b,

This system has infinite impulse response h…n† if the coefficients a and b are non-zero. This system is called an IIR system (or filter). In theory, we can calculate an IIR filter output y…n† using either the convolution equation (3.2.14) or the I/O difference equation (3.2.16).

However, it is not computationally feasible using (3.2.14) for the impulse response h…n†

given in (3.2.17), because we cannot deal with an infinite number of impulse response coefficients. Therefore we must use an I/O difference equation such as the one defined in (3.2.16) for computing the IIR filter output in practical applications.

The I/O equation of the IIR system given in (3.2.16) can be generalized with the difference equation

This IIR system is represented by a set of feedforward coefficients fbl, l ˆ 0, 1, . . . , L 1g and a set of feedback coefficients fam, m ˆ 1, 2, . . . , Mg. Since the outputs are fed back and combined with the weighted inputs, this system is an example of the general class of feedback systems. Note that when all am are zero, Equation (3.2.18) is identical to (3.1.16). Therefore an FIR filter is a special case of an IIR filter without feedback coefficients. An FIR filter is also called a non-recursive filter.

The difference equation of IIR filters given in (3.2.18) can be implemented using the MATLAB function filter as follows:

yn ˆ filter(b, a, xn);

where the vector b contains feedforward coefficients fbl, l ˆ 0, 1, . . . , L 1g and the vector a contains feedback coefficient fam, m ˆ 1, 2, . . . , Mg. The signal vectors, xn and yn, are the input and output buffers of the system. The FIR filter defined in (3.1.16) can be implemented using MATLAB as

yn ˆ filter(b, 1, xn);

Assuming that L is large enough so that the oldest sample x…n L† can be approxi-mated using its average, y…n 1†. The moving-average filter defined in (3.2.2) can be simplified as

INTRODUCTION TO DIGITAL FILTERS 89

where a is defined in (3.2.11b). This is a simple first-order IIR filter. Design and implementation of IIR filters will be further discussed in Chapter 6.