National Instruments NI-488.2 Benutzerhandbuch

Seite von 135
Chapter 7
NI-488.2 Programming Techniques
© National Instruments Corporation
7-19
Parallel Polling with Multi-Device NI-488.2 Calls
Complete the following steps to implement parallel polling the using 
multi-device NI-488.2 calls. Each step contains example code.
1.
Configure the device for parallel polling using the 
PPollConfig
 
call, 
unless the device can configure itself for parallel polling. The 
following example configures a device at address 3 to assert data line 5 
(DIO5) when its 
ist
 value is 1.
#include "decl-32.h"
char response;
Addr4882_t AddressList[2];
/* The following command clears the GPIB. */
SendIFC(0);
/* The value of sense is compared with the ist bit
of the device and determines whether the data 
line is asserted.*/
PPollConfig(0,3,5,1);
2.
Conduct the parallel poll using 
PPoll
,
 store the response, and check 
the response for a certain value. In the following example, because 
DIO5 is asserted by the device if 
ist
 is 1, the program checks bit 4 
(hex 10) in the response to determine the value of 
ist
.
PPoll(0, &response);
/* If response has bit 4 (hex 10) set, the ist bit
of the device at that time is equal to 1. If 
it does not appear, the ist bit is equal to 0. 
Check the bit in the following statement. */
if (response & 0x10) {
printf("The ist equals 1.\n");
}
else {
printf("The ist equals 0.\n");
}
3.
Unconfigure the device for parallel polling using 
PPollUnconfig
, as 
shown in the following example. In this example, the 
NOADDR
 constant 
must appear at the end of the array to signal the end of the address list. 
If 
NOADDR
 is the only value in the array, all devices receive the parallel 
poll disable message.
AddressList[0] = 3;
AddressList[1] = NOADDR;
PPollUnconfig(0, AddressList);