LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i use the TCP/IP to control the instrument via VISA resource?

I Need to control the instrument use TCP/IP via VISA resource, I have created the VISA resource => "TCPIP0:: 192.168.1.1:: inst0:: INSTR" in the NI MAX, And try to send the SCPI command "*IDN?\n" to instrument, The instrument has responded normally.

log1.png

 

 

But, when I send the same command to the instrument under LabVIEW, use VISA resource, The Error message are shows up after execute the VISA Write component.

log2.png

 

I tried to search the other similar talk, such as below link:
LINK

But I still haven't solved the problem.
Attach file is my VI, Have anyone can help me?
Thanks

0 Kudos
Message 1 of 35
(10,879 Views)

You should attach the end characters to the sting you send.

 

Note the \r\n in max? They are not there in LabVIEW. Make sure to set the string to "'\' Code Display" (right click on the constant, Visible Items>Display Style, then click the new thingy on the left of the constant).

 

You're telling VISA to not use end characters. I'd enable them, and set them to \n (10). That way, when you read, the reads are automatically truncated on \r\n. Very convenient, and the only alternative is to poll data, concatenate that data, and check for \r\n manually. Not sure why you'd want to do that.

 

IIRC (it's been a while), the end characters are not attached to the output strings, so you need to attach them to the strings you're sending. Won't hurt to check, or maybe someone else can confirm\contradict that. EDIT: Probably set the Send End... Boolean to true, to send it.

 

 

 

 

0 Kudos
Message 2 of 35
(10,850 Views)

You are getting an "Insufficient location information" error.  I am assuming all of this was on the same computer, so the instrument should still be there.  So first thing I would do is make sure your VISA Test Panel is closed (it might be holding the resource and blocking LabVIEW from getting access to it).  After that, try to ping the device (open the Windows command prompt an type "ping 192.168.1.1") and verify you are getting a response.


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 3 of 35
(10,839 Views)

Also, the Wait Until Next ms Multiple seems out of place here.You probably mend to use a Wait (ms)?

 

It's not needed at all, and undesirable. You'll probably just slow down the program without need. The VISA read has a time out, simply make it larger when needed. The end character will help to make it work.

 

If the wait is removed, the error case structure can be removed. All nodes in it are skipped when there is an error in.

 

It's OK in a test VI, but usually you want to put the init, write\read and close in three different VI's. Then open once, write\read unil the program quits, then close once.

0 Kudos
Message 4 of 35
(10,834 Views)

I would leave the timeout at its default value, or at least make it longer than 200 ms.  Some commands may take longer to process than that and cause a timeout error.

 

Edit: Maybe that's 2000 ms but the lightbulb tool tip got cut off, making it look like 200.  2 seconds (and lengthening it temporarily when expecting a command that takes time to process) is probably good enough without becoming a nuisance if there actually was a timeout.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 35
(10,830 Views)

Thanks for your reply!

 

I had set the string to "'\' Code Display" and set them to \n (10),
Enable the "Send End" in the Instr Property node. After the change above setting,
The error message still shows up after sending the command to the instrument.

This error message shows up after VISA writes, But, I have removed the wait component.

forUSNI.png

0 Kudos
Message 6 of 35
(10,784 Views)

I had closed the "NI MAX Check panel"
And Check the the Windows command prompt an type "ping 192.168.1.1
The instrument has response.
Then i execute this VI, the Error message is still shows up.

Even I restart the computer, Then Open this VI, execute it directly
(No open any other tool that communication this instrument IP)
The error message is still showing up.

0 Kudos
Message 7 of 35
(10,782 Views)

I tried to change the timeout parameter to (200, 500, 1000, 2000), The Error message is still shows up.

0 Kudos
Message 8 of 35
(10,780 Views)

The error doesn't seem to be related with any timeout or end characters.

 

Have you closed MAX\Test panel? You probably can't connect two clients.

 

That TCIP\IP connection probably needs a (the correct) port. It's now using the default port. IIRC, you can specify it in the resource string or in the function.

 


@WIILE wrote:

 

I had set the string to "'\' Code Display" and set them to \n (10),
Enable the "Send End" in the Instr Property node. After the change above setting,
The error message still shows up after sending the command to the instrument.

This error message shows up after VISA writes, But, I have removed the wait component.

forUSNI.png


If you set the send end termination character to true, you shouldn't have to put it in the constant. Both do the same, so it's eiter\or not both. You probably also want to set the incoming end character.

 

Also, that error case is now completely redundant. Both send and receive will skip all their functionality if there is an error in, so the case doesn't add anything. Doesn't hurt much either, but "less is more"...

0 Kudos
Message 9 of 35
(10,772 Views)

wiebe@CARYA


I had closed MAX\Test panel, Then execute this VI

Even I restart the computer,
Then Open this VI, execute it directly, The Error message is still shows up.
(Before this operation, Not open any other tool that communication this instrument IP)

 

How can I use the other port except the default port?
I create this source in the NI MAX and tested successfully,
In the LabVIEW, The VISA source name component has auto found this source,
I use the same source in the LabVIEW...
So this source should be correct and workable?
Am I missing something?

 

And.... What is the "IIRC"?

 

Thanks

 
已寫:

The error doesn't seem to be related with any timeout or end characters.

 

Have you closed MAX\Test panel? You probably can't connect two clients.

 

That TCIP\IP connection probably needs a (the correct) port. It's now using the default port. IIRC, you can specify it in the resource string or in the function.

 


@WIILE wrote:

 

I had set the string to "'\' Code Display" and set them to \n (10),
Enable the "Send End" in the Instr Property node. After the change above setting,
The error message still shows up after sending the command to the instrument.

This error message shows up after VISA writes, But, I have removed the wait component.

forUSNI.png


If you set the send end termination character to true, you shouldn't have to put it in the constant. Both do the same, so it's eiter\or not both. You probably also want to set the incoming end character.

 

Also, that error case is now completely redundant. Both send and receive will skip all their functionality if there is an error in, so the case doesn't add anything. Doesn't hurt much either, but "less is more"...


 

0 Kudos
Message 10 of 35
(10,768 Views)