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.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple serial communications

I am using Labview 7 express, and I am trying to read from multiple serial ports simultaneously. I have tried using the visa read vi, but it does not seem to work. Do you need to using anything with the visa read.vi to parse the data stream? Thanks
0 Kudos
Message 1 of 8
(3,454 Views)
I think we don't have enough information to answer the VISA questions.

In what way does VISA Read fail?

Are all the serial ports receiving actual data simultaneously, or are you trying to monitor several ports that are mostly quiet, and respond to each one as it receives data?

Do you have a bunch of parallel loops--one for each port, or are you doing the reads sequentially?

Have you confirmed that a single VISA Read on a single port works correctly?

Post your answers back here and perhaps we can figure something out.

As far as parsing the data stream, this is a separate issue. The VISA Read function returns a string, so if you need to extract numbers from it, you have to use different functions from the string palette menu. The "Scan from St
ring" is very useful. "Spreadsheet String to Array" is useful for parsing waveforms.

If you are on Windows, you can use Instrument I/O Assistant to help you figure out how to parse the data from your devices. It only deals with a single device at a time, but you can take apart its results and apply it to your case.

I hope this helps.

Brian
0 Kudos
Message 2 of 8
(3,454 Views)
OK, The Visa read does not fail it just does not work properly. It recieves and displays the data for the first port fine, but then the data for the second port gets backed up sort of. The display blinks, the real data every few seconds.

I am using parallel loops for each port.

The visa read works fine for one port. It just has trouble with more ports, it is like the data gets backed up at the port or something.

Thanks, Aaron
0 Kudos
Message 3 of 8
(3,454 Views)
I am not sure what you mean by "gets backed up". Do you mean that it appears to come in bursts when you expect it to come more continuously? Do you think the second port is falling behind, or do you think that data is being lost?

LabVIEW should be scheduling the parallel loops fairly evenly, so I don't think it's a problem that LabVIEW is starving some of your loops.

You don't mention what kind of serial hardware you are using. If the data is coming in at a very high rate of speed, I wonder if the hardware has some prioritization such that the first port always gets the most attention.

One way to narrow things down would be to swap your devices on your first and second ports, and swap the COM ports in your software, but leave all the rest o
f your software the same. Does the first port continue to work correctly, or has the second port started working instead? The answer to this helps identify whether it's something in your software (and/or LabVIEW), or whether it's a behavior of the hardware setup.

Brian
0 Kudos
Message 4 of 8
(3,454 Views)
It seems like the second port is falling behind, If I take data for awhile, the second port will display the data but data that had been taken a few seconds before.

I have four digital(postal scales) that have serial output, and they are hooked to a serial hub, that hooks to the computer via USB port, I don't think that it is a problem with the hub, but I will try what you suggested to make sure.

Aaron
0 Kudos
Message 5 of 8
(3,454 Views)
That makes sense now. (Well, the description of the problem, not a solution.)

One thing you could try is to monitor the "Bytes at Serial Port" (it's on the VISA palette) to see if you have a backlog of data waiting to be read on the various ports.

How much data are you reading from the port at once? Are you reading a fixed amount, or trying to read all of it?

If you find a backlog, you may want to change your reading strategy to get it to catch up when you fall behind.

Unfortunately, this doesn't help you understand why you're falling behind.

Brian
0 Kudos
Message 6 of 8
(3,454 Views)
That is exactly what is happening, on the second loop, the data backs up, like it can't read through it fast enough.

What do you mean how much data, data bits? It is a fixed amount, the data string word length is 8 bits. and it needs to be read continously.

How would you change the reading strategy?

Aaron
0 Kudos
Message 7 of 8
(3,454 Views)
As a means of explanation, here are a couple of different example strategies.

Example 1, in a loop:
read 1 point
process 1 point

Example 2, in a loop:
read all the data
process all the data

The latter might be more appropriate in your case.

If you don't care about anything but the most recent data, you could do something like this...

Example 3, in a loop:
Read all data
Discard all but the last point
process 1 point

Does this make sense?

Brian
0 Kudos
Message 8 of 8
(3,454 Views)