User`s guide

95
Programming Your Instruments
Example Programs
Example: Simple Sine Waveform (Visual C++ and VXIpnp)
This example program is intended for use with Microsoft Visual C++ 6.0
and requires VISA revision 2.0 and the Agilent Technologies 33220A VXIpnp
instrument driver installed. This program shows how to download an
arbitrary waveform using binary data. The program generates a damped
sine wave using 16,000 points.
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "ag33250a.h"
#define CHECK(func)\
do {\
ViStatus _s = (func);\
if (_s < 0)\
{\
fprintf(stderr, "Error: %s returned %d\n", #func, _s);\
exit(0);\
}\
} while (0)
/* Specify the default address */
#define DEFAULT_LOGICAL_ADDRESS "GPIB0::10::INSTR"
void main()
{
ViSession vi;
ViRsrc TxtAddress = DEFAULT_LOGICAL_ADDRESS;
ViInt16 Waveform[16000];
long Ncycles = 10; /* Define number of sinewave cycles */
double Damp_factor = -5; /* Define damping factor */
double pi = 3.14159; /* Define pi */
long i;
ViInt16 reply;
CHECK(ag33250a_init(TxtAddress, 0, 0, &vi));
/* This funcion initializes the instrument */
CHECK(ag33250a_reset(vi));/* Reset the function generator */
CHECK(ag33250a_dcl(vi));/* Clear errors and status registers */
CHECK(ag33250a_formBord(vi, ag33250a_ARB_WAV_FORM_BOR_SWAP));