What is filter ? A filter is a circuit that passes certain frequencies and rejects all others. What do we mean by passband ? The passband is the range of frequencies allowed through the filter. What is critical frequency fc ? The critical frequency defines the end (or ends) of the passband. is normally specified at the point where the response drops - 3 dB (70.7%) from the passband response. What is a transition region ? It is a region Following the passband leading into stopband region What is a stop region ? It is a region at the end of passband Basic filter response low-pass filter Basic low-pass filter Circuit The low-pass filter allows frequencies below the critical frequency to pass and rejects other. The simplest low-pass filter is a passive RC circuit with the output taken across C Ideal and Practical low-pass filter response Practical low-pass filter response BW is the bandwidth of an ideal low-pass Where : BW=fc Example: A certain low-pass filter has a critical frequency of 800 Hz. What is its bandwidth? Calculation Simple LP Digital filter vin(t)xi v out(t)yi dtt dvoutyi-yi-1 That is, this discrete-time implementation of a simple RC low-pass filter is the exponentiallyweighted moving average // Return RC low-pass filter output samples, given input samples, // time interval dt, and time constant RC function lowpass(real[0..n] x, real dt, real RC) var real[0..n] y var real α := dt / (RC + dt) y[0] := x[0] for i from 1 to n y[i] := α * x[i] + (1-α) * y[i-1] return y for i from 1 to n y[i] := y[i-1] + α * (x[i] - y[i-1]) High-Pass filter Basic high-pass circuit A high-pass filter is one that significantly attenuates or rejects all frequencies below fc and passes all frequencies above fc. The critical frequency is, again, the frequency at which the output is 70.7% of the input (or - 3 dB) Practical low-pass filter response Ideal and Practical low-pass filter response Calculation Simple HP Digital filter // Return RC high-pass filter output samples, given input samples, // time interval dt, and time constant RC function highpass(real[0..n] x, real dt, real RC) var real[0..n] y var real α := RC / (RC + dt) y[0] := x[0] for i from 1 to n y[i] := α * y[i-1] + α * (x[i] - x[i-1]) return y for i from 1 to n y[i] := α * (y[i-1] + x[i] - x[i-1]) FIR (finite impulse response) Filters • These filters are systems for which each output sample is the sum of a finite number of weighted samples of the input sequence. • a filter is a system that is designed to remove some component or modify some characteristic of a signal, but often the two terms are used interchangeably. • the basic input-output structure of the FIR filter as a time domain computation based on a feed-forward difference equation. Discrete-Time Systems • A discrete-time system is a computational process for transforming one sequence, called the input signal, into another sequence called the output signal • In general, we represent the operation of a system by the notation • Block-diagram representation of a discrete time system. • Simple Example In this case, the output depends only on one input value. • complicated example would be the following system definition: In this case, the output depends on three consecutive input values. The Running-Average (moving average) Filter • A simple but useful transformation of a discrete-time signal is to compute a moving average or running average of two or more consecutive numbers of the sequence, thereby forming a new sequence of the average values. • Averaging is commonly used whenever data fluctuate and must be smoothed prior to interpretation. • Case study : stock-market prices fluctuate noticeably from day to day, or hour to hour. example Finite-length input signal, x[n]. • The sequence is an example of a finite-length signal. • we can compute a new sequence called y [n], which is the output of the averaging operator. • A 3-point average of the values {x[0], x[l], x[2]} = [2, 4, 6} gives the answer 1/3 (2 + 4 + 6) =4. • The next output value is obtained by averaging (x[l], x[2], x[3]} = (4, 6, 4} which, yields a value of 14/3. • With this indexing, the equations for computing the output from the input are • which generalizes to the following input-output equation: • The equation given in is called a difference equation. It Finite-length input signal, x[n]. Output of running-average filter, y[n] to compute the entire output signal for all index values — < n < . For the input of x[n], the result is the signal y[n] tabulated as follows: • Note that the values in orange type in the x[n] row are the numbers involved in the computation of y[2]. • Also note that y[n] = outside of the finite interval —2 < n < 4; i.e., the output also has finite support. Observe that the output sequence is longer (has more nonzero values) than the input sequence, and that the output appears to be a somewhat rounded-off version of the input; i.e. it is smoother than the input sequence. In this case, n would stand for time, and we can interpret y[n] . as the computation of the present value of the output based on three input values. Since these inputs are indexed as n, n + 1, and n + 2, two of them are "in the future." Causal And Noncasual Filter • In general, values from either the past or the future or both may be used in the computation. • The running-average filter calculation at the present time (l=n) uses values within a sliding window. • Gray shading indicates the past (L<n); orange shading, the future (L > n). Here, the sliding window encompasses values from both the future and the past. • as shown in the figure . In all cases of a 3-point running average, a • sliding window of three samples determines which three samples are used in the computation of y[n]. • A filter that uses only the present and past values of the input is called a causal filter. backward average • a filter that uses future values of the input is called noncausal. • Noncausal systems cannot be implemented in a real-time application because the input is not yet available when the output has to be computed. In other cases, where stored data blocks are manipulated inside a computer, the issue of causality is not crucial. • Observe that the output of the causal filter is simply a shifted version of the output of the previous noncausal filter. EXERCISE 5.1: Determine the output of a centralized average for the following figure Is this filter causal or noncausal? What is the support of the output for this input? How would the plot of the output compare to the figure below ? FIR filter in Labview The General FIR Filter In the previous example ( not the exercise ): M = 2 and bk = 1/3 for k = 0, 1, 2, • If the coefficients bk are not all the same, then we might say that y[n] defines a weighted running average of M + 1 samples. Operation of the Mth order causal FIR filter showing various positions of the sliding window of M + 1 points under which the weighted average is calculated. When the input signal x [n] is also finite length (N points), the sliding window will run onto and off of the input data, so the resulting output signal will also have finite length The parameter M is the order of the FIR filter The number of filter coefficients is also called the filter length (L). L =M+1 An Illustration of FIR Filtering consider a signal Unit Impulse Sequence The unit impulse is perhaps the simplest sequence because it has only one nonzero value, which occurs at n = 0. The mathematical notation is that of the Kronecker delta function It is tabulated in the second row of this table: Shifted impulse sequence • A shifted impulse such as [n - 2] is nonzero when its argument is zero, i.e., n - 2 = 0, or equivalently n = 2. The third row of the table gives the values of the shifted impulse [n-2]. • The shifted impulse is a concept that is very useful in representing signals and systems. Consider, for example, the signal The following table shows the individual sequences and their sum: Block diagram showing definition of impulse response any sequence can be represented in this way. • The equation is true if k ranges over all the nonzero values of the sequence x[n]. • The equation states the obvious: The sequence is formed by using scaled shifted impulses to place samples of the right size at the right positions. Unit Impulse Response Sequence When the input to the FIR filter is a unit impulse sequence, x[n] = [n], the output is, by definition, the unit impulse response, which we will denote by h[n]. Substituting x[n] = [ n] in gives the output y[n] = h[n]: • the impulse response h[n] of the FIR filter is simply the sequence of difference equation coefficients. EXERCISE 5.3: Determine and plot the impulse response of the FIR system The Unit-Delay System One important system is the operator that performs a delay or shift by an amount n0 Delayed Finite-length input signal , y[n]=x[n-2] • When n0 = 1, the system is called a unit delay. • The delay system is actually the simplest of FIR filters; it has only one nonzero coefficient. For example, a system that produces a delay of 2 has filter coefficients {bk } = [0, 0, 1}. The order of this FIR filter is M = 2, and its difference equation is