HP 34970A User Manual page 328

Data acquisition / switch unit
Table of Contents

Advertisement

Chapter 7 Application Programs
Example Programs for C and C++
do{
/* Stay in loop until the srqFlag goes negative */
index = 1;
for (count = 0; count <45; count++)
{
index = 0;
printf(".");
}
printf(" srq flag = %d\n",srqFlag);
}
while (srqFlag>=0);
/* The instrument is done, so close the SRQ handler */
viDisableEvent(DataAcqu,VI_EVENT_SERVICE_REQ,VI_HNDLR);
viUninstallHandler (DataAcqu,VI_EVENT_SERVICE_REQ,SRQ_handler,(ViAddr)10);
viPrintf (DataAcqu,"FETCH?\n");
viScanf(DataAcqu,"%,10lf",&volt);
for (index = 0;index<10;index++){
printf("reading %d = %lf\n",index+1,volt[index]);
}
viClose (DataAcqu);
viClose (defaultRM);
}
/* This function will be called when the instrument interrupts the controller with
an SRQ for alarm and/or Operation Complete */
ViStatus _VI_FUNCH SRQ_handler(ViSession DataAcqu, ViEventType eventType,
ViEvent context,ViAddr userHdlr)
{
ViUInt16 statusByte;
viReadSTB(DataAcqu,&statusByte);
/* Bit 6 (64) indicates this SRQ is for our instrument, bit 1 (2) indicates
an alarm, and bit 5 (32) indicates the standard event register;
so alarm 64+2=66; OPC 64+32=96; both 64+32+2=98 */
if ((statusByte==66)|(statusByte==98)){
srqFlag = 1;
viPrintf (DataAcqu,"STATUS:ALARM:EVENT?\n");
viScanf(DataAcqu,"%s",&reply_string);
printf("alarm event; bit = %s\n",reply_string);
}
if ((statusByte==96)|(statusByte==98)){
srqFlag = -1;
viPrintf (DataAcqu,"*ESR?\n");
viScanf(DataAcqu,"%s",&reply_string);
printf("Standard Event Register; bit %s\n",reply_string);
}
return VI_SUCCESS;
}
/* A negative srqFlag indicates scan is done */
/* Get all the readings */
/* Put readings into an array */
/* Print the readings */
/* Close the communication port */
/* Read status byte register and clear SRQ */
/* Set flag to indicate this is an alarm */
/* Set flag to indicate end of operation */
/* Check and clear alarm */
/* Check and clear ESR bit */
7
331

Advertisement

Table of Contents
loading

Table of Contents