Agilent Technologies N5183A MXG User Manual

Page 348

Advertising
background image

338

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

Creating and Downloading User-Data Files
User Flatness Correction Downloads Using C++ and VISA

if (status)//if any errors then display the error and exit the program

{

fprintf(stderr, "viOpen failed (%s)\n", instOpenString);

return -1;

}

printf("Example Program to Download User Flatness Corrections\n\n");

printf("Enter number of frequency and amplitude pairs: ");

int num = 0;

scanf("%d", &num);

if (num > 0)

{

int lenArray=num*2;//length of the pairsList[] array. This array

//will hold the frequency and amplitude arrays

char** pairsList = new char* [lenArray]; //pointer array

for (int n=0; n < lenArray; n++)//initialize the pairsList array

//pairsList[n]=0;

for (int i=0; i < num; i++)

{

char* nextFreq = new char[MAX_STRING_LENGTH+1]; //frequency array

char* nextPower = new char[MAX_STRING_LENGTH+1];//amplitude array

//enter frequency and amplitude pairs i.e 10ghz .1db

printf("Enter Freq %d: ", i+1);

scanf("%s", nextFreq);

printf("Enter Power %d: ",i+1);

scanf("%s", nextPower);

pairsList[2*i] = nextFreq;//frequency

pairsList[2*i+1]=nextPower;//power correction

}

unsigned char str[256];//buffer used to hold SCPI command

//initialize the signal generator's user flatness table

sprintf((char*)str,":corr:flat:pres\n"); //write to buffer

viWrite(vi, str,strlen((char*str),0); //write to PSG

char c = ',';//comma separator for SCPI command

for (int j=0; j< num; j++) //download pairs to the PSG

Advertising
This manual is related to the following products: