LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA vs GPIB

I've been yelled at numerous times on this forum for using GPIB functions rather than VISA functions.  So I would like to dedicate this thread to all the ways VISA is better than GPIB.  Why should I choose VISA functions?  What can they do that GPIB functions cannot?  Do all of the GPIB functions have an analogue VISA function?  I've been choosing to use the GPIB because to a new labview programmer, they seem simpler to use, or at least more intuitive in the beginning, but if the VISA functions really are better, I need to learn to use them.

0 Kudos
Message 1 of 17
(15,359 Views)

Almost all of the GPIB functions have an equivalent VISA function. For what you do 99% of the time, there is no difference. For example, the VISA Write is equivalent to a GPIB write except the VISA Write returns a VISA Reference Out that is much easier to use. You pass that to the next VISA function instead of wiring a GPIB address to all. I think it makes for cleaner wiring.

 

The main thing that VISA gives you is portability. VISA supports GPIB, Serial, Ethernet, USB, PXI, VXI, and PCI. So, with a single piece of code, you can support all of the interfaces and even GPIB controllers from different vendors.This has been enourmously helpful in many situations. For example:

 

1. A GPIB instrument in a production test rack goes bad. The spare is out for calibration. The line is down and you've got to get it back up RIGHT NOW. There's an identical instrument in the lab but it has a USB interface. Because the test program used VISA, the station was back up in a manner of minutes.

 

2.  I inherited a batch of GPIB controllers from another division. They purchased them from Agilent. I needed new test stations and instead of buying new controllers, used the Agilent ones. No changes were required in the existing test programs.

 

3. As a cost savings measure, I decided to switch to USB and Ethernet interfaces on the test equipment. No changes were required to any of the existing test programs.

 

4. A test program is using a pc's dedicated serial port. It went bad. I connected a USB_RS-232 adapter, changed the VISA alias for the com ports and was back up and running within minutes.

Message 2 of 17
(15,353 Views)

For GPIB users who are familiar with NI-488.2, the following table shows several common, but not all, NI-488.2 device-level function calls and the corresponding VISA operations. As you can see, the APIs are almost identical. The difference is that VISA is extensible to additional hardware interfaces. Therefore, if you are programming multiple devices that communicate over more than one bus type, it might be easier to use VISA for your entire system.

NI-VISA and NI-488.2 Functions and Operations

C NI-488.2 Device FunctionC VISA INSTR OperationLabVIEW NI-488.2 Device FunctionLabVIEW VISA INSTR Operation
ibdev viOpen <no equivalent>
VISA Open
ibonl viClose <no equivalent>
VISA Close
ibwrt viWrite
GPIB Write

VISA Write
ibrd viRead
GPIB Read

VISA Read
ibclr viClear
GPIB Clear

VISA Clear
ibtrg viAssertTrigger
GPIB Trigger

VISA Assert Trigger
ibrsp viReadSTB
GPIB Serial Poll

VISA Read STB
ibwait viWaitOnEvent
Wait for GPIB RQS
Wait for RQS
ibconfig viSetAttribute
GPIB Initialization

VISA Property Node

One difference in the event mechanism between NI-488.2 and VISA is worth noting. In VISA, you must always call viEnableEvent() prior to being allowed to receive events. While this was not the case with NI-488.2, this is required in VISA to avoid the race condition of trying to wait on events for which the hardware may not be enabled. Thus, you should enable the session for events not just immediately before calling viWaitOnEvent(), but before the device has even been triggered or configured to generate a service request event.

 

Its allways good to read the VISA help fileSmiley Wink


"Should be" isn't "Is" -Jay
Message 3 of 17
(15,346 Views)

Just to paraphrase what Dennis and Jeff have said, VISA is...    ummmm...  Smiley Indifferent  ...   ummm...   Accepted in more locations worldwide.  Smiley Happy

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 4 of 17
(15,336 Views)

It looks like with GPIB you can set the timeout for each write.  VISA has a timeout property node but that sets it for the for the session.  However, I content with the default timeouts unless I have specific timeout issues.

 

GPIB Write VI1.png

0 Kudos
Message 5 of 17
(15,316 Views)

@LarsUlrich wrote:

Why should I choose VISA functions?  What can they do that GPIB functions cannot?



RS232, TCP/IP, USB.....

=====================
LabVIEW 2012


0 Kudos
Message 6 of 17
(15,304 Views)

Having had issues similar to Dennis's #1 and #4 examples happen to me on more than one occasion I would have to say VISA is a lifesaver!

 

 Also you don't need to remember what device is on what GPIB address. Using VISA alias it's as easy as selecting "AC Source" or "DC Source" from the drop down menu. You can do VISA query's and find what device is where and pragmatically fill in all the proper VISA resources.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 17
(15,280 Views)

To add a few more advantages:

 

The VISA Resource Control allows you to pick from a list of available resources.

 

VISA supports aliases. You can assign logical names to the resources. Instead of trying to remember the GPIB address in a rack full of instruments, you can reference 'DMM', 'Scope', etc.

Message 8 of 17
(15,273 Views)

 


@CTF wrote:

It looks like with GPIB you can set the timeout for each write.  VISA has a timeout property node but that sets it for the for the session.  However, I content with the default timeouts unless I have specific timeout issues.

 

GPIB Write VI1.png


Not really an advantage.   Say you need to enable unaddressing for an old instrument- every GPIB function would need the MODE wired but, you can set it once in a VISA session during initialize-  making debugging that driver a lot easier!


"Should be" isn't "Is" -Jay
Message 9 of 17
(15,269 Views)

I agree with your statements. The one question I have is this: if you are using old HP devices that are connected through GPIB to some old PC, if you buy a new PC (Win. 10), how would you be able to connect the GPIB devices to the new PC without installing your own GPIB card and port on the PC?

0 Kudos
Message 10 of 17
(5,637 Views)