User`s guide
93
Programming Your Instruments
Example Programs
#include <stdio.h>
#include <math.h>
// Specify the default address
#define DEFAULT_LOGICAL_ADDRESS OLESTR("GPIB0::10::INSTR")
#import "IviDriverTypeLib.dll" no_namespace
#import "IviFgenTypeLib.dll" no_namespace
#import "VisaCom.tlb" no_namespace
#import "Agilent33220.dll" no_namespace
void main()
{
BSTR TxtAddress = DEFAULT_LOGICAL_ADDRESS;
long Ncycles = 10; /* Define number of sinewave cycles */
double Damp_factor = -5; /* Define damping factor */
double pi = 3.14159; /* Define pi */
long i;
IAgilent33220Ptr Fgen;
CoInitialize(NULL);
Fgen.CreateInstance(__uuidof(Agilent33220));
Fgen->Initialize(TxtAddress, VARIANT_FALSE, VARIANT_TRUE, "");
Fgen->Utility->Reset();// Reset the function generator
Fgen->Status->Clear();// Clear errors and status registers
Fgen->System->TimeoutMilliseconds = 40000; // Set timeout to 40
seconds for long download strings
Fgen->Output->Frequency = 5000; // Output frequency is 5 kHz
Fgen->Output->Load = 50; // Output termination is 50 Ohms
Fgen->Output->Voltage->Amplitude = 5; // Output amplitude is 5 Vpp
// Compute waveform
fprintf(stderr, "Computing Waveform...\n");
// Create an array of data
SAFEARRAY *psa;
// Build a SafeArray of integer values.
SAFEARRAYBOUND bounds = {16000, 0};