Technical data

260 Agilent Signal Generators Programming Guide
Creating and Downloading Waveform Files
Programming Examples
for (int i=0; i<SAMPLES; ++i)
{
iqData[2*i] = AMPLITUDE * sin(two_pi*i/(float)SAMPLES);
iqData[2*i+1] = AMPLITUDE * cos(two_pi*i/(float)SAMPLES);
}
// make sure bytes are in the order MSB(most significant byte) first. (PC only).
char* cptr = (char*)iqData;// cast the integer values to characters
for (int i=0; i<(4*SAMPLES); i+=2)// 4*SAMPLES
{
char temp = cptr[i];// swap LSB and MSB bytes
cptr[i]=cptr[i+1];
cptr[i+1]=temp;
}
// now write the buffer to a file
out_stream.write((char*)iqData, 4*SAMPLES);
return 0;
}
Creating and Downloading I/Q Data—Big and Little Endian Order
On the documentation CD, this programming example’s name is “CreateDwnLd_Data_c++.txt.”
This C++ programming example (compiled using Microsoft Visual C++ 6.0) performs the following
functions:
error checking
data creation
data scaling
text file creation for viewing and debugging data
byte swapping and interleaving for little endian order data
interleaving for big endian order data
data saving to an array (data block)
data block download to the signal generator
// This C++ program is an example of creating and scaling
// I and Q data, and then downloading the data into the
// signal generator as an interleaved I/Q file.
// This example uses a sine and cosine wave as the I/Q
// data.
//
// Include the standard headers for SICL programming
#include <sicl.h>