12-13-2016 08:48 AM
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.
12-13-2016 08:57 AM
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)
12-14-2016 03:47 AM
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....
12-14-2016 04:43 AM
12-14-2016 07:51 AM
@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.
IMHO not advised to send same command every 100 msec ad infinitum until STOP button is pressed.
12-14-2016 09:42 AM
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.
12-15-2016 03:31 AM
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.
12-16-2016 03:22 AM
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.
12-16-2016 07:40 AM
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.
12-16-2016 08:29 AM
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 :")