0% found this document useful (0 votes)
4 views8 pages

Presentation 10

The document outlines the steps to design linear phase FIR filters using the windowing method, including specifying filter specifications, computing the cut-off frequency, and generating the desired impulse response. It provides MATLAB and C code examples for implementing high pass, low pass, and band pass filters with a specified order and different windows. Additionally, it describes the procedure for testing the generated filter coefficients using a signal generator and CRO setup.

Uploaded by

prathik.genaro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views8 pages

Presentation 10

The document outlines the steps to design linear phase FIR filters using the windowing method, including specifying filter specifications, computing the cut-off frequency, and generating the desired impulse response. It provides MATLAB and C code examples for implementing high pass, low pass, and band pass filters with a specified order and different windows. Additionally, it describes the procedure for testing the generated filter coefficients using a signal generator and CRO setup.

Uploaded by

prathik.genaro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Designing of High pass, Low pass and band pass FIR filter for a given cut off, order

and a given window

Following are the steps to design linear phase FIR filters Using Windowing Method.

I. Clearly specify the filter specifications.


Eg: Order = 30;
Sampling Rate = 8000 samples/sec
Cut off Freq. = 400 Hz.

II. Compute the cut-off frequency Wc


Eg: Wc = 2*pi* fc / Fs
= 2*pi* 400/8000
= 0.1*pi

III. Compute the desired Impulse Response hd (n) using particular Window Eg:
b_rect1=fir1(order, Wc , 'high', boxcar(31));

(Matlab function for Generating high pass filter coefficients with order equal to 30, cut-off frequency
400 Hz with Rectangular window. Parameters within the functions can be changed to obtain coefficients
of different types of filter)
IV. Convolve input sequence with truncated Impulse Response x (n)*h (n)

Matlab program for generating filter coefficients of high pass filter with cut off frequency of 400, 800 and
1200 with order equal to 30 and using different windows like rectangular, triangular and Kaiser
// C program to implement low pass, high pass and band pass filter with order 30 and rectangular window
// For low pass and high pass cut off is 2 KHz and for band pass 3-10KHz

#include "L138_LCDK_aic3106_init.h"
#define N 31 //number of coefficients

float h[N]={0.01525652688, 0.01155856438, 0.006443395745,-4.29373144e-17,-0.007614922244,


-0.0161819905, -0.02542754449, -0.0350350365, -0.04465886205, -0.05393996835,
-0.06252241135, -0.07007007301, -0.07628263533, -0.08090995252, -0.08376414329,
0.932015717, -0.08376414329, -0.08090995252, -0.07628263533, -0.07007007301,
-0.06252241135, -0.05393996835, -0.04465886205, -0.0350350365, -0.02542754449,
-0.0161819905,-0.007614922244,-4.29373144e-17, 0.006443395745, 0.01155856438,
0.01525652688}; //HPF-2KHz-Rectangular */

/*float h[N]={-0.01348909363, -0.01021953207,-0.005696943495,2.920240591e-18, 0.006732751615,


0.01430734433, 0.02248182334, 0.03097631037, 0.03948523849, 0.04769114777,
0.05527933314, 0.06195262074, 0.06744547188, 0.0715367198, 0.0740602687,
0.07491308451, 0.0740602687, 0.0715367198, 0.06744547188, 0.06195262074,
0.05527933314, 0.04769114777, 0.03948523849, 0.03097631037, 0.02248182334,
0.01430734433, 0.006732751615,2.920240591e-18,-0.005696943495, -0.01021953207,
-0.01348909363}; //LPF-2KHz-Rectangular*/
/*float h[N]={ 0.02425338328, 0.004938407801,-0.001079704845, 0.02781886607, 0.05735153705,
0.04029640928, -0.01203345321, -0.03613776714,-0.005907028913, 0.01629591547,
-0.04440294951, -0.1557321399, -0.1814887673, -0.03456885368, 0.1947017014,
0.3058844209, 0.1947017014, -0.03456885368, -0.1814887673, -0.1557321399,
-0.04440294951, 0.01629591547,-0.005907028913, -0.03613776714, -0.01203345321,
0.04029640928, 0.05735153705, 0.02781886607,-0.001079704845, 0.004938407801,
0.02425338328}; //BPF-3KHz-10Khz-Rectangular*/

float x[N]; // filter delay line


interrupt void interrupt4(void)
{
short i;
float yn = 0.0;

x[0] = (float)(input_left_sample()); // input from ADC


for (i=0 ; i<N ; i++) // compute filter output
yn += h[i]*x[i];
for (i=(N-1) ; i>0 ; i--) // shift delay line
x[i] = x[i-1];
output_left_sample((int16_t)(yn)); // output to DAC
return;
}
int main(void)
{

L138_initialise_intr(FS_48000_HZ,ADC_GAIN_0DB,DAC_ATTEN_0DB,LCDK_LINE_INPUT);

while(1);

} // end of main()

PROCEDURE:

1. After successful generation of .out file connect target to host PC


2. Connect signal generator to LINE INPUT with 2Vp-p Sine Wave frequency is set according to
filter co-efficient
3. Connect CRO to LINE OUT with volt/div at 1 and time/div at 5msec

You might also like