From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.



將單一GPIB卡設定為在兩個不同主要位置的收聽者。



硬體: GPIB>>Plug-in Controllers>>NB-GPIB-P/TNT, GPIB>>Plug-in Controllers>>SB-GPIB/TNT, GPIB>>Plug-in Controllers>>AT-GPIB/TNT (PnP), GPIB>>Plug-in Controllers>>AT-GPIB/TNT+, GPIB>>Plug-in Controllers>>NEC-GPIB/TNT, GPIB>>Plug-in Controllers>>GPIB-SPRC-B/TNT, GPIB>>Plug-in Controllers>>AT-GPIB/TNT, GPIB>>Plug-in Controllers>>NB-GPIB/TNT, GPIB>>Plug-in Controllers>>NEC-GPIB/TNT (PnP)

問題: GPIB卡通常只有一個主要位置,可當發聲者或收聽者。但我可以將單一GPIB卡設定為在兩個不同主要位置的收聽者嗎?

解答: 下面的程式,適用於NI 使用TNT4882晶片的GPIB卡。您可在型錄上找到晶片的資訊。範例程式修改了一些晶片內的設定,讓您可以將單一GPIB卡設定為在兩個不同主要位置的收聽者。

// Add appropriate include files. These are appropriate for LabWindows/CVI
#include <utility.h>
#include <gpib.h>
#include <stdio.h>

// Set Major and Minor Primary Addresses
#define PA1 0x01
#define PA2 0x04

void main ()
{
int board;
char buffer[100];
char byte;
int address;

board = ibfind ("GPIB0");
ibrsc (board, 0);

// Determine Address of GPIB board
// ibdiag will read some information from the table in memory
// bits 27 and 26 combine to make up the base address of I/O
// mapped boards (ie, not PCI boards which are memory mapped)
ibdiag(board, buffer, 100);
address = (((buffer[27] << 8) & 0xFF00) | (buffer[26] & 0x00FF));

outp (address + 0x8, 0x31); // ADR: Set Dual Addressing
outp (address + 0xC, PA1); // ARD1: Primary PA2
outp (address + 0xC, PA2 | 0x80); // ADR2: Secondary PA3

while (1) // Loop Forever
{
ibwait(board, 0); // Read Status

if ((ibsta & 0x04) && !(ibsta & 0x10)) // LACS + !ATN
{
byte = inp (address + 0x08); // Read Major/Minor #

if (byte & 0x1) // If bit 0 is set, it is the Minor #
printf("Primary Address %d is a Listener\n", PA2);
else
printf("Primary Address %d is a Listener\n", PA1);
} // if LACS + !ATN

if ((ibsta & 0x08) && !(ibsta & 0x10)) // TACS + !ATN
{
byte = inp (address + 0x08); // Read Major/Minor #

if (byte & 0x1)
printf("Primary Address %d is a Talker\n", PA2);
else
printf("Primary Address %d is a Talker\n", PA1);
} // if TACS + !ATN
} // while
} // main



相關連結: Listing of GPIB Controllers

附加檔案:


twoaddr.c - twoaddr.c


報告日期: 03/25/1998
最後更新: 05/19/2005
文件偏號: 17O7K8QA