185848895-Dsp-Lab-Manual.doc

Share Embed Donate


Short Description

Download 185848895-Dsp-Lab-Manual.doc...

Description

DEPTT. OF ELECTRONICS AND COMMUNICATION ENGG.

Course : B.Tech. (ECE) Year/Semester:III/VI Session: 2008-09 Digital Signal Processing Lab (TEC-652) L T P

0 0 2 S. No.

1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12.

NAME OF THE EXPERIMENT

Sampling & Waveform Generation. Quantization PCM Encoding Delta Modulation Digital Modulation Schemes (ASK, PSK, FSK) Error Correcting Codes DFT Computation. Fast Fourier Transform. FIR Filter implementation. IIR Filter implementation. DSP Processor Implementation Computational Experiments with Digital Filters

DEPTT. OF ELECTRONICS AND COMMUNICATION ENGG. 2008-09

List of Equipment for Digital Signal Processing Lab (TEC-652)

S.No.

Equipment

1

TMS320C6713 DSK development board External 5VDC power supply IEEE 1284 compliant maleto-female cable 233MHz or Higher PentiumCompatible CPU Monitor Frequency Generator CRO Speaker Jack

2 3 4 5 6 7 8

Qty(N os.) 10

Functional Status Working Non-Working 10 NIL

10 10

10 10

NIL NIL

15

15

NIL

15 2 2 5

15 2 2 5

NIL NIL NIL NIL

DEPTT. OF ELECTRONICS AND COMMUNICATION ENGG. 2008-09

List of Consumables for Digital Signal Processing Lab (TEC-652)

S.No.

Items

Quantity (Nos.)

DEPTT. OF ELECTRONICS AND COMMUNICATION ENGG. 2008-09

Course : B.Tech. (ECE) Year/Semester:III/VI Section:C1/C2 List of Students of EC VI Semester for the Session 2008-09 S.No.

Roll No.

Name Group C1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

36 37 38 39 Group C2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

DEPTT. OF ELECTRONICS AND COMMUNICATION ENGG. 2008-09 Digital Signal Processing Lab (TEC-652) Experiment No.-1 Object: Sampling and Waveform Generation. Equipment Used: 6713 DSK Board, IEEE 1284 compliant male- to-female cable, computer system, power supply, CRO, Function Generator, stereo jacks. Theory/Formula Used: In signal processing, sampling is the reduction of a continuous signal to a discrete signal. A common example is the conversion of a sound wave (a continuous-time signal) to a sequence of samples (a discrete-time signal). Let x(t) be a continuous signal which is to be sampled, and that sampling is performed by measuring the value of the continuous signal every T seconds. Thus, the sampled signal x[n] given by x[n] = x(nT), with n = 0, 1, 2, 3, ... The sampling frequency or sampling rate fs is defined as the number of samples obtained in one second, or fs = 1/T. The sampling rate is measured in hertz or in samples per second. Code: For waveform generation: #include #include #include float x[700]; void main() { float A,F,Fs; int i,choice,k,n; printf(" Generation of discrete time signals \n"); printf("\nEnter the frequency of analog signal F = "); scanf("%f",&F); //frequency of the signal printf("Enter the sampling frequency Fs = "); scanf("%f",&Fs); //sampling frequency printf("\nEnter your choice"); printf("\ncosine wave (Enter 1)"); //cosine wave printf("\nsine wave (Enter 2)"); //sine wave printf("\nsquare wave (Enter 3)"); //square wave

printf("\nexponential signal (Enter 4)"); //exponential signal scanf("%d",&choice); i = 640; //640 samples of the signal will be generated A = 1.0; //maximum amplitude of the signals is 1 switch(choice) { case 1 : for(n = 0; n < i; n++) // cosine wave x[n] = A * cos( 2 * 3.1415927 * F * (n/Fs)); break; case 2 : for(n = 0; n < i; n++) // sine wave x[n] = A * sin( 2 * 3.1415927 * F * (n/Fs)); break; case 3 : k = 0; // square wave do { for( n = (k*Fs)/(2*F); n < ((k+1)*Fs)/(2*F); n++) { // positive half cycle of aquare wave x[n] = A; if(n>i)break; } for(n = ((k+1)*Fs)/(2*F); n < ((k+2)*Fs)/(2*F); n++) { // negative half cycle of aquare wave x[n] = -A; if(n>i) break; } k = k+2; // this count is modified for next cycle } while(n0;i--) inp_buffer[i]=inp_buffer[i-1]; out_buffer[0]=out_sample; if(recon==1) out_sample=reconstruction_filter(out_buffer,h); for(i=N-1;i>0;i--) out_buffer[i]=out_buffer[i-1]; l_output=out_sample; r_output=out_sample; /* Send a sample to the left channel */ while (!DSK6713_AIC23_write(hCodec, l_output)); /* Send a sample to the right channel */ while (!DSK6713_AIC23_write(hCodec, r_output)); } /* Close the codec */ DSK6713_AIC23_closeCodec(hCodec); } short antialiasing_filter(short *x,short *h) { short j,val; long int sum=0; for(j=0;j>15; val=(short)sum; return(val); }

short reconstruction_filter(short *x,short *h) { short j,val; long int sum=0; for(j=0;j>15; val=(short)sum; return(val); } Method of Experiment: For waveform generation:  Open Code Composer Studio, make sure the DSP kit is turned on.  Start a new project using .Project-new . pull down menu, save it in a separate directory(c:\ti\myprojects) with name waveform.pjt.  Create the source file i.e. program for waveform generation in C language.  Add the source files to the project using ‘Project—add files to project’ pull down menu.  Add the linker command file hello.cmd . (Path: c:\ti\tutorial\dsk6713\hello1\hello.cmd)  Add the run time support library file rts6700.lib (Path: c:\ti\c6000\cgtools\lib\rts6700.lib)  Compile the program using the .Project-compile. pull down menu or by clicking the shortcut icon on the left side of program window.  Build the program using the .Project-Build. pull down menu or by clicking the shortcut icon on the left side of program window.  Load the program(xyz.out) in program memory of DSP chip using the File-load program. pull down menu.  To View output graphically Select view ― graph ― time and frequency. For sampling of waveform:  Connect CRO to the Socket Provided for LINE OUT.  Connect a Signal Generator to the LINE IN Socket.  Switch on the Signal Generator with a sine wave of frequency 500 Hz. and Vpp=1.5v.  Now Switch on the DSK and Bring Up Code Composer Studio on the PC.  Create a new project with name sample.pjt.  From the File Menu → new → DSP/BIOS Configuration →select “dsk6713.cdb” and save it as “sample.cdb”  Add “sample.cdb” to the current project.  Add the given “codec.c” file to the current project which has the main function and calls all the other necessary routines.  Add the library file “dsk6713bsl.lib” to the current project

Path → “C:\CCStudio\C6000\dsk6713\lib\dsk6713bsl.lib”  Copy files “dsk6713.h” and “dsk6713_aic23.h” from C:\CCStudio\C6000\dsk6713\include and paste it in current project.  Build, Load and Run the program.  You can notice the input signal of 500 Hz. appearing on the CRO verifying the codec configuration.  You can also pass an audio input and hear the output signal through the speakers.  You can also vary the sampling frequency using the DSK6713_AIC23_setFreq Function in the “codec.c” file and repeat the above steps. Result:The output waveform can be seen on the monitor and sampling can be viewed on CRO after performing the experiment. Precautions: 1) Connect the wire properly 2) Power cable should be connected after the connection of data cable in the DSK board. Importance/Competencies: Students have now understood the basic concept of sampling and how any waveform is generated and sampled.

DEPTT. OF ELECTRONICS AND COMMUNICATION ENGG. 2008-09 Digital Signal Processing Lab (TEC-652) Experiment No.-2 Object: Quantization Equipment Used: 6713 DSK Board, IEEE 1284, compliant male- to-female cable, computer system, power supply, CRO, Function Generator, stereo jacks. Theory/Formula Used: With the adjective "digital" we indicate those systems that work on signals that are represented by numbers, with the (finite) precision that computing systems allow. Up to now we have considered discrete-time and discrete-space signals as if they were collections of infinite-precision numbers, or real numbers. Unfortunately, computers only allow to represent finite subsets of rational numbers. This means that our signals are subject to quantization. For our purposes, the most interesting quantization is the linear one, which is usually occurring in the process of conversion of an analog signal into the digital domain. If the memory word dedicated to storing a number is made of b bits, then the range of such number is discretized into 2b quantization levels. Any value that is found between two quantization levels can be approximated by truncation or rounding to the closest value. The Figure 1 shows an example of quantization with representation on 3 bits in two's complement.

Figure 1: Sampling and quantization of an analog signal The approximation introduced by quantization manifests itself as a noise, called quantization noise. Often, for the analysis of sound-processing circuits, such noise is assumed to be white and

de-correlated with the signal, but in reality it is perceptually tied to the signal itself, in such an extent that quantization can be perceived as an effect. Code: #include "quancfg.h" #include "E:\ccstudio_v3.1\c6000\dsk6713\include\dsk6713.h" #include "E:\ccstudio_v3.1\c6000\dsk6713\include\dsk6713_aic23.h" //extern signed int FILTER(signed int ); DSK6713_AIC23_Config config = { \ 0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume */ \ 0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume */\ 0x00d8, /* 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone volume */ \ 0x00d8, /* 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume */ \ 0x0011, /* 4 DSK6713_AIC23_ANAPATH Analog audio path control */ \ 0x0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control */ \ 0x0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control */ \ 0x0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface format */ \ 0x0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */ \ 0x0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */ \ }; /* * main() - Main code routine, initializes BSL and generates tone */ Uint32 l_input, r_input,l_output, r_output; void main() { DSK6713_AIC23_CodecHandle hCodec;

/* Initialize the board support library, must be called first */ DSK6713_init(); /* Start the codec */ hCodec = DSK6713_AIC23_openCodec(0, &config); DSK6713_AIC23_setFreq(hCodec, 3); while(1) { /* Read a sample to the left channel */

while (!DSK6713_AIC23_read(hCodec, &l_input)); /* Read a sample to the right channel */ while (!DSK6713_AIC23_read(hCodec, &r_input)); l_output= quan(l_input); r_output= l_output; /* Send a sample to the left channel */ while (!DSK6713_AIC23_write(hCodec, l_output)); /* Send a sample to the right channel */ while (!DSK6713_AIC23_write(hCodec, r_output)); } /* Close the codec */ DSK6713_AIC23_closeCodec(hCodec); } int quan(Uint32 sin_out) { float sin_pos[100],sin_neg[100],pos_out[100],neg_out[100]; float quant_out[100]; int i; for(i=0;i -1) { neg_out[i] = -1 ; } else if ( sin_neg[i] > -3) { neg_out[i] = -2; } else if ( sin_neg[i] > -5) { neg_out[i] = -4; } else if ( sin_neg[i] > -7) { neg_out[i] =-6; } else if ( sin_neg[i] > -9) { neg_out[i] = -8; } else if ( sin_neg[i] > -10) { neg_out[i] = -10; } else { neg_out[i] = 0; } quant_out[i] = pos_out[i] + neg_out[i]; } }

Method of Experiment:  Connect CRO to the Socket Provided for LINE OUT.  Connect a Signal Generator to the LINE IN Socket.  Switch on the Signal Generator with a sine wave of frequency 500 Hz. and Vpp=1.5v.  Now Switch on the DSK and Bring Up Code Composer Studio on the PC.  Create a new project with name quant.pjt.  From the File Menu → new → DSP/BIOS Configuration →select “dsk6713.cdb” and save it as “quant.cdb”  Add “quant.cdb” to the current project.  Add the given “codec.c” file to the current project which has the main function and calls all the other necessary routines.  Add the library file “dsk6713bsl.lib” to the current project Path → “C:\CCStudio\C6000\dsk6713\lib\dsk6713bsl.lib”  Copy files “dsk6713.h” and “dsk6713_aic23.h” from C:\CCStudio\C6000\dsk6713\include and paste it in current project.  Build, Load and Run the program.  You can notice the input signal of 500 Hz. appearing on the CRO verifying the codec configuration.  You can also pass an audio input and hear the output signal through the speakers.  You can also vary the sampling frequency using the DSK6713_AIC23_setFreq Function in the “codec.c” file and repeat the above steps. Result: Quantized waveform obtained on CRO. Precautions: 1) Connect the wire properly 2) Power cable should be connected after the connection of data cable in the DSK board. Importance/Competencies: Students have now understood the basic concept of quantization and its real application in digital signal processing.

DEPTT. OF ELECTRONICS AND COMMUNICATION ENGG. 2008-09 Digital Signal Processing Lab (TEC-652) Experiment No.-3 Object: PCM Encoding Equipment Used: 6713 DSK Board, IEEE 1284, compliant male- to-female cable, computer system, power supply, CRO, Function Generator, stereo jacks. Theory/Formula Used: Pulse-code modulation (PCM) is a digital representation of an analog signal where the magnitude of the signal is sampled regularly at uniform intervals, then quantized to a series of symbols in a digital (usually binary) code. Here is one example of sine wave shown in figure. The sine wave is sampled at regular intervals, For each sample, one of the available values is chosen by some algorithm in this case, the ceiling function is used. This produces a fully discrete representation of the input signal that can be easily encoded as digital data for storage or manipulation. For the sine wave example at right, we can verify that the quantized values at the sampling moments are 9, 11, 12, 13, 14, 14, 15, 15, 15, 14, etc. Encoding these values as binary numbers would result in the following set of nibbles: 1001, 1011, 1100, 1101, 1110, 1110, 1111, 1111, 1111, 1110, etc. These digital values could then be further processed or analyzed by a purpose-specific digital signal processor or general purpose CPU. There are many ways to implement a real device that performs this task. In real systems, such a device is commonly implemented on a single Integrated Development Environment generally referred to as an ADC (analog-todigital converter). These devices will produce on their output a binary representation of the input whenever they are triggered by a clock signal, generated by DSP processor means 225MHz.

Code: #include #include #include double quantize(double value,double delta) { int q = value/delta; if ((value-delta*q)
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF