EasyManua.ls Logo

Agilent Technologies E4438C - Generating a CW Signal Using VISA and C

Agilent Technologies E4438C
208 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Programming Examples
GPIB Programming Examples
Chapter 2 47
Generating a CW Signal Using VISA and C
This example uses VISA library functions to control the signal generator. The signal
generator is set for a CW frequency of 500 kHz and a power level of
2.3 dBm. 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
visaex4.cpp.
//****************************************************************************************
// PROGRAM FILE NAME: visaex4.cpp
//
// PROGRAM DESCRIPTION: This example demonstrates query commands. The signal generator
// frequency and power level.
// The RF state of the signal generator is turn on and then the state is queried. The
// response will indicate that the RF state is on. The RF state is then turned off and
// queried. The response should indicate that the RF state is off. The query results are
// printed to the to the display window.
//
//****************************************************************************************
#include "StdAfx.h"
#include <visa.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
char rdBuffer [256]; // Declare variable to hold string data
int num; // Declare variable to hold integer data
viStatus=viOpenDefaultRM(&defaultRM); // Initialize VISA system
// 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);}
viPrintf(vi, "*RST\n"); // Reset the signal generator
viPrintf(vi, "FREQ 500 kHz\n"); // Set the source CW frequency for 500 kHz
viPrintf(vi, "FREQ:CW?\n"); // Query the CW frequency
viScanf(vi, "%t", rdBuffer); // Read signal generator response
printf("Source CW frequency is : %s\n", rdBuffer); // Print the frequency

Table of Contents

Other manuals for Agilent Technologies E4438C

Related product manuals