LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is fastest way to read from 30+ com ports simultaneously

While you are going there--- And you are hitting an edge case!

 

VISA Reads and VISA Writes can be "Synchronous" or "Asynchronous" (right-click menu on the primitaves)  You REALLY want to read and understand the differences by digging deep into the LabVIEW help file.Smiley Wink


"Should be" isn't "Is" -Jay
0 Kudos
Message 11 of 18
(705 Views)

Oh man, Jeff opened up a can of worms!

 

Against common wisdom I recommend synchronous rather than async.  (by right clicking on the icon).

 

Asynchronous calls will cause a spinlock to keep checking to see if the VI is done.  This will kill your CPU.  But it does not consume a LV execution thread.  With 30 async calls your CPU might come to a standstill.

 

Use of synchronous calls will use a LV execution thread but are easier on the CPU.  You will have to hand edit the number of LV threads for the number of simulataneous calls you might have.  There is a "threadconfig.vi" in the vi.lib that will set the # of threads up to 8 (IIRC).  I would do that for the main execution engine that you are using (or assign all your I/O vis to a specific engine like "user1").  But you will have to find the labview .ini file and hand edit it to make it do such a large thread allocation.  It is pretty easy to find the items to edit once you set them with threadconfig.vi.

 

Warning.   This solution is not endorsed by NI!  YMMV.

LabVIEW ChampionLabVIEW Channel Wires

Message 12 of 18
(696 Views)

Seth

 

That is why I  encouraged reading the help file studously!

 

This does sound like an edge case!  I cannot try it! I do not have the "bajllion" devicesSmiley Wink

 

WARNING! requesting "Async..." does not mean the VISA call completed asynchronously. It gets complicated.


"Should be" isn't "Is" -Jay
0 Kudos
Message 13 of 18
(687 Views)

Jeff·Þ·Bohrer wrote:

 

That is why I  encouraged reading the help file studously!

 

This does sound like an edge case!  I cannot try it! I do not have the "bajllion" devicesSmiley Wink

 

WARNING! requesting "Async..." does not mean the VISA call completed asynchronously. It gets complicated.


I agree and actually arguing with NI developers has been the main way of figuring that out.  A bit of testing is well worth the effort here when running those 30 serial port simultaneously.  I found out a lot about VISA in just opening two serial ports and sending packets back and forth at various sizes and measuring throught put.  Became a useful VISA test tool.

 

The other tuning I was pointing out is the number of threads in an execution system.  This also is very open to debate and depends on the cost overhead of thread switching which can cause system thrashing.  It depends if you are I/O limited or CPU limited.

 

And the last tuning is the OS itself.  There is a huge difference in latencies between windows and mac os x.  I have some custom software that was writtne in VB and can barely keep up with 6 or 7 serial ports at a time on very new hardware.  It replaced a C program that I had written under Unix that had no problems with very old hardware.  YMMV depending on a lot of factors.

 

PS. the "sth" are initials.  it is Scott

LabVIEW ChampionLabVIEW Channel Wires

0 Kudos
Message 14 of 18
(677 Views)

Also TERMINATION setting.

I find my biggest cause of slow communication between my test station and the UUTs is not getting the termination setting to match the termination settings of the UUT. Big mistake to assume.

 

To expand a little bit more, I open two VISA sessions per com port (64 total) one for sending (VISA Write) and one for receiving (VISA Read) duplicate session set to True. This allows you the write at the same time you are reading (or waiting to read) from the same com port.

 

For each UUT, the Testing SubVI each launch it’s own copy of a communication server VI for it’s assigned comport that opens the two VISA sessions. One sessions is constantly looping reading (more like waiting) at the comport for any bytes with a timeout set to 3 sec. Any messages received are time stamped and logged to a file. Then passing filtered messages back to the Testing SubVI in a queue. This allows a VISA Write function to work while the VISA Read function is blocked waiting for a reply.

 

The UUT can on their own send out a message mainly due to some error conditions (I prefer devices that only speak when spoken to) So regardless what the Testing SubVI or the top level VI is doing, I will always receive, time stamp and log any messages when they are received.

 

Again this communication server only knows about and only cares about a single comport, very simple to code, maintain and scalable.

Omar
Message 15 of 18
(643 Views)

Since I currently only have 2 units, what would be the best way to simulate the expected behavior and timing comstraints of using 32 units with 32 com ports?

Certified LabVIEW Developer

0 Kudos
Message 16 of 18
(621 Views)

Try a hard wire loop back on the remaining comports (Tx to Rx) and read back what you write 

http://www.ni.com/white-paper/3450/en/

Omar
0 Kudos
Message 17 of 18
(618 Views)

Good call, thanks.

Certified LabVIEW Developer

0 Kudos
Message 18 of 18
(601 Views)