Programming instructions
Programming Examples
GPIB Programming Examples
Chapter 2 49
Generating an Externally Applied AC-Coupled FM Signal Using VISA
and C
In this example, the VISA library is used to generate an ac-coupled FM signal at a carrier
frequency of 700 MHz, a power level of
−
2.5 dBm, and a deviation of 20 kHz. Before running
the program:
• Connect the output of a modulating signal source to the signal generator’s EXT 2 input
connector.
• Set the modulation signal source for the desired FM characteristics.
Launch Microsoft Visual C++ 6.0, add the required files, and enter the code into your .cpp
source file.
The following program example is available on the ESG Documentation CD-ROM as
visaex5.cpp.
//****************************************************************************************
// PROGRAM FILE NAME:visaex5.cpp
//
// PROGRAM DESCRIPTION:This example sets the signal generator FM source to External 2,
// coupling to AC, deviation to 20 kHZ, carrier frequency to 700 MHz and the power level
// to -2.5 dBm. The RF state is set to on.
//
//****************************************************************************************
#include <visa.h>
#include "StdAfx.h"
#include <iostream>
#include <stdlib.h>
#include <conio.h>
void main ()
{
ViSession defaultRM, vi; // Declares variables of type ViSession
// for instrument communication
ViStatus viStatus = 0; // Declares a variable of type ViStatus
// for GPIB verifications
// Initialize VISA session
viStatus=viOpenDefaultRM(&defaultRM);
// 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("Example program to set up the signal generator\n");