Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

GPIB Slave with NI488.2

Hi,

 

we use a NI 488.2 card as a slave (Listener and Talker), with the dll and our own code.

The problem is, that it is not working reliable. We tried it as described in the NI-488.2 User Manual,

Section 8-12, the code does the following:

 

Init:

                (*Pibonl)(mGPIBDesc, 1);    /* Set Board online */
                (*Pibeot)(mGPIBDesc, 1);    /* Auto assert EOI Line at the end of write ops */
                (*Pibrsc)(mGPIBDesc, 0);    /* Release System Control (Configure the GPIB board to NOT be a system controller) */                                
                (*Pibconfig)(mGPIBDesc, IbcSAD, GPIBSAddress);
                (*Pibconfig)(mGPIBDesc, IbcPAD, GPIBPAddress);

Loop:

     while(1)    {

        aStatus = (*Pibwait)(mGPIBDesc, 0xC0BF);

        if (aStatus & ERR) {
            LOG_E("GPIB Error!")
            printf("ibstat: %x, iberr: %x\n", aStatus, *Piberr);
        } else if (aStatus & LACS) {
            (*Pibrd)(mGPIBDesc, recbuff, RECBUFFSIZE);
            if ((*Pibsta) & ERR) {
                LOG_E("GPIB Read Error!")
                printf("ibstat: %x, iberr: %x\n", *Pibsta, *Piberr);                
            }
            recbuff[(*Pibcntl)] = 0;
            printf("Received: %s\n", recbuff);
        } else if (aStatus & TACS) {
            (*Pibwrt)(mGPIBDesc, sendbuff, SENDBLOCKSIZE);
            if ((*Pibsta) & ERR) {
                LOG_E("GPIB Write Error!")
                printf("ibstat: %x, iberr: %x\n", *Pibsta, *Piberr);                
            }                        
        }
        } else {
            printf("IBWAIT: ibsta: %x ++++++++++++++++++++++++++++++++++++++++++++\n", aStatus);                        
        }
   }

 

It works as long as the device gets only talk request, as soon as there are listen requests, too, there

are timeouts, because the code calls ibwrt again and again since the TACS bit seems to stay at 1

even after a successful write. It times out since there is no longer a listener active.

 

What we need is some listen and talk stuff (*IDN?) and reading out strings of our device acting as a

slave. Is it possible to get this working reliable with a NI-488.2 card so it fulfills IEEE 488 and does not

only work sometimes

If not, is there a PCI Card available that can do this reliable?

 

I have read 

http://forums.ni.com/ni/board/message?board.id=140&message.id=9749

and found there a solution with asyncronous calls, but how can one stop a pending ibwrta?

Is this a reliable working and full standards compliant way?

 

Is example source code available from NI for a working slave?

 

Thanks in advance.

 

Best regards,

 

Steffen

 

0 Kudos
Message 1 of 9
(8,740 Views)

Hi Steffen,

 

I will try and help sort out the questions you have concerning GPIBl. First let me ask you a few questions to have a better understanding of the context.

 

- Which OS are you running?

- Which dev. environment and version? 

- Which hardware card are you using?

- Which version of the 488.2 driver? 

 

Regards, 

0 Kudos
Message 2 of 9
(8,713 Views)

Hello Joseph,

 

> - Which OS are you running?

 

Microsoft Windows XP

 

> - Which dev. environment and version? 

 

 gcc 3.4.5 (mingw special)

 It is C++ Code that loads the NI gpib-32.dll and then calls functions of this dll.

 

> - Which hardware card are you using?

 

PCI - GPIB, NI-488.2 for Windows Vista/XP/2000

 

> - Which version of the 488.2 driver? 

 

 Version 2.5

 

 

Best regards,

 

Steffen

 

0 Kudos
Message 3 of 9
(8,707 Views)

Hi Steffen,

 

thanks for the information.

 

I cannot at the moment give you any specific information that you do not already know.

I will be able to talk with some colleagues beginning next week who will be more able to provide concrete answers to your questions.

 

Unless someone else has something to add in between, I'm afraid that I don't have more information until then.

 

Regards, 

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

Hi Steffen,

 

I've looked into the matter a little further, and all of our hardware can be a talker/listener by deactivating the controller part and should work according to specs.

 

We unfortunately don't have any example slave code for our GPIB drivers.

 

The function to abort an ibwrta or ibrda is ibstop. That should do the trick in your case.

 

Best regards, 

 

 

0 Kudos
Message 5 of 9
(8,624 Views)

Hello,

 

Here is some example GPIB instrument code that acts as an instrument. 

 

I hope this helps,

Steven T.

0 Kudos
Message 6 of 9
(8,598 Views)

I'm trying to write some similar code, but I'm using the .NET driver, which I think I'm having issues with.

 

I don't ever see the CurrentStatus lines get cleared for talker and listener. So when I get addressed as a listener I go read the bytes, and I see IOComplete get set, but then the CurrentStatus still has a flag enabled for Listener. If I ignore listening when IOComplete is set (which it still is), I can successfully be addressed as a Talker and transfer bytes. However, IOComplete stays set. I also need to be able to read successive commands in without being addressed as a Talker in between.

 

Has anyone had luck with using the NI .NET driver for being a slave (non-CIC)? There isn't very good documentation for it, and I'm just going off this C++ example here. Any help would be much appreciated. Sorry, I don't have the code open in front of me so it's possible I've gotten the nomenclature wrong. I've interfaced with the NI driver for CIC stuff, and I wrote a big interface for the TNT4882 chip on an embedded card, but there was a BytesAvailable register for that so it was easy to know when to read. The .NET Read() interface is blocking, so that doesn't work so well.

 

Thanks. 

0 Kudos
Message 7 of 9
(7,881 Views)

Hello,

Do you have a solution? I have the similar problem.

I am using C#, VS2008 and NI-GPIB-USB-HS.

 

I found some posts which are related to this

http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/Net-GPI-Device-ReadByteArray-method-beeing-ca...

 

http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/ibrd-does-not-terminate/m-p/351615/highlight/...

 

Thanks, 

0 Kudos
Message 8 of 9
(6,866 Views)

Hello Steven,

 

How do you run this noncic.zip application?

I saw noncic.exe from debug folder and also what c++ compiler did you used here?

 

Thanks,

Raymond

0 Kudos
Message 9 of 9
(3,917 Views)