Agilent Technologies E8663B Portable Generator User Manual


 
240 Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Creating and Downloading Waveform Files
Programming Examples
int ivalue = idata[index];
int qvalue = qdata[index];
iqbuffer[index*4] = (ivalue >> 8) & 0xFF; // high byte of i
iqbuffer[index*4+1] = ivalue & 0xFF; // low byte of i
iqbuffer[index*4+2] = (qvalue >> 8) & 0xFF; // high byte of q
iqbuffer[index*4+3] = qvalue & 0xFF; // low byte of q
}
// Big Endian order data, uncomment the following lines of code.
// Interleave the I and Q data.
// short iqbuffer[NUMSAMPLES*2]; // Big endian order, uncomment this line
// for(index=0; index<numsamples; index++) // Big endian order, uncomment this line
// { // Big endian order, uncomment this line
// iqbuffer[index*2] = idata[index]; // Big endian order, uncomment this line
// iqbuffer[index*2+1] = qdata[index]; // Big endian order, uncomment this line
// } // Big endian order, uncomment this line
// Open a connection to write to the instrument
INST id=iopen(instOpenString);
if (!id)
{
fprintf(stderr, “iopen failed (%s)\n”, instOpenString);
return -1;
}
// Declare variables to hold portions of the SCPI command
int bytesToSend;
char s[20];
char cmd[200];
bytesToSend = numsamples*4; // calculate the number of bytes
sprintf(s, “%d”, bytesToSend); // create a string s with that number of bytes
// The SCPI command has four parts.
// Part 1 = :MEM:DATA “filename”,#
// Part 2 = length of Part 3 when written to a string
// Part 3 = length of the data in bytes. This is in s from above.
// Part 4 = the buffer of data
// Build parts 1, 2, and 3 for the I and Q data.
sprintf(cmd, “:MEM:DATA \”WFM1:FILE1\”, #%d%d”, strlen(s), bytesToSend);