LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read from two instruments via GPIB?

Hi, I am new to Labview. Now my job at hand is to read two values spontaneously from two GPIB instruments. I make use of VISA (open-...-close) to read from the two respectively. Do I need to close one visa channel for one instrument in order to read the data from the other instrument? and it seems very complicated to connect "Visa Session" and "error" all over my program, is it a pure GPIB read, write better, since it is simple, just an icon representing different command?
0 Kudos
Message 1 of 4
(2,871 Views)
No, you can have multiple sessions open at the same time. What version of LabVIEW are you using? Some older versions require the open...close structure for GPIB, but the newer ones do not.

The GPIB read and write, skips all the VISA stuff. When you do a VISA read (or write), the software sends the information to the VISA driver, where the name of the instrument is looked up in a table, the command is changed to a GPIB format and sent to the GPIB driver. Direct GPIB read and write skip the middle-man. Direct GPIB read and write are faster, but for most cases, people won't see the difference.

Rob
Message 2 of 4
(2,871 Views)
Hi There,
You will need to set (on the instruments themselves) different GPIB address.
With VISA you can have multiple devices open simultaneously, so you can make
your program parallel.
Use a "sequence" control box to synchronize the read operation of both
instruments (put the request/read commands for both instruments inside the
same (single frame) sequence.

BTW if you are calling the instruments for data more than once, and you open
and close the visa sessions to the instruments outside the For/While loop
then - don't forget to use "shift-register"s in your loops for the inst.
handle and error in/out or u run into lots of difficult to trace problems...

good luck,
Peter


"cpu" wrote in message
news:506500000008000000EB380000-1007855
737000@exchange.ni.com...
> Hi, I am new to Labview. Now my job at hand is to read two values
> spontaneously from two GPIB instruments. I make use of VISA
> (open-...-close) to read from the two respectively. Do I need to close
> one visa channel for one instrument in order to read the data from the
> other instrument? and it seems very complicated to connect "Visa
> Session" and "error" all over my program, is it a pure GPIB read,
> write better, since it is simple, just an icon representing different
> command?
0 Kudos
Message 3 of 4
(2,871 Views)
VISA Instrument. Use VISA READ functions to read your instruments or using the (VISA) Read driver for the instrument. If your instrument drivers use the GPIB nomenclature you may want to consider either converting to VISA format or trying to obtain a newer driver from the vendor or NI website. Each instrument must have a unigue GPIB address. Follow connectivity guidelines for GPIB cables. No more than three cables connected on any instrument and keep the cables as short as possible, especially if you are using relatively large number of instruments.

The reason you carry a single VISA session through the VI is to reduce demands on memory. Each open VISA session takes up memory quickly. In particular true if they are not closed. This is a 'memory leak' condition that will eventually cause you to run out of memory and lock up either the application or the PC, or both. You would want to set up a 'While loop' (wire a F Boolean constant to the exit so it will execute only once) with a Case structure(..0,1..) using shift register to return VISA session to TypeCast(4X)function to determine validity of seesion, non-zero refnum returns indicate an active session. If the refnum returned is Zero, you should wire the inside of that case(..0) using the left shift register to a Visa Close and then use a new VISA Open. Note: in that case 0 do not wire the error to the VISA Close, but to the VISA Open. This will prevent a VISA Close error the first time you run the VI. As long as you follow the above rule for opening and closing, you do not have to individually open or close sessions for a given instrument. The VISA session refnum is the same for all instruments connected. By using a loop sequencer to check the validity of the refnum you will increase the throughput of your VI's.

The same is true for the error wire. You should use a left to right programming technique where possible in the VI flow. Construct sub VI's to handle each step of your overall application. You are then able to connect the Sub-VI's in the main VI using the error wires to predict the flow of the program. It helps to keep your instructions from executing at unexpected times and also allows for better debug tracing. This is just programming technique you will learn as you go.

Also, VISA is a standard for instrument connectivity. If you choose you may use the older GPIB commands, but additional functionality is then prohibted. VISA is the common format used by Alliance Instrument Vendors for setting up instrument drivers today. This allows for easier implemntation of various vendors instruments as well as open I/O connectivity to other standards, i.e serial,etc.

Hope that helps. See the example below, requires LabVIEW 6.0 or higher.
TRaper
Message 4 of 4
(2,871 Views)