EasyManua.ls Logo

Keysight 34972A - Page 266

Keysight 34972A
353 pages
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
266 Keysight 34970A/34972A User’s Guide
/* Wait for the instrument to complete its operations so waste time
and stay in the program in case there is an SRQ */
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); /* A negative srqFlag indicates scan is done */
/* 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"); /* Get all the readings */
viScanf(DataAcqu,"%,10lf",&volt); /* Put readings into an array */
for (index = 0;index<10;index++){ /* Print the readings */
printf("reading %d = %lf\n",index+1,volt[index]);
}
viClose (DataAcqu); /* Close the communication port */
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); /* Read status byte register and clear SRQ */
/* 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; /* Set flag to indicate this is an alarm */
viPrintf (DataAcqu,"STATUS:ALARM:EVENT?\n");/* Check and clear alarm */
viScanf(DataAcqu,"%s",&reply_string);
printf("alarm event; bit = %s\n",reply_string);
}
if ((statusByte==96)|(statusByte==98)){
srqFlag = -1; /* Set flag to indicate end of operation */
viPrintf (DataAcqu,"*ESR?\n"); /* Check and clear ESR bit */
viScanf(DataAcqu,"%s",&reply_string);
printf("Standard Event Register; bit %s\n",reply_string);
}
return VI_SUCCESS;
}

Table of Contents

Related product manuals