Agilent Technologies N5183A MXG User Manual

Page 245

Advertising
background image

Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide

235

Creating and Downloading Waveform Files

Programming Examples

// signal generator

char *filename = “C:\\Temp\\PSGTestFile”;

FILE *stream = NULL;

stream = fopen(filename, “w+b”);// Open the file

if (stream==NULL) perror (“Cannot Open File”);

int numwritten = fwrite( (void *)waveform, sizeof( short ), points*2, stream );

fclose(stream);// Close the file

// 3.) Load the internal Arb format file *********************************

// This process is just the reverse of saving the waveform

// Read in waveform as unsigned short integers.

// Swap the bytes as necessary

// Normalize between +-1

// De-interleave the I/Q Data

// Open the file and load the internal format data

stream = fopen(filename, “r+b”);// Open the file

if (stream==NULL) perror (“Cannot Open File”);

int numread = fread( (void *)waveform, sizeof( short ), points*2, stream );

fclose(stream);// Close the file

// If on a PC swap the bytes back to Little Endian

if( strcmp(computer,”PCWIN”) == 0 )

{

pChar = (char *)&waveform[0]; // Character pointer to short int data

for( i=0; i<2*points; i++ )

{

buf = *pChar;

*pChar = *(pChar+1);

*(pChar+1) = buf;

pChar+= 2;

}

}

// Normalize De-Interleave the IQ data

double IwaveIn[POINTS];

double QwaveIn[POINTS];

for( i=0; i<points; i++)

{

IwaveIn[i] = waveform[2*i] / 32767.0;

QwaveIn[i] = waveform[2*i+1] / 32767.0;

}

return 0;

}

Advertising
This manual is related to the following products: