12-24-2023 10:48 PM
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!
Solved! Go to Solution.
12-25-2023 06:02 AM
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.
12-25-2023 07:32 AM
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.
12-25-2023 09:30 PM
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
12-25-2023 10:46 PM
Thanks Bob.
Very useful!
12-26-2023 01:49 AM
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.
12-28-2023 02:52 PM
@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