Chapter 2 33
Programming Examples
GPIB Programming Examples
int sig; // Declares a device descriptor variable
sig = ibdev(0, 19, 0, 13, 1, 0); // Aquires a device descriptor
ibclr(sig); // Sends device clear message to signal generator
ibwrt(sig, "*RST", 4); // Places the signal generator into a defined state
// Print data to the output window
cout << "The signal generator should now be in REMOTE. The remote indicator"<<endl;
cout <<"annunciator R should appear on the signal generator display"<<endl;
return 0;
}
Interface Check using VISA and C
This program uses VISA library functions and the C language to communicate with the signal generator.
The program verifies that the GPIB connections and interface are functional. Launch Microsoft Visual C++
6.0, add the required files, and enter the following code into your .cpp source file.
The following program example is available on the PSG Documentation CD-ROM as visaex1.cpp.
//****************************************************************************************
// PROGRAM NAME:visaex1.cpp
//
// PROGRAM DESCRIPTION:This example program verifies that the GPIB connections and
// and interface are functional.
// Turn signal generator power off then on and then run the progam
//
//****************************************************************************************
#include <visa.h>
#include <stdio.h>
#include "StdAfx.h"
#include <stdlib.h>