두개의 다른 일차 주소에 Listener 로 작동하는 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 컨트롤러는 하나의 일차 주소를 가지고 talking 과 listening을 하는 것을 알고 있습니다. 그런데, 두개의 주소로 listen 하도록 하고 싶습니다. GPIB 보드가 두개의 다른 일차 주소에 Listener 로 작동하도록 할 수 있습니까?

솔루션: 아래의 예제 프로그램은 TNT4882 ASIC을 사용하는 내쇼날 인스트루먼트의 GPIB 보드에 해당합니다. 카탈로그에 보면 어떤 칩을 사용했는지 확인할 수 있습니다.(온라인 카탈로그 리스트를 보려면, 각 보드의 데이타시트를 보십시오.)

아래의 예제 프로그램은 TNT4882 칩의 레지스터를 수정하여, 두개의 다른 일차주소에 반응하도록 합니다. 그후에 루프 안에서 어느 주소가 talk 또는 listen에 설정되었는지 표시해줍니다.


// 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