LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA test panel works but VISA Write does not.

Hello. I am using LabVIEW 2023 and I want to automate which includes an optical copper and a monochromator. I used the commands provided in the manual which works with the VISA Test panel but does work with VISA Write. I enabled the termination character to 13, for carriage return (\r), in VISA Configure Serial Port and even enabled " '\' Codes Display " for the string of  VISA Write but still it doesn't work.

 

I am using a USB connection (USB A to USB B)

 

I have attached one of my basic code where I want to run the chopper, for which the command is " enable=1 + carriage return ". I have also attached the manual of the chopper just in case.

 

Can anyone please help me out with this?

 

Download All
0 Kudos
Message 1 of 9
(211 Views)

According to the manual to attached (thanks) and the very tiny code snippet, it should have worked, but how would you know?  You only send an "enable=1\r" command to "some unspecified port", and then quit!  I didn't read enough of the manual to know what to expect, but I assume that the device would respond with an acknowledgement that you could observe with a VISA Read.

 

I should have bookmarked it, but there is an excellent video out there by Tim Robinson on how to (properly) use VISA.  [Found it -- search for "Reading VISA in LabVIEW Tim Robinson", and it will take you to the video in the LabVIEW Wiki].

 

Bob Schor

0 Kudos
Message 2 of 9
(146 Views)

I suggest you watch this video: VIWeek 2020/Proper way to communicate over serial 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 9
(122 Views)

Thanks for your response Bob_Schor and RTSLVU but I watched the video and didn't get any proper solution.

I actually kept a PORT control for Visa Resource name like this here.

Sai_09_0-1750917700132.png

 

I had also wired a VISA Read after VISA Write as you said earlier. When I read the buffer from VISA Read I get the same string which I send from the command, just the difference is that it doesn' t include the carriage return (\r). 

Like for example, in the below VI I ask for the current frequency but I get the same string.

Screenshot 2025-06-26 113959.png

Where actually I should get a value like this. (This is from the VISA Test Panel)

Screenshot 2025-06-26 114421.png

0 Kudos
Message 4 of 9
(98 Views)

Hi Sai,

 


@Sai_09 wrote:

Like for example, in the below VI I ask for the current frequency but I get the same string.

Screenshot 2025-06-26 113959.png


Did you notice that little arrow in the lower right corner of the "read buffer" string indicator?

This arrow indicates that there is MORE text, but it's not visible! Resize the indicator to show more lines of text…

 

Or the other way around:

The VISA Testpanel shows messages in \-code display, but your string indicator is set to default display mode. Switch it to also show \-code display!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 9
(80 Views)

Yes I resized it but its nothing. It just shows like that. Also enabling the '\-code display' for the string indicator for read buffer just made a difference of adding a carriage return(\r). It still gives the same command as response 

Screenshot 2025-06-26 162615.png

 

 

0 Kudos
Message 6 of 9
(66 Views)

The problem for you is that you are reading to the first \r that VISA has in the buffer. 

 

Look at the VISA test panel. You have multiple \r in the return data. 

Either change the termination character, or read more times.   

Message 7 of 9
(60 Views)

Sometimes manuals are wrong, use _no_ termination character to see what it actually sends. It seems clear that it uses \r for write, but it might answer with \r\n or just \n as terminator on answers. Or it might just be that it actually sends 2-3 answers to a query, first mirror the command (which could be used as a sanity check) and then the real answer. In that case you need to read 2 answers each time.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 9
(38 Views)

Hi,

 


@Yamaeda wrote:

Or it might just be that it actually sends 2-3 answers to a query, first mirror the command (which could be used as a sanity check) and then the real answer. In that case you need to read 2 answers each time.


Sometimes you can even configure (aka dis-/enable) that "echoing of the command" to simplify the communication with the device…

(Probably reading the manual will tell you all your options!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 9
(34 Views)