Digital Signal Processing Reference
In-Depth Information
blocks). A full description and the function of different blocks can be readily
obtained by highlighting each block.
CCS is invoked from LabVIEW to build the project and to load and run
the ( .out ) file (from the current directory) on the DSK. (See the CPU status
within CCS in Figure 9.23.) Input and output arrays of data, specified as 32-
bit integers ( cinput,coutput ), are transferred to the DSK through RTDX
(Figure 9.24).
3. Figure 9.25 shows the C source program rtdx_lv_filter.c that runs on the
DSK. It creates two input channels (for the sine wave data and the filter coef-
ficients generated by LabVIEW) and one output channel for the filtered
output data ( coutpu t). Inputs to the DSK are obtained using RTDX_read()
or RTDX_readNB() to read/input the sine data ( cinput ) and the coefficients
// rtdx_lv_filter.c RTDX with LABVIEW->filter design/plot DSK output
#include <rtdx.h> //RTDX support
#include "target.h" //init target
#define kBUFFER_SIZE 48 //RTDX read/write buffers
#define kTAPS 51
double gFIRHistory [kTAPS+1];
double gFIRCoefficients [kTAPS];
int input[kBUFFER_SIZE],output[kBUFFER_SIZE];
int gain;
double FIRFilter(double val,int nTaps,double* history,double* coefs);
int ProcessData (int* output, int* input, int gain);
RTDX_CreateInputChannel(cinput); //create RTDX input data channel
RTDX_CreateInputChannel(ccoefs); //input channel for coefficients
RTDX_CreateOutputChannel(coutput); //output channel DSK->PC(Labview)
void main()
{
int i;
TARGET_INITIALIZE(); //init target for RTDX
RTDX_enableInput(&cinput); //enable RTDX channels
RTDX_enableInput(&ccoefs);
//for input, coefficients, output
RTDX_enableOutput(&coutput);
gFIRCoefficients[0] = 1.0;
for (i = 1; i<kTAPS; i++)
gFIRCoefficients[i] = 0.0;
for (;;)
//infinite loop
{
while(!RTDX_read(&cinput,input,sizeof(input)));//wait for new buffer
if (!RTDX_channelBusy(&ccoefs)) //if new set of coefficients
RTDX_readNB(&ccoefs,&gFIRCoefficients,sizeof(gFIRCoefficients));
ProcessData (output, input, 1); //filtering on DSK
RTDX_write(&coutput,&output,szeof(output));//output from DSK->LABVIEW
}
}
FIGURE 9.25. C program running on the DSK that implements an FIR filter and illustrates
RTDX with LabVIEW ( rtdx_lv_filter.c ).
Search WWH ::




Custom Search