Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP-IP instrument communication with VISA (LV 7.0)

Hello,
I have just re-written a software which was using the "old" generic interface VIs for RS-232 and GPIB to the "new" VIs using VISA. This was REAL work, because many of the old input controls did not match the input controls requested by the VISA VIs and there were no example VIs available showing how to use the old inputs with the new VIs (for compatibility reasons, I could not change the input controls). Now I would like to add TCP-IP as another interface choice. Unfortunately, the NI LabVIEW example "TCP Communicator" uses the generic VIs "TCP Open Connection" and "TCP Read" instead of the VISA functions. I have not found any VISA example about this! Can you help me please? In my software, I would like to offer all available options as input controls (like port and address, the user should be able to input the address in dot notation or as the host name), open a VISA session with this configuration, clear the interface and send a string. The device that I want to control has its own command language, no standard. Can you please send me a sample VI (which can also be written in LV 7.1 if the functions are available in 7.0 also) showing how to implement this?
Thanks in advance,
best regards,
Gabs
0 Kudos
Message 1 of 8
(5,135 Views)
The beauty of VISA is that once you've written a driver, you've got one that will handle all interfaces with little to no code modification. It is usually the serial interface that requires the modification. GPIB, Ethernet, and USB instruments all pretty much work the same. It is the VISA Resource Name that allows the user to select an instrument at either a serial port, GPIB address, or an IP address. If you look at a driver certified for multiple interfaces such as the AG33120, you'll see that inside the Initialize VI, the interface type is determined and only if it's serial, is anything different done. With a VISA Resource Name control, all the user has to do is click on the arrow on the right side of the control to see a list of all available instruments. VISA itself then takes care of the details of the different interface protocols.
Message 2 of 8
(5,134 Views)
Hello Dennis,
thanks for your answer. Unfortunately, I cannot simply offer a VISA resource name control on my panel. What I am doing right now is changing an existing software driver from the generic VIs to the VISA versions plus adding TCP-IP as an additional interface choice. My problem is, that for RS-232 for instance, with the generic VIs there were more options available than with the VISA VIs. I understand that this makes VISA easier to use than the old generic VIs, but I cannot change my "old" input controls on my VI panel for compatibiltiy reasons. NI already helped me to solve this for RS-232. With GPIB, I still have the problem that there was an input called "GPIB mode" before which doesn't exist anymore in VISA. This "mode" control exists on my software panel and I also cannot remove it for compatibility reasons. But how can I connect it with the VISA VIs? Leaving the "mode" input unwired is propably not a clean solution, right? Can you or somebody else help me here?

In the same way as I have offered interface options for RS-232 and GPIB as input controls on the panel, I would like to have a "host address" and "Port" control on this panel for TCP-IP communication. This is why I am looking for a sample VI showing how to implement this.

Best regards,
Gabs
0 Kudos
Message 3 of 8
(5,127 Views)
I'm having a little trouble understanding the problem. What modes existed for the old serial that don't exist for serial with VISA? What did selecting GPIB mode actually do and what can't VISA do? If all you want to do is have a user specify an IP address, then this can be easily converted to a VISA Resource Name with either the Concantanate String or Format Into String function. The Open VISA function accepts strings as inputs. If GPIB is selected with an address of 12, then the resource name becomes "GPIB0::12:INSTR". If Ethernet is selected and an IP of 192.168.100.1 is specified, the resource name is "TCPIP::192.168.100.1::INSTR". I'm thinking that all of your instrument communication can be handled by a single subVI and still keep your user interface the same. Maybe if you posted your VI, I or someone else could look at exactly what you're trying to accomplish.
0 Kudos
Message 4 of 8
(5,124 Views)
I'm having a little trouble understanding the problem. What modes existed for the old serial that don't exist for serial with VISA? What did selecting GPIB mode actually do and what can't VISA do? If all you want to do is have a user specify an IP address, then this can be easily converted to a VISA Resource Name with either the Concantanate String or Format Into String function. The Open VISA function accepts strings as inputs. If GPIB is selected with an address of 12, then the resource name becomes "GPIB0::12:INSTR". If Ethernet is selected and an IP of 192.168.100.1 is specified, the resource name is "TCPIP::192.168.100.1::INSTR". I'm thinking that all of your instrument communication can be handled by a single subVI and still keep your user interface the same. Maybe if you posted your VI, I or someone else could look at exactly what you're trying to accomplish.
Message 5 of 8
(5,123 Views)
Hello Dennis,
with RS-232, the two VIs that I was talking about were "VISA Configure Serial Port.vi" and "Serial Port Init.vi". If you compare these two VIs (which ship with LabVIEW) you'll see that both VIs are supposed to do the same thing, acutally it was my understanding that the VISA Configure Serial Port.vi is supposed to replace the Serial Port Init.vi. Unfortunately, the input controls that I needed for the former one are not compatible with the second one. I was able to solve that problem for all input controls except the flow control input, but someone from NI helped me with this.

With TCP-IP, from your reply it will propably be the best to use the string input that you mentioned and convert the input controls to the correct resource name string. Thanks for that remark.

With GPIB, my problem still is the "mode" which is an input for "GPIB Send.vi". This control told LabVIEW to add a LF or EOI or nothing to the message to send. You find this VI and the "GPIB mode" help under LabVIEWs old "generic" I/O VIs. There is no such input for the corresponding VISA function, however. What do I need to do with my old "mode" input?

Regards,
Gabs
0 Kudos
Message 6 of 8
(5,119 Views)
You can probably ignore the mode if you're using newer instruments. One of the IEEE-488 standards (don't remember which version or date) required that all new instruments would use EOI. There is the ability to turn it on or off with a VISA Property node though. Drop a property node on the diagram. Right click and select Properties>Message Based Settings>Send End End Enable. If you need CR or LF at the end of a command, the constants are on the string palette and you could just concantanate these to the command based on the user settings.
Message 7 of 8
(5,114 Views)

Dennis

I'm using a driver supplied by Lambda for a   GEN-600-5.5-LAN-3P20 . I'm going back a year ( this has been idle for that long) so bear w me.  When I start adding the controls in the vi ( left click> create>control) the visa control that gets created is GPIB.  I'm using TCP/IP to talk to the power supply (PS) .  In MAX I created an alias for the PS and specified the address ( 192.168....).  Manufact is now starting to use my code and the driver is coming back w a broken wire...dotted line.  When I right click on the visa control that I created a year ago I notice it has "select visa class>I/O session>Instru" instead of "select visa class>I/O session>TCP/IP Instr".  I noticed in a post on this page you said once a driver is created VISA takes care of the rest for you.  Is the selection of "instru" in the select visa class ok as long as I specified an alias in MAX??  Or should I still chg the visa class to TCP/IP.  This will mean chging all the subvi's in the Lambda supplied driver because they are set for GPIB and hence...I think.. the broken line..

 

Thanks

0 Kudos
Message 8 of 8
(4,234 Views)