Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Sep 6, 2006


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

Parallel Polling with NI-488.2 Software

6 ratings | 1.83 out of 5
Print

Overview

Although parallel polling is not widely used, you can use it to obtain the status of multiple devices simultaneously. By analyzing a single byte of data, you can determine whether a device is present on the bus or requesting service. This document describes how to configure devices (instruments) for a parallel poll and how to perform a poll using both NI-488.2 routines and NI-488 functions. Using NI-488.2 routines makes setting up and executing parallel polls easy because you do not need extensive knowledge of the parallel polling messages. However, the NI-488 functions are more flexible in cases where the GPIB interface is a device and must configure itself for a parallel poll and set its own individual status bit (ist). This document also contains examples of parallel polling using NI-488.2 routines and NI-488 functions.

Theory of Parallel Polling

A Controller conducts a parallel poll to retrieve an individual status (ist) bit of a device. Because this status information is contained in a single bit, you can obtain up to eight distinct status bits in parallel from different devices during a single poll.

Each device that is to respond to the poll must be configured before the actual poll. In this configuration step, each device is assigned one of the eight GPIB data lines on which to respond, and is told the sense with which the data line should be asserted -- that is, whether an asserted (true) response represents an ist value of 1 or 0.

An advantage to parallel polling is that a single parallel poll can easily check up to eight individual devices at once corresponding to the number of data lines on the GPIB. In comparison, a serial poll is initiated by the device requesting service by asserting the SRQ line. If SRQ is asserted, it is the responsibility of the Controller to determine which device asserted the line by polling each device individually and checking for the RQS bit in the serial poll response byte (hex 40). Eight individual serial polls are required to check eight devices for their serial poll response byte. In parallel polling, it takes a single poll to check the same eight devices.

Implementing a Parallel Poll


Most parallel polls consist of two steps: a configuration step, which sets up the devices to participate in the poll, and the poll itself, which reads the data lines and reports the result.

You can use NI-488.2 routines or NI-488 functions to perform both the configuration step and the parallel poll. The NI-488 functions that perform these steps are ibppc and ibrpp. ibppc configures a single device to participate in parallel polling and ibrpp conducts a parallel poll after all devices have been configured. Some devices can configure themselves for a parallel poll. In those cases, the configuration step is not necessary. If your GPIB interface is parallel polled by another Controller, you can use a third function, ibist. ibist sets the individual status bit of the GPIB Controller to 0 or 1. The NI-488.2 routines to configure and conduct polls are PPollConfig, PPoll, and PpollUnconfig. PPollConfig and PpollUnconfig perform the parallel poll configuration and unconfiguration operations, respectively, and PPoll conducts the parallel poll.

Using NI-488.2 Routines


The following steps describe a parallel poll from beginning to end. Each step contains example code in QuickBASIC.
  1. The following example configures a device at address 3 for parallel polling using NI-488.2 routines. The device asserts data line 2 (DIO2) when its ist value is 1 and the device cannot configure itself to participate in parallel polling.
  2. REM $INCLUDE: 'qbdecl. bas'
    REM The following command clears the GPIB.
    REM board% is simply the index of the GPIB board.
    
    board% = 0
    CALL SendIFC( board%)
    
    REM The first step in a parallel poll is configuring
    REM the device for the poll.    The value of sense% is
    REM compared with the ist bit of the device and
    REM determines whether the data line is to be
    REM asserted or unasserted.
    
    address% = 3
    dataline% = 2
    sense% = 1
    CALL PPollConfig( board%, address%, dataline%, sense%)
  3. The following example conducts the parallel poll and checks the response for a certain value. In this case, because DIO2 is asserted by the device if ist = 1, check for hex 2 in the response to determine the value of ist.
  4. REM The second step performs the parallel poll and
    REM stores the response in response%.
    CALL PPoll(board%, response%)
    REM If response% contains hex 2, the ist bit
    REM of the device at that time is equal to 1. If
    REM it does not appear, the ist bit is equal to 0.
    REM Check the bit in the following statement.
    IF (response% AND &H2) <> 0 THEN
                  PRINT "The ist equals 1"
                  ELSE PRINT "The ist equals 0"
    END IF
  5. The following example unconfigures the devices for parallel polling.
  6. REM The third step disables parallel polling for
    REM device 3. Notice that the NOADDR constant
    REM (hex FFFF) must appear at the end of the array
    REM to signal the end of the address list. If
    REM NOADDR is the only value in the array, ALL
    REM devices are sent the parallel poll disable
    REM message.
    
    DIM addresslist%(1)
    addresslist%(0) = 3
    addresslist%(1) = NOADDR
    CALL PPollUnconfig(board%, addresslist%())

Using NI-488 Functions

Use ibppc to configure a parallel poll and ibrpp to perform the parallel poll. ibppc requires an 8-bit value to specify the data line number, the ist sense, and to determine whether or not the function will configure or unconfigure the device for the parallel poll. The bit pattern is as follows:

0 1 1 E S D2 D1 D0
    E is set to 1 to disable parallel polling or set to 0 if parallel polling is to be enabled for that particular device.

    S is set to 1 if the device is to assert the assigned data line when ist = 1 or set to 0 if the device is to assert the assigned data line when ist = 0. D2 through D0 determine the number of the assigned data line. The physical line number is the binary line number plus one. For example, DIO3 has a binary bit pattern of 010.

    The following steps describe a parallel poll from beginning to end. Each step contains example code in Microsoft C.
    1. The following example configures a device at address 3 for parallel polling using NI-488 functions. The device asserts DIO7 if its ist = 0.
    2. /* In this example, the ibdev command is used to
      open a generic device that has the desired
      characteristics. The device will have a primary
      address of 3, no secondary address, a timeout of 3
      seconds, assert EOI with the last byte of a write
      operation, and have EOS characters disabled.*/
                  #include "decl.h"
                  char ppr;
                  board = 0;
                  pad = 3;
                  sad = 1;
                  tmo = T3s;
                  eot = 1;
                  eos = 0;
                  dev = ibdev(board, pad, sad, tmo, eot, eos);
      /* The following call configures the device to
      respond to the poll on DIO7 and to assert the line
      in the case when its ist is 0. Pass the binary
      bit pattern, 0110 0110 or hex 66, to ibppc.*/
      ibppc(dev, 0x66);
    3. The following example performs the parallel poll and compares the response to hex 40, which corresponds to DIO7. If that bit is set, the ist of the device is 0.
    4. ibrpp(dev, &ppr);
      if (ppr & 0x40) printf("ist = 0\n");
    5. The following example unconfigures the device so that it no longer participates in parallel polling. Any value with the Parallel Poll Disable bit set (bit 4) in the bit pattern disables the configuration, so any value between hex 70 and 7E is usable.
    6. ibppc(dev, 0x70);
      Note: If the GPIB interface configures itself for a parallel poll, the ibppc function is also used. You pass the board index or a board unit description value as the first argument in the ibppc function. In addition, if the individual status bit (ist) of the interface needs to be changed, use the ibist function. In the following example, the GPIB interface is to configure itself to participate in a parallel poll. It asserts DIO5 when ist = 1 if a parallel poll is conducted.
      /*Board parallel poll configuration example*/
                  bdindex = 0;
                  ibppc(bdindex, 0x6C);
                  ibist(bdindex, 1);

      6 ratings | 1.83 out of 5
      Print

      Reader Comments | Submit a comment »

       

      Legal
      This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).