62 Chapter 2
Programming Examples
GPIB Programming Examples
viClear(vi); // Clears the signal generator
viPrintf(vi, "*RST\n"); // Resets signal generator
// Print program header and information
printf("** End of Sweep Service Request **\n");
printf("\n");
printf("The signal generator will be set up for a step sweep mode
operation.\n");
printf("An ’*’ will be printed while the instrument is sweeping. The end of
\n");
printf("sweep will be indicated by an SRQ on the GPIB and the program will
end.\n");
printf("\n");
printf("Press Enter to continue\n");
printf("\n");
getch();
viPrintf(vi, "*CLS\n");// Clears signal generator status byte
viPrintf(vi, "STAT:OPER:NTR 8\n");// Sets the Operation Status Group // Negative
Transition Filter to indicate a // negative transition in Bit 3 (Sweeping)
// which will set a corresponding event in // the Operation Event Register. This occurs
// the end of a sweep.
viPrintf(vi, "STAT:OPER:PTR 0\n");// Sets the Operation Status Group // Positive
Transition Filter so that no
// positive transition on Bit 3 affects the // Operation Event Register. The positive //
transition occurs at the start of a sweep.
viPrintf(vi, "STAT:OPER:ENAB 8\n");// Enables Operation Status Event Bit 3 // to report
the event to Status Byte // Register Summary Bit 7.
viPrintf(vi, "*SRE 128\n");// Enables Status Byte Register Summary Bit 7
// The next line of code indicates the // function to call on an event
viStatus = viInstallHandler(vi, VI_EVENT_SERVICE_REQ, interupt, rdBuffer);
// The next line of code enables the // detection of an event
viStatus = viEnableEvent(vi, VI_EVENT_SERVICE_REQ, VI_HNDLR, VI_NULL);
viPrintf(vi, "FREQ:MODE LIST\n");// Sets frequency mode to list