ABSTRACT

There are several types of filters used world widely. The filters may be an analogue filters or a digital filters. The analogue filters will only deal with the analogue signals to remove the noise signals and to manage the bandwidth of the input analogue signals. The digital filters will sample the input signal(Analogue signal) at the sampling frequencies and then start its process to remove the unwanted frequency components to manage the bandwidth and to remove the noise signals. The digital filters are mainly of two types, Finite Impulse Response(FIR) filter and Infinite Impulse Response(IIR) filter. This coursework report is going to deal with the IIR filter design and its implementation, using code composer studio and with the fixed point DSP board DSKC6416

INTRODUCTION

In the present world we are moving our daily life with technologies. Most of the technologies are based on the theory of Digital signal processing. The device used to implement the theory in real time processing is called as Digital signal processor. The digital signal processors are widely used in many applications in our daily life, from communication to the control of speech and image processing. The applications are mobile, radio, disk drive, and so on. It is always important to design a faster, flexible and cost efficient system. Digital processing systems (DSP) provide much larger reliability and are more flexible than the other systems hence are in larger demand in the market. The digital filter mainly contains, an analogue to digital converter(ADC) to capture the input signal. Then the digital signal processor to represent the digital signal. At last the output is captured by the digital to analogue converter(DAC). It also consists of an input filter for anti-aliasing to remove the jacked distortion of the signal and an output filter to modify the processed output signal. An IIR filter is implemented on DSKC6416 which is the type of DSP. This report deals in designing a fixed point IIR filter with the help of a c code, which can be easily implemented on the DSKC6416 DSP kit. Using the coefficients a c program is designed. The impulse response for a given filter coefficients are figured out in MATLAB.

OVERVIEW OF TI C6416 DSK:

The digital signal processor is used as main system in this report to implement the designed filter. The processor used here is a Texas instrument C6416 DSP. The TMS320C6416 starter kit mainly developed by combining with the spectrum digital. It is a low-cost platform, which is designed to speed up the development of high performance applications on TI’s TMS320C64x DSP generation. The processor, operates at a clock period of 1 GHz. The DSK board makes more sufficient to interlink the DSP with the analogue to digital converters, external devices, external memory units, power supplies. The board uses USB communication for true plug and play functions. The DSK board is controlled mainly by the code composer studio(CCS) by USB to get connect with the PC which is running in the normal window. The CCS software contains an inbuilt C code compiler and an assembler so that it helps in programming and control DSP over PC through USB interface. The overview diagram of the TI C6416 DSK board is shown below.

The DSK board mainly contains four connections. Two connections for output audio devices and another two connections for input audio connections. All the ports in the DSK board are interfaced through onboard D/A and A/D converters to the C6416, by preinstallation with codec on the board.

DIGITAL FILTERS:

The digital filters are the most important part of DSP. The digital filters are mainly used for two major purposes. One for the separation of signals that are in a combined state. Other for the restoration of the signals, which have been damaged during the process. The analogue filters can also be used for these tasks but the digital filters can reach more quality, reliability, less sensitive to temperature and aging. The digital filters such as a Finite Impulse Response(FIR) filter and an Infinite Impulse Response(IIR) filter can operate in the discrete- time signals and can be implemented with the digital signal processor. The external signal is captured by ADC, then input samples are processed and finally the resulting output sample is provided by DAC. Here in this report, the IIR filter is used to implement with the TMS320C6416 DSK.

INFINITE IMPULSE RESPONSE FILTER(IIR FILTER):

The filter is called IIR, because the impulse response in the filter will continue to infinity due to their internal feedback from the previous output and feed forward. The first choice to choose the IIR filter is because the speed is paramount and any non-linearity phase is acceptable. The IIR filters are more efficient than FIR filters as it requires fewer coefficients due to the fact they use internal feedback or poles. Moreover, the feedback result can become unstable if the coefficients deviate from true values.

The equation for the Infinte Impulse Response will be represented as mentioned below.

Here y[n] is the filter output signal and x[n] is the filter input signal. bk is the feedforward coefficient and ak is the feedback coefficient.

The output signals get the value from the input and from the previous output values. If the output signal is y[n], then it depends on the current input signal x[n] and previous output signals, y[n-1],y[n-2],……..,y[n-N] and the previous input signals, y[n-1],y[n-2],……..,y[n-M].

There are several types of structure used to design an IIR filter which are represented below.

‘ Direct form I structure

‘ Direct form II structure

‘ Direct form II transpose

‘ Cascade structure

‘ Parallel Form structure

In this report, we are going to implement only Direct form II structure to design the IIR filter.

DIRECT FORM II TRANSPOSE STRUCTURE:

The structure of the Direct form II transposed is given below.

This structure is the modified form of Direct form II structure. It requires the same number of elements as in direct form II.

MATLAB:

MATLAB is defined as Matrix Laboratory, which is the high level fourth generation programming language. It is also an interactive environment for computing, programming and for stimulations. The language tools used for programming are C, C++, JAVA,.etc. Here in this report, the MATLAB is used mainly for the stimulations of IIR filter coefficients and to plot an impulse response, a magnitude response and phase response of the tested filter.

FILTER STRUCTURE DESIGN AND IMPLEMENTATION:

The components used in this report for designing the IIR filter and for implementing the code are MATLAB, DSK6416 fixed point board, signal generator and Cathode Ray Oscilloscope. The filter is designed by the filter structure of Direct form II transposed and with the filter coefficients given in Appendix B. MATLAB FDATOOLS is used to import the coefficients of the filter as mentioned in APPENDIX B to implement the impulse response, a magnitude response and phase response of the tested IIR filter.

The implemented graph of an magnitude response, phase response, poles/zeros plot, impulse response for the given coefficients are shown below respectively.

magnitude response e

Phase Response

Poles and Zeros Plot

Impulse Response

The figure below shows the filter information of the designed IIR filter.

Filter Information

From the figure, the IIR filter is a low pass filter which is designed by Direct-form II transposed structure, using an filter order of 3. The numerator coefficient is bk, which are the zeros and the denominator coefficient is ak , which are the poles of the filter. The designed IIR filter is in stable condition, so that the poles and zeros lie within the unity. The sampling frequency is set as 96KHz. Initially the transfer function of the filter H(z) is given in the analogue form. Then it is transformed from S-domain to Z-domain to design the filter.

DESIGN OF OTHER IIR FILTER:

MATLAB FDAtool is used to design a filter. New coefficients are imported in the filter design and analysis tool. Here the structure of the filter design is Direct form I transform. The sampling frequency is provided as 96KHz in the same tool. Now the filter design will be generated. If the design is found as unstable, then the alteration should be made in poles and zeros. By modifying the position of poles and zeros in the plot, and by adding more poles/zeros within the unity, the design of the filter can become stable. This modification should be done in poles/zeros editor. Then the 16 bit new coefficients will be generated in the target menu as shown in APPENDIX C. The new plot of a magnitude response, impulse response, phase response, and poles/ zeros are shown below respectively.

Magnitude response

Poles/zeros plot

Filter Information

CONCEPTUAL DESIGN OF SOURCE CODE:

The code for the IIR filter is designed using Code Composer Studio. The code for the IIR filter design is given below in APPENDIX A.

// IIR filter

#include “dsk6416.h” //For DSP processor supporting file(I/O registers)

#include “DSK6416_aic23.h”

#include “IIR_Coeffs.cof” // coefficient file

Uint32 fs=DSK6416_AIC23_FREQ_96KHZ; // sampling frequency of codec

short x[N+1] = {0}; // input samples

short y[N+1] = {0}; // output samples

int yn;

interrupt void c_int11() // ISR

{

short k; //

yn=0; // initialize filter’s output

x[0] = input_sample(); // new input @ beginning of buffer

{

for (k = 0; k<= N; k++)
yn += ((b[k] * x[k]>>15)-(a[k] * y[k]>>15));

for (k = N; k > 0; k–) // starting @ end of buffer

{

x[k] = x[k-1]; // update delays with data move

y[k] = y[k=1];

}

y[1]=y[n-1]; // store current output as y[n-1]

output_sample((short)(yn));

return; // show output filter

}

}

void main()

{

comm_intr(); // init DSK, codec, SP0

while(1); // infinite loop

}

From the above code, b[k] and a[k] are the coefficients of the filter. x[k] and y[k] are the input and output samples. The code design of the IIR filter is represented by flowchart below.

ANALYSIS OF THE FILTER CODE DESIGN:

The coefficients of the filter with are given in the APPENDIX B, is included in the code by the header file # include ” IIR_Coeffs.cof”. The filter coefficient file IIR_Coeffs.cof which is created by MATLAB is shown below.

Filter Coefficients (IIR_Coeffs.cof file)

// IIR Filter

// Sampling Frequency 96 KHz

#define N 3

int b[4]={6107, 6852, 6852, 6107};

int a[4]={32768,-26895, 33003,-12960};

From the code, the input samples x[ ], and output samples y[ ], holds the value if (N+1) samples , which are defined as short. That is the samples are divided by 2^15, so that the overflow computation of the error caused by fixed point architecture in the DSK board can be prevented. The output yn is defined as integer. From the file IIR_Coeffs.cof, b[4] and a[4] holds the array value of the coefficients. The sampling frequency of 96KHz is provided in the code as Uint32 fs=DSK6416_AIC23_FREQ_96KHZ. The step by step process of the designed code is explained below.

‘ Initially the size of the the coefficients b[k], a[k] and the input sample x[k] are defined as short. So that the length of the vectors are 16 bits.

‘ The output value yn is defined as an integer.

‘ we defined the initial value of yn as zero.

‘ x[0] will take the input samples.

‘ Now the loop counter starts the process of calculation by the formula of the filter structure as mentioned in the code.

‘ The calculated value is stored in yn.

‘ When the next loop starts, the output samples y[k] will get its value from yn and starts the calculation.

‘ The input buffer will shift down after every loop to get the value into the memory. Here the last value of the array will be deleted, it will have no space in the memory.

‘ Finally the output samples are scaled by output_sample() function.

MAIN CHALLENGES OF IMPLEMENTING IIR FILTER FOR C6416:

‘ The filter design should be checked whether it is stable or unstable. Because if it is in an unstable state, then the filter cannot be implemented for C6416.

‘ The components should be checked properly regarding their functions before using them for the implementation.

‘ The connection between the instruments should be made correctly.

‘ The code which is designed for the implementation of the filter should have the exact structure as the filter.

‘ The code should be complied to verify that the code has no error.

‘ The DSK6416 board is a fixed point, so that the memory can able to hold only a finite number of bits. Due to this, there will be difference between the actual outcome and a desire outcomes. So, sometimes there could be a noise signal in the output.

‘ The softwares such as MATLAB and Code Composer Studio should be checked properly whether they have full features to use in this operates at a clock period of 1 GHz implementation.

TESTING:

Testing is the main portion in the process of design. Testing will help us to find whether the design is successful or not. In this report the design of IIR filter is tested using DSK6416 board, CRO and a signal generator. The step by step process in testing the design of IIR filter is explained below.

‘ First, the instruments used for testing such as DSK6416 board, signal generator and CRO are should be connected through cables.

‘ The DSK6416 board should be connected to PC through USB cable.

‘ Now all the components are connected.

‘ In the PC open the Code Composer Studio file. Then open the Project tab, and click the open project option.

‘ Now click the .pjt file, which will contain the skeleton of the code in which we to design the code for the IIR filter.

‘ Then open the Debug tab and click the built all option. It is the compiler of the studio to show whether the code we design is correct or with error.

‘ If it shows the error, then correct the code and compile it again, till the code is correct.

‘ Then open the Debug tab, and open the connect option in it. Now the DSK6416 board is connected with PC.

‘ Now click the file tab, and open the load program tab. It will the debug folder.

‘ Open the folder and click the .out file. Now the program will be read into the DSK6416 board from the PC.

‘ Finally, open the Debug tab and click the Run option.

‘ Now the output of the stimulation can be seen through CRO.

‘ The input samples are given by the signal generator, by increasing the input frequencies, the amplitude of the output signal will be increased high at 20KHz and then get decreased at 25 KHz, then increases.

‘ Here MATLAB will show the graphical output of the design, which will be helpful to check whether the output we obtained in CRO is correct or not.

‘ The plots of the magnitude response, an impulse response, phase response and poles /zeros can be seen in the MATLAB.

SUMMARY:

Finally, in this report the two IIR filters are designed and implemented. Using this coursework, the aim of getting the detailed knowledge regarding , the design of a filter is achieved. Further this coursework provides knowledge regarding the usage of MATLAB and Code Composer Studio and other hardware components, used for the implementation. At last , designing a digital filter and its implementation have been learnt and done successfully as mentioned to implement.

REFERENCE:

1. RULP CHASSING, “DIGITAL SIGNAL PROCESSING AND ITS APPLICATION WITH THE C6713 AND C6416 DSK”, A JOHN WILEY & SONS, INC., PUBLICATIONS.,2005

2. STEVEN W. SMITH, “THE SCIENTIST AND ENGINEER’S GUIDE TO DIGITAL SIGNAL PROCESSING”, CALIFORNIA TECHNICAL PUBLISHING., 1997-1998

3. James McClellan, Ronald Schafer, and Mark Yoder, ‘Signal Processing First’,

Prentice Hall, New Jersy, 2003. ISBN 0-13-090999-8., 2003

4. T1 C6416 DSK INSTRUCTION MANUAL.

5. LECTURE NOTES OF REAL-TIME DSP BY Dr. ALI AHMADINIA, 2012/2013.

APPENDIX A: CODE LISTING

// IIR filter

#include “dsk6416.h” //For DSP processor supporting file(I/O registers)

#include “DSK6416_aic23.h”

#include “IIR_Coeffs.cof” // coefficient file

Uint32 fs=DSK6416_AIC23_FREQ_96KHZ; // sampling frequency of codec

short x[N+1] = {0}; // input samples

short y[N+1] = {0}; // output samples

int yn;

interrupt void c_int11() // ISR

{

short k; //

yn=0; // initialize filter’s output

x[0] = input_sample(); // new input @ beginning of buffer

{

for (k = 0; k<= N; k++)
yn += ((b[k] * x[k]>>15)-(a[k] * y[k]>>15));

for (k = N; k > 0; k–) // starting @ end of buffer

{

x[k] = x[k-1]; // update delays with data move

y[k] = y[k=1];

}

y[1]=y[n-1]; // store current output as y[n-1]

output_sample((short)(yn));

return; // show output filter

}

}

void main()

{

comm_intr(); // init DSK, codec, SP0

while(1);} // infinite loop

APPENDIX B: FILTER COEFFICIENTS

IIR Filter

// Sampling Frequency 96 KHz

#define N 3

int b[4]={6107, 6852, 6852, 6107};

int a[4]={32768,-26895, 33003,-12960};

APPENDIX C: NEW FILTER COEFFICIENTS GENERATED IN MATLAB

/*

* Filter Coefficients (C Source) generated by the Filter Design and Analysis Tool

*

* Generated by MATLAB(R) 7.14 and the Signal Processing Toolbox 6.17.

*

* Generated on: 11-Mar-2013 12:45:10

*

*/

/*

* Discrete-Time IIR Filter (real)

* ——————————-

* Filter Structure : Direct-Form I

* Numerator Length : 5

* Denominator Length : 5

* Stable : Yes

* Linear Phase : No

*/

/* General type conversion for MATLAB generated C-code */

#include “tmwtypes.h”

/*

* Expected path to tmwtypes.h

* C:MATLABR2012aexternincludetmwtypes.h

*/

/*

* Warning – Filter coefficients were truncated to fit specified data type.

* The resulting response may not match generated theoretical response.

* Use the Filter Design & Analysis Tool to design accurate

* int16 filter coefficients.

*/

const int NL = 5;

const int16_T NUM[5] = {

918, 1737, 2327, 1737, 918

};

const int DL = 5;

const int16_T DEN[5] = {

32767, -32768, 32767, -32768, 9142

};

**...(download the rest of the essay above)**