Spectrogram with RTDX using MATLAB
#1

This version of project makes use of RTDX with MATLAB for transferring data from the DSK to the PC host. This section introduces configuration file(.CDB) file and RTDX with MATLAB.
This project uses source program spectrogram_rtdx_mtl.c that runs on the DSK which computes 256 point FFT and enables an RTDX output channel to write/send the resulting FFT data to the PC running MATLAB for finding the spectrogram. A total of N/2 (128 points )are sent. The (.CDB) configuration file is used to set interrupt INT11. From this configuration file select Input/Output  RTDX. Right click on properties and change the RTDX buffer size to 8200. Within CCS, select tools  RTDX  Configure to set the host buffer size to 2048(from 1024).
An input signal is read in blocks of 256 samples. Each block of data is then multiplied with a hamming window of length 256 points. The FFT of the windowed data is calculated and squared. Half of the resulting FFT of each block of 256 points is then transferred to the PC running MATLAB to find the specrtrogram.
Spectrogram_rtdx_mtl.c Time-Frequency analysis of signals Using RTDX-MATLAB

Code:
#include "dsk6713_aic23.h"                        //codec-DSK support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;            //set sampling rate
#include <rtdx.h>                                    //RTDX support file
#include <math.h>
#include "hamming.cof"                           //Hamming window coefficients
#define PTS 256                                     //# of points for FFT
#define PI 3.14159265358979
typedef struct {float real,imag;} COMPLEX;
void FFT(COMPLEX *Y, int n);                   //FFT prototype
float iobuffer[PTS],iobuffer1[PTS],a[PTS];                              //input and output buffer
float x1[PTS];                                    //intermediate buffer
short i;                                              //general purpose index variable
int j, k,l, curr_block = 0;                    //index variables
short buffercount = 0;                        //number of new samples in iobuffer
short flag = 0;                                   //set to 1 by ISR when iobuffer full
COMPLEX w[PTS];                                  //twiddle constants stored in w
COMPLEX samples[PTS];                            //primary working buffer
RTDX_CreateOutputChannel(ochan);                //create output channel C6x->PC

main()
{
for (i = 0 ; i<PTS ; i++)                      //set up twiddle constants in w
  {
   w[i].real = cos(2*PI*i/512.0);             //Re component of twiddle constants
   w[i].imag =-sin(2*PI*i/512.0);             //Im component of twiddle constants
  }
comm_intr();                                      //init DSK, codec, McBSP

while(!RTDX_isOutputEnabled(&ochan))      //wait for PC to enable RTDX
    puts("\n\n Waiting . . . ");           //while waiting
for(l=0;l<256;l++)
  a[l]=cos(2*3.14*1500*l/8000);
for(k=0;k<5000;k++)                                    //infinite loop
  {
   while (flag == 0) ;                        //wait until iobuffer is full
   flag = 0;                                  //reset flag
   for (i = 0 ; i < PTS ; i++)                //swap buffers
    { iobuffer1[i]=iobuffer[i]+a[i];
      samples[i].real=h[i]*iobuffer1[i];      //multiply by Hamming window coeffs
      iobuffer1[i] = x1[i];                //process frame to iobuffer
    }
   for (i = 0 ; i < PTS ; i++)
      samples[i].imag = 0.0;                //imag components = 0
   FFT(samples,PTS);                      //call C-coded FFT function
   for (i = 0 ; i < PTS ; i++)              //compute square of FFT magnitude
    {
         x1[i] = (samples[i].real*samples[i].real
                + samples[i].imag*samples[i].imag)/16;  //FFT data scaling
    }
   RTDX_write(&ochan, x1, sizeof(x1)/2); //send 128 samples to PC
  }                                        //end of infinite loop}                                         //end of main

interrupt void c_int11()                        //ISR
{
  output_sample((short)(iobuffer[buffercount]));   //out from iobuffer
  iobuffer[buffercount++]=(short)(input_sample()); //input to iobuffer
  if (buffercount >= PTS)                                   //if iobuffer full
  {
    buffercount = 0;                                           //reinit buffercount
    flag = 1;                                                   //reset flag
  }
}
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: rtdx 6713, rtdx matlab 2012 c6000, spectrogram matlab source code, rtdx matlab ccsusing wiper motor in pdf, write a matlab function that computes the spectrogram, rtdx debug, enable rtdx on paper battery,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  Spectrogram_RTDX.m For spectrogram plot using RTDX with MATLAB seminar class 0 1,714 06-05-2011, 04:22 PM
Last Post: seminar class
  USING MATLAB TO DETERMINE FILTER COEFFICIENTS: Using FIR1 Function on Matlab seminar class 0 2,289 06-05-2011, 03:58 PM
Last Post: seminar class

Forum Jump: