Hydra GPIB C Program
Hydra GPIB C Program
Hydra GPIB C Program
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
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
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)
{