Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

converting GPIB C/C++ to control same device using USBTMC

I have some C/C++ code written to control a power analyzer using the GPIB C language interface (decl-32.h, gpib32.obj, gpib-32.dll) included with an NI GPIB-USB-HS adapter.   The usual functions such as Ibclr(), Ibrd(), Ibwrt() are used.
 
Now I have a newer analyzer that uses the same command set but also has a USBTMC interface.  I see that the NI-VISA runtime libraries can connect to USBTMC devices.  Is there a way to use my same code and C language interface to talk to the device across USB?
0 Kudos
Message 1 of 5
(4,933 Views)
I don't think there is anything you can do except change from the low level gpib functions to their VISA equivalents. This is one of the reasons that VISA has been the preferred api for the last several years.
0 Kudos
Message 2 of 5
(4,925 Views)
There wouldn't happen to be a guide for converting NI-488.2 to NI-VISA apps, would there?  I just used NI-488.2 interfaces because that's the first thing I found after installing the software that came with the USB-GPIB-HS adapter.
0 Kudos
Message 3 of 5
(4,919 Views)

There might be one but I'm not aware of anything specific. Maybe someone from NI will post with a detailed document but to start, you'll replace all of your ibwrt with a viWrite and the ibrd gets replaced with a viRead. It won't be as simple as just doing a single search and replace though. For example, with VISA, you use a VISA Resource Name instead of just a GPIB address. The VISA Resource Name syntax for a GPIB instrument is GPIB[board]::primary address[::secondary address][::INSTR].

I use LabVIEW these days and have had to go through the conversion process a number of times when I've gotten very old instrument drivers. I would suggest you first get the existing gpib instrument working with VISA and then see how it works with the USB version.

0 Kudos
Message 4 of 5
(4,915 Views)
Dennis,
 
Thanks for your help!  The good news is, all of the ib* code is hidden behind more generic read, write and init functions, so there are only a handful of actual ib*() calls isolated within 200 lines of code.  It should be pretty easy to convert.
I'll start poking around for docs on how to use viWrite et al, but even that simple keyword will make it much easier for me to find.
 
~Bingo
 
0 Kudos
Message 5 of 5
(4,904 Views)