From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Command works in NI Max but not LabView

Solved!
Go to solution

I have been trying to send a command to my instrument via LabView but it's not working as it is only working on the NI Max Visa Test Panel, What could I be doing wrong? I have attached pictures of the command I am trying to send, my block diagram, and the error I keep getting.

Download All
0 Kudos
Message 1 of 15
(1,432 Views)

You clearly send different strings, but there is no way to really tell without seeing the actual vi. We can't even tell what the display style is for your string diagram constant.

 

Please attach your VI. Thanks.

0 Kudos
Message 2 of 15
(1,420 Views)

You could have wrong settings, check the settings in NI MAX and use the same in your VI (maybe use "Visa configure serial port" function instead of "Visa Open" to specify the settings)

Possibly you have the wrong termination character specified.

0 Kudos
Message 3 of 15
(1,402 Views)

@altenbach wrote:

You clearly send different strings, but there is no way to really tell without seeing the actual vi. We can't even tell what the display style is for your string diagram constant.


It's actually worse. If the automatic wire probe shows backslashes then that is because there are backslashes in the sting, not escaped characters. The probe NEVER shows "\s" for a space character!

 

To the OP: Go in the front panel, right click on the string control and select "'\' Codes Display" in the popup menu. Then revalidate the string you see and make sure to change the double \ into single ones.

 

But I have to support Christian's request! If you want support for a problem, you need to post the VI itself, not a picture of it. It is often impossible to see the specific settings on LabVIEW objects in a picture. While this was possible to diagnose, it is a roundabout way of doing so, as we have to deduce things around a few corners to actually find the problem.

Rolf Kalbermatter
My Blog
Message 4 of 15
(1,394 Views)
  1. In NI-Max you are sending your command "-ALARM N " followed by "\r\n"
    1. /r/n = carriage return + line feed. That's commonly called an end of line (EOL) character
    2. That EOL is the Termination Character
  2. In your LabVIEW program you are sending your command "-ALARM Y " and nothing else.
  3. You probably need to Concatenate the proper Termination Character to the string you are sending. 

As it's very common for a device to listen until it receives a termination character.

Basically the device you are talking to does not know you have stopped talking because you haven't told it you have stopped talking with a termination character.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 15
(1,366 Views)

You are also actually reading after writing in your LabVIEW code and the error is a timeout waiting for a response.  You only write to the instrument with NI-MAX. Maybe try a query and see if you get the same timeout?

 

Are you sure the instrument sends a response to the ALARM command?

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 6 of 15
(1,359 Views)

I have attached my VI, I have been trying all possible solutions posted in this discussion, but none seem to work for me yet. Thank you for your help and support.

0 Kudos
Message 7 of 15
(1,269 Views)
Solution
Accepted by topic author AETHER1

@AETHER1 wrote:

I have attached my VI, I have been trying all possible solutions posted in this discussion, but none seem to work for me yet. Thank you for your help and support.


I doubt you have, else it would be working. Now you are attaching a VI that we've already seen, with all input fields blank. Enter what you think is correct into the control named "string" (I am sure there could be a better label name!), then "right-click...data operation...make current value default". Save and attach the VI once more. No we can see what you actually entered!

 

Your string is still in normal display. Have you tried changing it to \-codes instead?

 

What do you get if you run the attached code (after entering the correct resource, of course)

 

altenbach_0-1675617693677.png

 

0 Kudos
Message 8 of 15
(1,243 Views)

It worked after setting the string to code display, thanks a lot!

0 Kudos
Message 9 of 15
(1,210 Views)

How did you get "visa test panel" on NIMAX? My NIMAX does not have it.

0 Kudos
Message 10 of 15
(1,200 Views)