From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Setup GPIB controller on a PC and GPIB listner on PXI

Hello everybody, I was advised to repost  my original question  from the PXI board, to the current board to get more exposure. 

So here is the question again,

 

I have a PXI system on PXIe-1078 chassis, with PXIe-8821 controller (win7, 64bit).

The NI-VISA and NI-488.2 installed. 

I have to pick up text messages, or send/receive short text files using GPIB communication.

"Text Message" represents sort of a command to do stuff with my PXI system, then return results to the host.

The communication is synchronous - meaning, the "Host" sends a text command. The listener picks up, performs the action, and return result. Meanwhile, the "Host" waits for MY application to finish the job.

 

Now, I'm trying to recreate this scenario. Set up a "GPIB listener" on PXI controller, that picks up incoming GPIB  events, handles that event, then sends data back.

For now, I'm doing the following:

Simple CVI application to trigger GPIB events on my PC, and other application that picks up these events on PXI PC(the controller).

Here are some of my code details:

GPIB "events" Sending side:

setupFunction()

{

   glGPIBdevice = ibfind ("GPIB0");

   if(0<glGPIBdevice)
  {
     ibsic (glGPIBdevice);
     ibsre (glGPIBdevice, 1);
     ibdev (0, 0, NO_SAD, T30ms, 1, 0);

     found = 1;
   } 

}

sendFunction()

{

      status = ibwrt (glGPIBdevice, "HELLO", 5);

}

 

RECEIVING SIDE (PXI)

main()

{

        glHnGPIBDevice = ibfind ("gpib1");
       ibrsc (glHnGPIBDevice, 0);
       status = ibInstallCallback (1, EVENT, ProcessGPIBEvent, 0);

}

void CVICALLBACK ProcessGPIBEvent()
{
        MessagePopup ("GPIB Event", "GPIB event recieved.");
}

 

For now, that scheme doesn't work for me. 

Any ideas what do I miss?

 

Thanks for the support 🙂 

0 Kudos
Message 1 of 9
(4,257 Views)

Hi @ArtB83,

 

Are you seeing any errors?

0 Kudos
Message 2 of 9
(4,201 Views)

Sorry for a delay - I was a bit off the topic.

I'm trying to run NI example  from here on 2 PCs - using the GPIB-USB-HS+ .

When I'm running the example on 2 PCs, I'm configuring 1 PC with

ibrsc(noncontroller,0) 

the other

ibrsc(controller,1)

And nothing happens until I run the NI-MAX GPIB utilities, like GPIB analyzer, or GPIB scan for instruments. 

When I do so, I get a library error on a "controller" PC for ibwrt: (iberr==6[0x6])

And on the "noncotroller" I get the same library error, but for ibrd.

These are my results so far. Any ideas?

0 Kudos
Message 3 of 9
(4,159 Views)

Here are some more details - I've started using the GPIB Interactive Control from NIMAX. Please see the results in attached screenshots. 

I'm trying to reproduce same procedures in CVI : 

Here is the code of Controller side :

static int controller;
static int device;
static char buffer[100];
static int panelHandle;

int main ()
{
controller = ibfind ("GPIB0");

ibsic(controller);
ibsre(controller,1);
device = ibdev (0, 1, NO_SAD, T10s, 1, 0);
Delay(0.1);
while (1)
{
// If addressed to talk, send the response "I am a talker"
if ((ibsta&TACS)&&(!(ibsta&ATN)))
{
// Send data across the bus.
ibwrt (device, "I am a talker", strlen("I am a talker"));
ibconfig (device, IbcREADDR, 1);
return 0;
} // second if
}// while
} // main

 

nonController side:

static int noncontroller;
static char buffer[100];
static int panelHandle;

int main ()
{
// Open a session to the GPIB board
noncontroller = ibfind ("GPIB0");

// Release system control
ibrsc (noncontroller, 0);

// Change primary address from 0 to 1
ibpad (noncontroller, 1);

while (1)
{
// Wait until non-controller is listener and ATN line is dropped.
if ((ibsta&LACS)&&(!(ibsta&ATN)))
{
ibrd (noncontroller, buffer, 20); // Read data bytes
buffer[ibcnt] = '\n'; // Add linefeed and 0 to string.
buffer[ibcnt + 1] = 0;
MessagePopup ("GPIB communication event", buffer);

} // while
} // main

 

Still receive error num - 0x6 - according to GPIB manual it's a timeout error. My timeout is set to 10sec. 

My assumption is improper work with TACS, LACS control lines - need help with that, and with GPIB Bus monitoring utility. Where are TACS/LACS located on that utility?  

Thanks for the support 🙂

0 Kudos
Message 4 of 9
(4,154 Views)

Hi ArtB83,

 

It sais in the example guide that the ibdev command (on the controller) includes GPIB addresses and access board index for the non-controller. I see from your images that you entered the default values as described in the example. Are you sure those are correct for your non-controller GPIB board?

 

-Mitchell | NI

0 Kudos
Message 5 of 9
(4,135 Views)

Hi Mitchell,

Yes, I'm sure those are correct values. Tested on the interactive test panel.

For now, looks like I managed to succeed with my final goal. To send GPIB messages between 2 PCs.

Here is the code that I tested and it worked - again, the purpose is to send data back and forth between 2 PCs in pure synchronous way. I have attached 2 modified *.c files from examples that I found online and modified. They represent "listner" and "server" side. It was tested on 2 separate PCs. 

I still have some questions regarding TACS and LACS how do they exactly work? Which bit they represent in status word? How does readdresing work? In my current solution, it looks like there is no real control on TALKING and LISTENING cycles. I would glad to know the more elegant way to implement it. 

Download All
0 Kudos
Message 6 of 9
(4,126 Views)

Hey ArtB83,

 

Glad to hear you got your test system working, and on multiple machines! 

 

What are you referring to by TACS and LACS? I am unfamiliar with those acronyms.

0 Kudos
Message 7 of 9
(4,117 Views)

Hi mfaltin, thank you. 

TACS and LACS represent status bits in a status word that returned by "ibsta" macro.

"Based on the status bits set in Ibsta, the application takes whatever action
is appropriate. For example, the application could monitor the status bits TACS (Talker Active State) and LACS (Listener Active State) to determine when to send data to or receive data from the Controller." A quote from user manual.

I still can't figure out for sure how these control lines are functioning or how to operate them.

 

Regards.

0 Kudos
Message 8 of 9
(4,079 Views)

Thank you for clarifying what the acronyms are. Could you elaborate a bit on why you think there is no Listening or Talking cycles?

0 Kudos
Message 9 of 9
(4,040 Views)