You are currently viewing Periodogram using TMS320C6745 DSP

Periodogram using TMS320C6745 DSP

Spread the love

Aim

To perform the Adaptive Filter of given sine continuous sequence in TMS320C6745 KIT.

Requirements

Theory

An adaptive filter is a filter that self-adjusts its transfer function according to an optimization algorithm driven by an error signal. Because of the complexity of the optimization algorithms, most adaptive filters are digital filters. By way of contrast, a non-adaptive filter has a static transfer function. Adaptive filters are required for some applications because some parameters of the desired processing operation (for instance, the locations of reflective surfaces in a reverberant space) are not known in advance. The adaptive filter uses feedback in the form of an error signal to refine its transfer function to match the changing parameters.

Generally speaking, the adaptive process involves the use of a cost function, which is a criterion for optimum performance of the filter, to feed an algorithm, which determines how to modify filter transfer function to minimize the cost on the next iteration.

As the power of digital signal processors has increased, adaptive filters have become much more common and are now routinely used in devices such as mobile phones and other communication devices, camcorders and digital cameras, and medical monitoring equipment.

Procedure for build a project on Periodogram using TMS320C6745 DSP

1. Open Code Composer Studio v4 .

2. In WorkSpace Launcher.

BROWSE → Select the project location and make one new folder, MAKE NEW FOLDER → Type the Workspace name, OK → OK.

3. FILE ⇒ NEW ⇒ CCS PROJECT

☞Project name: Type your project name.

☞Tick use default location. → NEXT

☞Project type C6000.

☞Tick Debug And Release. → NEXT → NEXT.

☞Output type: Executable.

☞Device Variant : generic – TMS320C6745.

☞Device Endianness : little

☞Code Generation Tools: TI v6.1.12.

☞Run time support library: automatic.

☞Target content: none. →FINISH

4.FILE ⇒ NEW ⇒ SOURCE FILE

☞Source file: Type your projectname.c( .c extension is must ).

☞Type the program.

FILE → SAVE.

5. Paste the following board library files in workspace location.

☞Common folder (contains header files)

☞Gel folder (contains gel file)

☞Library folder(contains library files)

6. Paste the Linker file in the project location.(linker file is available in cd)

Note: Those folders and linker file are availble at cd.

7. PROJECT ⇒ PROPERTIES ⇒ C/C++ BUILD → BASIC OPTION

☞Target processor version(–silicon version, -mv) : 6400+ ⇒OK.

☞IN C/C++ BUILD,  INCLUDE OPTIONS (Add dir to #include search path(–include_path,-I)) select this add icon add-icon and add the following three path by indivdually – “${Diag}../../common/header” – “${XDAIS_CG_ROOT}/packages/ti/xdais” – “${C6000_CSL_CG_ROOT}/include”

8. FILE ⇒ NEW ⇒ TARGET CONFIGURATION FILE

☞file name: projectname. ccxml (.ccxml extension is must)

☞Connection: Texas Instrument XDS100 v1 USB Emulator.

☞Device: TMS320C6745 KIT. (Tick the TMS320C6745)→ SAVE → TARTGET CONFIGURATION → C674X_0 → BROWSE, browse the workspace location, open the gel folder and select the GEL file. → OPEN → SAVE.

9. In C/C++ Project window, Right click the project ⇒ REBUILD PROJECT.

10. Connections

☞Connect the usb cable, PC to TMS320C6745 KIT.

☞Connect the 5v adapter.

☞Power on the kit.

11. TARGET ⇒ DEBUG ACTIVE PROJECT.

12. Use breakpoint at follownig lines at program,

☞for(count=0;count<nsamp;count++)41 line

☞original[count] = sin(teta)*1024; 45 line

☞orgnoise[count] = original[count] + noise[count]; 65 line

☞errorsig[count] = error; 83 line

13. TOOLS ⇒ GRAPH ⇒ SINGLE TIME (single time 0)

☞Acquisition Buffer Size – 128

☞Dsp Data Type – 32 bit Signed int

☞Start Address – original

☞Display Data Size – 128

14. Again, TOOLS ⇒ GRAPH ⇒ SINGLE TIME (single time 1)

☞Acquisition Buffer Size – 128

☞Dsp Data Type – 32 bit Signed int

☞Start Address – orgnoise

☞Display Data Size – 128

15. Again, TOOLS ⇒ GRAPH ⇒ SINGLE TIME (single time 2)

☞Acquisition Buffer Size – 128

☞Dsp Data Type – 32 bit Signed int

☞Start Address – errorsig

☞Display Data Size – 128

16. VIEW ⇒ BREAKPOINT

☞line 41 break point – remain halted

☞line 45 break point – Update View – (single time 0)

☞line 65 break point – Update View – (single time 1)

☞line 83 break point – Update View – (single time 2)

17. TARGET ⇒ RUN.

18. First view – console window

☞Then, single time 0 see here original signal output as graph

☞Then, single time 1 see here Org + noise signal output as graph

☞Then, single time 2 see here error signal output as graph

Program for Periodogram using TMS320C6745 DSP

#include 
#include 

#define 	PI		3.14
#define		BETA	0.1
#define		N		30
#define 	NS 		128 			//number of samples
	
short original[128],noise[128],orgnoise[128],adaptout[128],errorsig[128],coeff[128],noisecoeff[128],yn=0;
short orgsig=0,noisesig=0,orgnoisesig=0;
float error,Temp;

void main()
{
	const float sampf = 27000.0;		// Sampling frquency is fixed
	const int inpf = 1000; 
	const int inpn = 500;
	float sampt;
	double teta;

	int i=0,j=0,k=0,count,nsamp;
	sampt = 1/sampf;
	nsamp = 128;	
	
	printf("\n Original Signal Sampling Frequency is : %f",sampf);
	printf("\n Original Signal Sampling Time is :%f",sampt);
	printf("\n Original Signal Frequency is : %d",inpf);
	printf("\n Number of Sample in Original Signal : %d",nsamp);
	
	for(count=0;count<nsamp;count++)
	{
		original[count] = 0;
		noise[count] = 0;
		orgnoise[count] = 0;
		adaptout[count] = 0;
		errorsig[count] = 0;
		noisecoeff[count]=0;
		coeff[count] = 0;
	}
		
	for(count=0;count<nsamp;count++)
	{
		teta = (2 * PI * inpf * sampt * count);
		yn = sin(teta)*1024;
		original[count] = sin(teta)*1024;
		j++;
	}
	
	printf("\n");
	printf("\n Noise Signal Sampling Frequency is : %f",sampf);
	printf("\n Noise Signal Sampling Time is :%f",sampt);
	printf("\n Noise Signal Frequency is : %d",inpn);
	printf("\n Number of Sample in Noise Signal : %d",nsamp);
	
	j=0;
	for(count=0;count<nsamp;count++)
	{
		teta = (2 * PI * inpn * sampt * count);
		noise[j] = sin(teta) * 1024;
		j++;
	}
	
	

for(count=0;count<nsamp;count++)
	{
		orgnoise[count] = original[count] + noise[count];
	}
	
	
	for(count=0;count<nsamp;count++)
	{
		orgsig = original[count];
		noisesig = noise[count];
		orgnoisesig = orgnoise[count];
		noisecoeff[k] = noise[count];
		yn = 0;
		
		for(i=0;i<N;i++)
		{
			yn += (noisecoeff[i] * coeff[i]);			//output of adaptive filter
		}
		error = orgnoise[count] - yn;
		
		errorsig[count] = error;
		
		for(j=N-1;j>=0;j--)
		{
			coeff[j] = coeff[j] + (2 * BETA * error * noisecoeff[j]);			//update weights 
			noisecoeff[j+1] = noisecoeff[j];								//update delays
		}
				
	}
	
}

Result

Thus, the Adaptive Filter of given sine Continuous sequence was performed and the result is stored and displayed in graph.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.