LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple visa write and visa read problem

Solved!
Go to solution

I am attempting to develop communication software for a pump using LabVIEW. The pump utilizes the UART protocol, and there is a USD interface. To communicate with the pump and retrieve parameters such as temperature and operating voltage, I need to send commands to the pump, which then provides feedback.

In LabVIEW, I am employing Visa Write to send commands and Visa Read to receive feedback. When I request a single parameter at a time (refer to Figure 1), the software operates smoothly without any issues. However, when I attempt to request multiple parameters simultaneously (refer to Figure 2), the software runs initially, and the feedback from the pump is sensible. However, after a few seconds, I start receiving nonsensical data.

I am curious about the proper approach to sending multiple commands to the device and receiving feedback. If this is not the correct method for such applications, please provide guidance on the best practices.

Thank you!

Download All
0 Kudos
Message 1 of 7
(1,568 Views)

Ever wondered why COM ports are named serial ports and not parallel ports? (You can remove the VISA Open altogether). First request a parameter: once received the answer, request another parameter. And so on.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 7
(1,521 Views)

Hi Paolo,

Thank you for your suggestions.

Since I need to set the baud rate, I found that only 'visa configure serial port' can accomplish this. Acutally, I am unsure of how to configure it for parallel ports.

Following your advice, I removed all the 'visa open' and put two sets of write and read in series (see screenshot attached). Unfortunately, the problem persists, even worse, I continue to encounter nonsensical data right from the beginning of running the program.

I am beginning to wonder if I have somehow messed up the memory.

I look forward to any further suggestions from you.

0 Kudos
Message 3 of 7
(1,500 Views)
Solution
Accepted by topic author Max39

The first thing to learn about VISA is (as Paolo told you) they are often (but not always) "call and response".  You send a message (or a "code") saying "Tell me <something>" and it sends back "<something>".  Sometimes you tell it "Tell me <something> every <time-interval>" and (guess what?) it repetetively sends you <something> every <time-interval>.

 

You need to know the device you are using, what its "commands" are, and how it "responds".  In many cases, everything is text.

 

A good idea when dealing with a VISA device is to plug it into your PC, open MAX, find the appropriate VISA port, and try to get MAX to "talk" to it.  I haven't done this in a few years, so I forget the details to setting this up.  You, of course, need to set the Serial Parameters (Baud Rate, # Data Bits, # Stop Bits, parity, etc.), then try to send a command to the Device and read its response.

 

If you are fortunate to have a VISA device that "speaks" in Text, then programming VISA reads is simple.  When you do the VISA Configure, there is a default setting to Enable Termination Character, and to use <LineFeed> as the character.  Most VISA responses are a single line of text, so your VISA Read command should request a Read of 1000 (or, because I like Binary, I ask for 1024) bytes of data (do not use "Bytes at Port").  The VISA response (if a single line response) will end with <LF>, so you don't have to "guess" or "think you know" the length of the response!  This keep you "in sync" with your device.  If you use "Bytes at Port", and you ask for too small a Read, you'll leave "garbage" waiting to be read the next time you try to read, which is probably why your responses become garbled over time.

 

I'm sure if you Google "Reading VISA in LabVIEW", you will find one of Tim Robinson's excellent presentations on "How to VISA in LabVIEW" (that's probably not his title), where he discusses this and more.

 

Bob Schor

0 Kudos
Message 4 of 7
(1,481 Views)

Thanks Bob.

Very useful!

0 Kudos
Message 5 of 7
(1,472 Views)

Bob gave you the solution. Your device does not talk text but binary bytes and uses fixed size messages rather than end of line terminated messages. So you need to disable the termination character input on your Configure Serial Port function.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 7
(1,450 Views)

@Bob_Schor wrote:

I'm sure if you Google "Reading VISA in LabVIEW", you will find one of Tim Robinson's excellent presentations on "How to VISA in LabVIEW" (that's probably not his title), where he discusses this and more.


Bob, you need to learn to use macros...

VIWeek 2020/Proper way to communicate over serial


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 7 of 7
(1,389 Views)