LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write SAME value to MULTIPLE serial ports in parallel

I have a setup consisiting of 1200 motor controllers across 52 RS232 connections (each connection contains up to 26 devices). A very unique situation, I know.

 

What I want to do is speed up the time it takes to send a command to these things. Currently I have 3 loops running in parallel. Port 1 opens and send its commands to motors 1-26 then closes. Then Port 2 opens and does the same. I can drive about 1/3  of the field at any one time with this setup.

 

What I would like to do is run all 52 in parallel: Ports 1-52 open, all Motor 1's receive a command, then 2, then 3, etc. I cannot find a way to do this without creating 52 loops (one for each serial connection). The command being sent is just a string with no return. Say "o2000". Every motor receives the same command.

 

In doing my code like this, all motors with address #1 should start at about the same time, thus greatly reducing my time to move the entire field of motors.

 

Thanks in advance for the help,

0 Kudos
Message 1 of 4
(3,344 Views)

Hello traviscole,

 

Thanks for posting! The best way I could think to do this was to make an array of all the references to your serial ports and then iterate through them opening each of them in a for loop. Obviously, this isn't executing in parallel yet so you'll need to right-click the for loop boundary and select "parallelize iterations" . This is the best I can come up with off the top of my head. Unfortunately, you'll be limited by the number of cores on your computer which, sadly, probably isn't 52. 

 

Collin D.
Software Product Manager
0 Kudos
Message 2 of 4
(3,332 Views)

I think I would use a loop to open your VI that sends the commands and run them using the Asynchronous Call By Reference.  Make sure your VI is reentrant.  Then use an User Event to send the commands to all of the clones who then send the serial data.


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 3 of 4
(3,304 Views)

@TheNIDragon wrote:

Unfortunately, you'll be limited by the number of cores on your computer which, sadly, probably isn't 52.  


This isn't necessarily true.  A for loop set to be parallel, isn't limited to the number of cores especially when there is delays involved.  In this case the delay might be so minimal that I agree you won't see any real benefit.  But for other cases like when reading finite samples from N DAQ devices, or doing a VISA read, there can be real benefits.

 

Example_VI_BD.png

 

I would actually recommend the technique you mentioned.  Open 52 COM ports, use parallel for loops to write or read all of them more or less at the same time, and close all 52 at once.  I've used this technique before on 16 COM ports before successfully.

0 Kudos
Message 4 of 4
(3,281 Views)