0% found this document useful (0 votes)
141 views

Hydra GPIB C Program

This C program code is designed to interface with and control a Fluke Hydra 2620A data acquisition system over IEEE-488 to measure and return various electrical values. It includes functions to initialize the connection, reset the device, and measure DC voltage, AC voltage, resistance, frequency, and temperature by sending commands over IEEE-488, receiving the measurement string values, and converting to floats.

Uploaded by

sure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views

Hydra GPIB C Program

This C program code is designed to interface with and control a Fluke Hydra 2620A data acquisition system over IEEE-488 to measure and return various electrical values. It includes functions to initialize the connection, reset the device, and measure DC voltage, AC voltage, resistance, frequency, and temperature by sending commands over IEEE-488, receiving the measurement string values, and converting to floats.

Uploaded by

sure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

/* Example C Program to interface to Fluke Hydra Data Acquisition System using I

EEE-488 port */
/*******************************************************************************
**************/
//--------------------------------------------------------------------------#include <stdio.h> /* standard I/O library functions */
#include <math.h> /* need math.h for atof function */
#include <conio.h>
#include <windows.h>
#include "decl-32.h"
#pragma hdrstop
//--------------------------------------------------------------------------#pragma argsused
int main(int argc, char* argv[])
{
int HydraAddress;
float DCVolts;
char DCVoltsChar[13];
HydraAddress = ibfind ("HYDRA"); /* find the HYDRA DAU */
ibwrt (HydraAddress, "*RST", 4); /* reset the HYDRA DAU */
ibwrt (HydraAddress,"FUNC 0,VDC,AUTO",15); /* Channel 0, Auto Range */
ibwrt (HydraAddress, "*TRG", 4); /* trigger voltage meas. */
ibwrt (HydraAddress, "LAST? 0", 7); /* prompt for last meas. */
ibrd (HydraAddress, DCVoltsChar, 13); /* voltage string */
DCVolts = atof(DCVoltsChar); /* string to floating pt.*/
printf("DC Voltage Measured = %f volts.", DCVolts);
while (!kbhit()) { }
return 0;
}
//--------------------------------------------------------------------------/*
This program is designed for the Borland C/C++ compiler and uses
borlandc_gpib-32.obj and decl-32.h
These obj and decl-32.h will not work in other compilers or in Visual Basic
*/
/*********************************************************************/
/*Header file Hydra.h used in the C code below is as follows:
int Clear_Hydra(void);
float MeasureDCvolts_Hydra(int);
float MeasureACvolts_Hydra(int);
float MeasureOhms_Hydra(int);
float MeasureFrequency_Hydra(int);
float MeasureTemperature_Hydra(int);
*/
/*********************************************************************/
/* The Hydra.C file is as below*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

<stdio.h> /* standard I/O library functions */


<io.h> /* contains the write function */
<math.h> /* contains the atof function */
<dos.h> /* contains the sleep function */
<fcntl.h> * contains access flags for 'open' */
<sys\stat.h> /* contains access modes for 'open' */
<time.h> /* contains all time functions */
<string.h> /* contains all str functions */
<stdlib.h> /* contains the exit() function */
"hydra.h" /* function declaration file */
<windows.h>
"decl-32.h" /* header declaration file */

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
int Clear_Hydra()
{
/* Subroutine to reset the FLUKE HYDRA 2620A Data Acquisition Unit. */
int hydra,i; /* variable declaration */
hydra = ibfind ("HYDRA"); /* find the HYDRA DAU/get handle */
ibwrt (hydra, "*RST", 4); /* reset the HYDRA DAU */
return hydra; /* return hydra handle */
}
float MeasureDCvolts_Hydra(int hydra)
{
/* Subroutine to measure DC volts on the front panel (Channel 0) of the */
/* FLUKE HYDRA 2620A Data Acqusition Unit. "hydra" must be sent down */
/* from function main. Value is returned as "volts". */
float volts; /* variable declarations */
char volts_char[13];
ibwrt (hydra,"FUNC 0,VDC,AUTO",15); /* Channel 0, Auto Range */
ibwrt (hydra, "*TRG", 4); /* trigger voltage meas. */
ibwrt (hydra, "LAST? 0", 7); /* prompt for last meas. */
ibrd (hydra, volts_char, 13); /* voltage string */
volts = atof (volts_char); /* string to floating pt. */
ibwrt (hydra, "*RST", 4); /* reset HYDRA */
/* Eliminate the reset to speed this up. */
/* You can also eliminate the FUNC statement once the Hydra is set. */
/* Use another name for the function if you change anything. */
return volts; /* return measured voltage */
}
float MeasureACvolts_Hydra(int hydra)
{
/* Subroutine to measure AC volts on the front panel (Channel 0) of the */
/* FLUKE HYDRA 2620A Data Acqusition Unit. "hydra" must be sent down */
/* from function main. Value is returned as "volts". */
float volts; /* variable declarations */
char volts_char[13];
ibwrt (hydra,"FUNC 0,VAC,AUTO",15); /* Channel 0, Auto Range */
ibwrt (hydra, "*TRG", 4); /* trigger voltage meas. */
ibwrt (hydra, "LAST? 0", 7); /* prompt for last meas. */
ibrd (hydra, volts_char, 13); /* voltage string */
volts = atof (volts_char); /* string to floating pt.*/
ibwrt (hydra, "*RST", 4); /* reset HYDRA */
return volts; /* return value */
}
float MeasureOhms_Hydra(int hydra)
{
/* Subroutine to measure two-wire-ohms resistance on the front panel */
/* (Channel 0) of the FLUKE HYDRA 2620A Data Acqusition Unit. "hydra"*/
/* must be sent down from function main. Value is returned as */
/* "resistance". */
float resistance; /* variable declarations */
char ohms_char[13];
ibwrt (hydra,"FUNC 0,OHMS,AUTO,2",18); /* Chan. 0, Auto, 2-Wire */
ibwrt (hydra, "*TRG", 4); /* trigger ohms meas. */
ibwrt (hydra, "LAST? 0", 7); /* prompt for last meas. */
ibrd (hydra, ohms_char, 13); /* ohms string */
resistance = atof (ohms_char); /* string to floating pt.*/
ibwrt (hydra, "*RST", 4); /* reset HYDRA */
return resistance; /* return value */
}
float MeasureFrequency_Hydra(int hydra)
{

/* Subroutine to measure frequency on the front panel (Channel 0) of the */


/* FLUKE HYDRA 2620A Data Acqusition Unit. Value is returned as */
/* "frequency". "hydra" must be sent down from function main. */
float frequency; /* variable declarations */
char freq_char[13];
ibwrt (hydra,"FUNC 0,FREQ,AUTO",16); /* Chan. 0, Auto Range */
ibwrt (hydra, "*TRG", 4); /* trigger freq. meas. */
ibwrt (hydra, "LAST? 0", 7); /* prompt for last meas. */
ibrd (hydra, freq_char, 13); /* frequency string */
frequency = atof (freq_char); /* string to floating pt.*/
ibwrt (hydra, "*RST", 4); /* reset HYDRA */
return frequency; /* return value */
}
float MeasureTemperature_Hydra(int hydra)
{
/* Subroutine to measure frequency on the front panel (Channel 1) of the */
/* FLUKE HYDRA 2620A Data Acqusition Unit. Value is returned as */
/* "temperature". "hydra" must be sent down from function main. */
float temperature; /* variable declarations */
char temp_char[13];
ibwrt (hydra,"FUNC 1,TEMP,K",13); /* Chan. 1, Type K Thermocouple */
ibwrt (hydra, "*TRG", 4); /* trigger TEMP meas. */
ibwrt (hydra, "LAST? 1", 7); /* prompt for last meas on Ch 1 */
ibrd (hydra, temp_char, 13); /* temperature string */
temperature = atof (temp_char); /* string to floating pt */
ibwrt (hydra, "*RST", 4); /* reset HYDRA */
/* Eliminate the reset to speed this up. */
/* You can also eliminate the FUNC statement once the Hydra is set. */
/* Use another name for the function if you change anything. */
return temperature; /* return measured value*/
}

You might also like