LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communication over TPC/IP without using VISA drivers?

Im trying to communicate with a RIGOL DG4162. 

Using the visa library and the instruments divers works and it's fairly simple.

 

Im trying to  connect without this resources, over a simple TCP connection and be able to send the SCPI commands to the instrument. I need to do this becouse we will later need to implement the communication in a siemens PLC (PLC to RIGOL communication) in wich i cannot install VISA drivers...

 

Im able to open the TCP connection with the instrument using port 5555 and the instrument IP adress, but writing the same commands wich work with the VISA driver, using the TCP Write function won't work. Any help would be apreciated.

 

0 Kudos
Message 1 of 13
(7,851 Views)

1. Why should the communcations in a PLC matter what you do in a Windows environment?  LabVIEW code does not port to a PLC.

2. My guess of what your issue is that you need to send a termination character to the instrument, typically an End Of Line (Carriage Return and a Line Feed, 0x0D and 0x0A)


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 13
(7,844 Views)

I know it has nothing to do with the PLC programming of the TCP protocol. But still, I want to test that it's posible to communicate without any drivers installed and verify wich messages I need to seend to the instrument.

 

I have tryed to send different messages with the TCP write function to enable the output channel 1 of my instrument but it does not recognize the command. I have tryed the end of line & sending the string length frist and nothing.

 

The connection over port 5555 opens just fine with the correct IP adress. So yhe, the problem is that without the VISA functions im not able to talk in a propper way with this thing.... 

0 Kudos
Message 3 of 13
(7,786 Views)
I would generally recommend using NI-VISA since it has cross-platform support and is fully supported by NI.

However...I have found times where I need a lightweight windows application and I have had success in using the .NET equivalents (e.g. TCPClient in System.Net.Sockets and also the Serial library) which is installed by default on Win 7/8/10 so doesn't require any additional NI drivers (but you still have to install the LV run-time so NI-VISA isn't much more than that once you create an installer).

Also note that 'End of Line' is platform dependent - normally for TCP/IP you need to send either \n or \r\n as the termination (using \ codes display).

Really - you need to do some research into the device you are communicating with - take a look at the documentation for the protocol and that should give you the information you need to communicate with it.

LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 13
(7,780 Views)

@AntonioNI wrote:

Im trying to communicate with a RIGOL DG4162. 

Using the visa library and the instruments divers works and it's fairly simple.

 

Im trying to  connect without this resources, over a simple TCP connection and be able to send the SCPI commands to the instrument. I need to do this becouse we will later need to implement the communication in a siemens PLC (PLC to RIGOL communication) in wich i cannot install VISA drivers...

 

Im able to open the TCP connection with the instrument using port 5555 and the instrument IP adress, but writing the same commands wich work with the VISA driver, using the TCP Write function won't work. Any help would be apreciated.

 


 

First off, do you realize that you are sending the same command ":OUTPUT1 ON;" every 100 msec in your loop until you hit the STOP button? That's probably not what you intended to do.

 

As Sam said, use a "\n" to terminate the command. Make sure you have the '\ Code Display' selected before you enter the \n in the text field (Right click the command text control and select). Also take his advice and research the communications protocol. After that, the easiest way for you to test out your TCP/IP raw socket is to use NI MAX. What I do to create a raw socket is:

 

* Open NI MAX; Right click "Devices and Interfaces" and create new
* Select VISA TCP/IP Resource, Click next
* Select "Manual Entry of Raw Socket", Click Next
* Enter your IP address and Port Number, and Validate
* In the next screen Highlight the resource you created and "Open VISA test Panel"
* Click "Input/Output" at the top of the window

 

Start typing in commands and see what happens. You also may want to turn on "NI I/O Trace" (link is just to the right of "Advanced") to get more detailed information of the VISA traffic.

 

Capture.JPG

IMHO not advised to send same command every 100 msec ad infinitum until STOP button is pressed.

0 Kudos
Message 5 of 13
(7,762 Views)

Thanks for your help. I have monitored the connections with MAX and the RAW socket does not work. However, the VXI-11 option does. I guess I need to implement the VXI-11 communication protocol with the TCP labview functions (in order to avoid using the VISA drivers). The point is that I will actually need to do the same with the AG_SEND/AG_RECIVE ethernet functions in the PLC in order to directly comunicate the PLC with the instrument, still no clue. 

0 Kudos
Message 6 of 13
(7,748 Views)

VXI-11 protocol is no rocket science at all. It is simply a combination of a few other semi standards like SCPI, GPIB-488.2 commands and adaptions to make them also work with other communication channels than GPIB and serial port.

 

GPIB 488.2 defines a number of commands such as *RST, *IDN? etc. which all instruments should understand.

The commands starting with *are all considered system commands, and a trailing ? indicates a query that should produce a response. Also commands can be terminated with a ; (semicolon) in order to send multiple commands in the same message string.

 

SCPI defines a structured command syntax :<system>:<subsystem>:<command>

 

And the VXI-11 standard adds to that things like that all command messages should be terminated with a standard termination character such as <line feed>, since serial port and network connections don't have special handshaking lines like the GPIB bus to indicate the <end of message>.

 

Aside from the comment that you will definitely not want to send a command repeatedly inside a loop, all that seems to be missing from your example is the termination character (assuming your command is valid for your instrument). So follow the advice about right clicking on your text constant and enabling "Enable backslash \ codes" and then appending \n (or \r) to the end of the string.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 13
(7,730 Views)

Ok, Im trying out again and I have found something interesting.

 

Im able to send the commands via TCP with labview but it does not execute them. However, the last command I seend via pressing "send" in the atached figure 2 is beeing correctly executed by the device whenever I send another comand (like the ID command) via pressing "write" or "query" with NI MAX (figure 3), and the instrument complains with a error message in the screen (figure 4).

 

It's like the command is correcly send and "stored" by the instrument but not executed until the NI MAX sends some kind of trigger that im missing... At least I know that the command can be send correctly via TCP write function.

Download All
0 Kudos
Message 8 of 13
(7,701 Views)

You still have a problem with your VI. Your "Send" control has a mechanical action of "switch when pressed". This means that it stays TRUE until you press it again. So, it will continuously send the same command every 100 ms.


I modified your VI to use an event structure. It will only send the command once when the "Send" control is pressed (mechanical action is latch when released). It will exit the loop when the stop control is pressed and then finally send the "Q" command.


Don't know if your TSP loop is the reason for your error, but it's not advisable to repeatedly send the same command every 100 ms to an instrument. It will probably fill up the buffer, lock up the machine because it is performing the instruction over and over again, or a combination of thereof.


As for the source of your problem, I can only speculate. Is the command syntax right? Is "2" a valid channel number? On some OLDER equipment, I had experienced some quirky behavior with using the ";". The ";" is mainly used to concatenate several commands together. The older instruments would NOT execute any command until ALL commands are sent over. Newer equipment will execute the command upon receiving the termination (\n). Try the command without the ";". Does the final "Q" command also need the \n termination? I have also seen other instruments buffer the commands until some type of "execute" command was sent. Can't think of anything else at the moment.

 

Send Command Once.png

 

0 Kudos
Message 9 of 13
(7,659 Views)

The boolean is set to latch when pressed, so thats not the issue. Im sending commands 1 by 1. Migth be the ; ... Will try again on monday :") 

0 Kudos
Message 10 of 13
(7,645 Views)