
251
Chapter 6 Application Programs
Example Programs for C and C++
4
6
/* dac_out.c
/*************************************************************************************
* Required: 34907A Multifunction Module in slot 200; VISA library
*
* This program uses the VISA library to communicate with the 34970A.
*
* The program queries slot 200 and displays the response. It then resets
*
* the instrument and sends the value ’voltage’ to the DAC on channel 205.
*
**************************************************************************************/
#include <visa.h>
#include <stdio.h>
#include <string.h>
#define ADDR "9"
/* Set GPIB address for instrument */
void main ()
{
ViSession defaultRM;
/* Resource manager id */
ViSession dac;
/* Identifies instrument */
char reply_string [256];
/* String returned from instrument */
char Visa_address[40];
/* VISA address sent to module */
double voltage;
/* Value of voltage sent to DAC */
/* Build the address required to open communication with GPIB card.
The address format looks like this "GPIB0::9::INSTR". */
strcpy(Visa_address,"GPIB0::");
strcat(Visa_address, ADDR);
strcat(Visa_address, "::INSTR");
/* Open communication (session) with the 34970A */
viOpenDefaultRM (&defaultRM);
viOpen (defaultRM, Visa_address,VI_NULL,VI_NULL, &dac);
/* Query the module id in slot 200; Read response and print. */
viPrintf
(dac,
"SYST:CTYPE? 200\n"
);
viScanf (dac, "%s", &reply_string);
printf("Instrument identification string:\n %s\n\n", reply_string);
viPrintf (dac,
"*RST\n"
);
/* Set power-on condition */
voltage = 5;
/* Set variable to voltage setting */
viPrintf (dac,
"SOURCE:VOLTAGE %f,(@205)\n",voltage
); /* Set output voltage */
/* Close communication session */
viClose (dac);
viClose (defaultRM);
}
C/C++ Example:
dac_out.c
34970A Refresh UG.book Page 251 Wednesday, February 17, 2010 12:34 PM
Summary of Contents for 34970A
Page 16: ...16 34970A Refresh UG book Page 16 Wednesday February 17 2010 12 34 PM ...
Page 20: ...34970A Refresh UG book Page 20 Wednesday February 17 2010 12 34 PM ...
Page 21: ...1 1 Quick Start 34970A Refresh UG book Page 21 Wednesday February 17 2010 12 34 PM ...
Page 39: ...2 2 Front Panel Overview 34970A Refresh UG book Page 39 Wednesday February 17 2010 12 34 PM ...
Page 59: ...3 3 System Overview 34970A Refresh UG book Page 59 Wednesday February 17 2010 12 34 PM ...
Page 87: ...4 4 Features and Functions 34970A Refresh UG book Page 87 Wednesday February 17 2010 12 34 PM ...
Page 217: ...5 5 Error Messages 34970A Refresh UG book Page 217 Wednesday February 17 2010 12 34 PM ...
Page 241: ...6 6 Application Programs 34970A Refresh UG book Page 241 Wednesday February 17 2010 12 34 PM ...
Page 254: ...254 34970A Refresh UG book Page 254 Wednesday February 17 2010 12 34 PM ...
Page 255: ...7 7 Tutorial 34970A Refresh UG book Page 255 Wednesday February 17 2010 12 34 PM ...
Page 324: ...324 34970A Refresh UG book Page 324 Wednesday February 17 2010 12 34 PM ...