Agilent Technologies N5183A MXG User Manual
Page 249
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
239
Creating and Downloading Waveform Files
Programming Examples
// Create arrays to hold the I and Q data
int idata[NUMSAMPLES];
int qdata[NUMSAMPLES];
// save the number of sampes into numsamples
int numsamples = NUMSAMPLES;
// Fill the I and Q buffers with the sample data
for(int index=0; index { // Create the I and Q data for the number of waveform // points and Scale the data (20000 * ...) as a precentage // of the DAC full scale (-32768 to 32767). This example // scales to approximately 70% of full scale. idata[index]=23000 * sin((4*3.14*index)/numsamples); qdata[index]=23000 * cos((4*3.14*index)/numsamples); } // Print the I and Q values to a text file. View the data // to see if its correct and if needed, plot the data in a // spreadsheet to help spot any problems. FILE *outfile = fopen(ofile, “w”); if (outfile==NULL) perror (“Error opening file to write”); for(index=0; index { fprintf(outfile, “%d, %d\n”, idata[index], qdata[index]); } fclose(outfile); // Little endian order data, use the character array and for loop. // If big endian order, comment out this character array and for loop, // and use the next loop (Big Endian order data). // We need a buffer to interleave the I and Q data. // 4 bytes to account for 2 I bytes and 2 Q bytes. char iqbuffer[NUMSAMPLES*4]; // Interleave I and Q, and swap bytes from little // endian order to big endian order. for(index=0; index {