Você está na página 1de 6

BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI

Hyderabad Campus
Digital Signal Processing-LAB
Lab-10
1. [a] Write the generalized transfer function (TF) of an IIR filter.
[b] The following is a code given for IIR filter. Write the TF of the IIR filter and draw its Direct
form II structure.
Code:
#include "configurationcfg.h"
#include "dsk6713.h"
#include "dsk6713_aic23.h"
#include "stdio.h"

float den[] = {1,1.4054,1.3279,0.6297,0.1768,0.0201};


float num[] = {0.1425,0.7125,1.4250,1.4250,0.7125,0.1425};
DSK6713_AIC23_Config
config={0x0017,0x0017,0x00d8,0x00d8,0x0011,0x0000,0x0000,0x0043,0x0081,0x0001};

void main()
{
DSK6713_AIC23_CodecHandle hCodec;
Uint32 l_input, r_input,l_output, r_output;
DSK6713_init();
hCodec = DSK6713_AIC23_openCodec(0, &config);
DSK6713_AIC23_setFreq(hCodec, DSK6713_AIC23_FREQ_16KHZ); // sampling frequency
while(1)
{
while(!DSK6713_AIC23_read(hCodec, &l_input));
while(!DSK6713_AIC23_read(hCodec, &r_input));
l_output=2.25* IIR_FILTER(&den, &num ,l_input);
r_output=l_output;
while(!DSK6713_AIC23_write(hCodec, l_output));
while(!DSK6713_AIC23_write(hCodec, r_output));

}
DSK6713_AIC23_closeCodec(hCodec);
}
signed int IIR_FILTER(float * a, float * b, signed int x)
{
signed long output=0;
static short int reg[6]; //order+1 registers
reg[0] = x - (a[1] * reg[1]) - (a[2] * reg[2]) - (a[3] * reg[3]) - (a[4] * reg[4]) - (a[5] * reg[5]);
output = (b[0] * reg[0]) + (b[1] * reg[1]) + (b[2] * reg[2]) + (b[3] * reg[3]) + (b[4] * reg[4]) + (b[5]
* reg[5]);
reg[5] = reg[4];
reg[4] = reg[3];
reg[3] = reg[2];
reg[2] = reg[1];
reg[1] = reg[0];
return(output);
}
[C] Test the functionality of this IIR filter using DSK kit. To test the filter, generate signals of peak to peak
of 600mv using signal generator. Give this signal as input to the DSK kit through line in and get the
filtered output through the line out of DSK kit. Apply the line in and line out voltage of the DSK kit in two
channels of CRO and note down same in the table given below:

Input frequency

Input voltage(PP)

500

600

1K
2K
3K
3.5K
4K
4.3K

Output voltage (PP)

Attenuation in dB= 20 log


(output/maximum output)

4.5K
4.7K
4.9K
5K
5.1
5.2
5.3
5.5K
6K
6.5K
7K
7.5K
8k
8.5K
9K
10K
10.5K

[D] Plot the frequency response of the filter.

2. Design a low pass IIR filter for the given specification following the instructed steps:
Pass band frequency = 7Khz
Stop band frequency = 10KHz
Pass band ripple = 2dB
Stop band ripple = 50dB
a) Use sampling frequency as 24 KHz. Find normalized frequency and use this to find minimum
order and 3dB frequency using buttord.(Normalized frequency = f/(fs/2))
b) Find the coefficients of the IIR filter to match the filter specification.

c) Write a C code using CCS which will use the obtained coefficients and take external signal
through line in of DSK kit and do the filtering. Give the filtered output at line out.
d) To test the designed filter, generate signals of peak to peak of 600mv using signal generator.
Give this signal as input to the DSK kit through line in and get the filtered output through the
line out of DSK kit. Apply the line in and line out voltage of the DSK kit in two channels of CRO
and note down same in the table given below:

Input frequency

4K
4.5K
5K
5.5K
6K
6.5K
6.7K
7K
7.2k
7.4
7.6K
7.8K
8K
8.5k
9K
9.5k
9.8k
10K
10.3K
10.6K
10.9K
11.4K

Input voltage(PP)

Output voltage (PP)

Attenuation in dB= 20 log


(output/maximum output)

12K
12.5K

3. Design a band pass IIR filter for the given specification following the instructed steps:
3db Cutoff frequency at 4KHz and 8 KHz. Order of filter is 2.
a) Use sampling frequency as 48 KHz. Find minimum order the coefficients of the IIR filter to
match the filter specification.
b) Write a C code using CCS which will use the obtained coefficients and take external signal
through line in of DSK kit and do the filtering. Give the filtered output at line out.
c) To test the designed filter, generate signals of peak to peak of 600mv using signal generator.
Give this signal as input to the DSK kit through line in and get the filtered output through the
line out of DSK kit. Apply the line in and line out voltage of the DSK kit in two channels of CRO
and note down same in the table given below:
Input frequency

2K
2.5K
3K
3.5K
4K
4.5K
5K
5.5K
6K
6.5K
7K
7.5k
7.8K
8K
8.5k
9K

Input voltage(PP)

Output voltage (PP)

Attenuation in dB= 20 log


(output/maximum output)

9.5k
10K
10.9K
11.4K
12K
12.5K

End