EasyManua.ls Logo

Keysight 34972A - C;C++ Example: Dac_Out.C

Keysight 34972A
353 pages
Print Icon
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...
6 Application Programs
264 Keysight 34970A/34972A User’s Guide
C/C++ Example: dac_out.c
Continued on next page
/* 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);
}

Table of Contents

Related product manuals