Programming instructions

Programming Examples
GPIB Programming Examples
Chapter 2 57
Reading the Data Questionable Status Register Using VISA and C
In this example, the signal generator’s data questionable status register is read. You will be
asked to set up the signal generator for error generating conditions. The data questionable
status register will be read and the program will notify the user of the error condition that the
setup caused. Follow the user prompts presented when the program runs. 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 ESG Documentation CD-ROM as
visaex9.cpp.
//***************************************************************************************
// PROGRAM NAME: visaex9.cpp
//
// PROGRAM DESCRIPTION:In this example, the data questionable status register is read.
// The data questionable status register is enabled to read an unleveled condition.
// The signal generator is then set up for an unleveled condition and the data
// questionable status register read. The results are then displayed to the user.
// The status questionable register is then setup to monitor a modulation error condition.
// The signal generator is set up for a modulation error condition and the data
// questionable status register is read.
// The results are displayed to the active window.
//
//***************************************************************************************
#include <visa.h>
#include "StdAfx.h"
#include <iostream>
#include <conio.h>
void main ()
{
ViSession defaultRM, vi; // Declares a variables of type ViSession
// for instrument communication
ViStatus viStatus = 0; // Declares a variable of type ViStatus
// for GPIB verifications
int num=0; // Declares a variable for switch statements
char rdBuffer[256]={0}; // Declare a variable for response data
viStatus=viOpenDefaultRM(&defaultRM); // Initialize VISA session
// Open session to GPIB device at address 19
viStatus=viOpen(defaultRM, "GPIB::19::INSTR", VI_NULL, VI_NULL, &vi);
if(viStatus){ // If problems, then prompt user
printf("Could not open ViSession!\n");
printf("Check instruments and connections\n");
printf("\n");
exit(0);}
printf("\n");