HP 34970A User Manual page 326

Data acquisition / switch unit
Table of Contents

Advertisement

Chapter 7 Application Programs
Example Programs for C and C++
C / C++ Example: dac_out.c
/* dac_out.c
/***************************************************************************
* Required:
HP 34907A Multifunction Module in slot 200; VISA library
* This program uses the VISA library to communicate with the HP 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"
void main ()
{
ViSession defaultRM;
ViSession dac;
char reply_string [256];
char Visa_address[40];
double voltage;
/* Build the address required to open communication with HP-IB 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 HP 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
viPrintf (dac, "*RST\n");
voltage = 5;
viPrintf (dac, "SOURCE:VOLTAGE %f,(@205)\n",voltage);
/* Close communication session */
viClose (dac);
viClose (defaultRM);
}
/* Set HP-IB address for instrument */
/* Resource manager id */
/* Identifies instrument */
/* String returned from instrument */
/* VISA address sent to module */
/* Value of voltage sent to DAC */
%s\n\n", reply_string);
/* Set power-on condition */
/* Set variable to voltage setting */
*
*
*
*
/* Set output voltage */
7
329

Advertisement

Table of Contents
loading

Table of Contents