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.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Do I need to initialize the GPIB board?

I'm having a great deal of difficulty connecting an instrument to our computer using a GPIB interface and the CVI driver supplied with the instrument, and I came up with a fairly obvious question, which I can't find the answer to.

In my program, do I need to initialize the GPIB board itself, or is this done for me when I call the OpenDev function to open a given device? The reason I ask is that my errors happen approximately 2/3 of the time, and I can't seem to find any real rhyme or reason to them.

thanks,

John
0 Kudos
Message 1 of 6
(3,294 Views)
John, try to use the ibdev() function if you don't.
Below is an example:

/****************************************************************************/
te_booleen MultiMetreInitialise (void)
/****************************************************************************/
{
int idMultiMetre;
DisableBreakOnLibraryErrors ();
idMultiMetre = ibdev (0, 22, NO_SAD, T3s, 1, 0);
return idMultiMetre;
EnableBreakOnLibraryErrors ();
}


Hope this helps,
Daniel


John Nordling wrote in message news:<506500000008000000F9880000-1042324653000@exchange.ni.com>...
> I'm having a great deal of difficulty connecting an instrument to our
> computer using a GPIB interface and the CVI driver supplied with the
> instrument, and I came up with a fairly obvious question, whi
ch I
> can't find the answer to.
>
> In my program, do I need to initialize the GPIB board itself, or is
> this done for me when I call the OpenDev function to open a given
> device? The reason I ask is that my errors happen approximately 2/3
> of the time, and I can't seem to find any real rhyme or reason to
> them.
>
> thanks,
>
> John
0 Kudos
Message 2 of 6
(3,294 Views)
The CVI driver should come with an example program that you can test communication with.

The GPIB board does not have to be initialized and Daniel is right, ibdev is the recommended method to obtain an instrument handle.

You may also want to test communication with IBIC. This webpage explains how to use IBIC.
Launching IBIC: Measurement and Automation explorer >> Tools >> NI-488.2 >> Interactive Control

Also, the errors themselves may indicate what you may be doing wrong. What errors have you been getting?
0 Kudos
Message 3 of 6
(3,294 Views)
Unfortunately, the instrument driver does not come with any program to test it.

I entered the code (as listed in the first post to this thread, with the obvious modifications) into my program in the proper place, and there doesn't seem to be any improvement.

The driver code uses the Opendev function to initialize communication with the instrument (the driver can be downloaded here if you'd like to look at it.)

When I step through, during the call to OpenDev, the following function is called, with the following arguments (supplied by NISpy): ibdev (0, 4095, 0(0x0), T10s(13), 1, 0x000)

I note that the prima
ry address field is 4095. I don't understand this, as I haven't really found anything that should lead to an incorrect PAD setting. Should I rewrite that portion of the driver to use the ibdev command instead of fooling around with OpenDev? It sets iberr to 4 when returning, I assume that's due to the incorrect PAD setting (or so it would seem).

I've attached my code and uir file to this message as well. I believe it's fairly well documented at this point.

I'll keep trying to figure out exactly what's going on, and try to update this as I figure out what else it could be.

There are other errors which occur farther down in the program (still within the initialization function of the driver file); however, I suspect the root of these problems is what I've discussed above.

thanks for all the help,

-John
Download All
0 Kudos
Message 4 of 6
(3,294 Views)
John,

We had probably the same GPIB problem as you have. The program worked
fine for a while, but then crashed at some point. It was on Windows 95
or 98. For versions above that, I didn't test them.

We finally found out this workaround:
You have to find the GPIB first, before opening the device. It has to
be the same GPIB device than the one that you will open afterwards.

Here is an example (almost the same I gave you before, but I just
found the workaround in my sources again. It was missing at first):

/****************************************************************************/
int MultiMetreInitialise (void)
/****************************************************************************/
{
int idMultiMetre;
DisableBreakOnLibraryErrors ();
idMultiMetre = ibfin
d ("GPIB0"); /* This line solves the GPIB bug */
if (idMultiMetre>=0)
MultiMetre = ibdev (0, 22, NO_SAD, T3s, 1, 0);
EnableBreakOnLibraryErrors ();
if (idMultiMetre < 0)
{
// error message here
}
return idMultiMetre;
}

Hope this will help you, and please tell it here if it does, for the
next ones having this problem.

Regards,

Daniel
0 Kudos
Message 5 of 6
(3,294 Views)
I tried putting in an ibfind call yesterday afternoon,
and it seems to have cleared up several of my
problems. The function I wrote to ensure that my
board is initialized is contained below:


void InitializeGPIB()
{
GPIBboard = ibfind ("gpib0");
ibpad (GPIBboard, 0);
ibrsc (GPIBboard, 1);
ibsic (GPIBboard);
ibsre (GPIBboard, 0);

}

Additionally, in the driver file, I replaced the call
to OpenDev with a call to ibpad, and that also seems
to help.

again, thanks for all the help.


-John
0 Kudos
Message 6 of 6
(3,294 Views)