09-09-2015 08:53 PM
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,
09-09-2015 09:33 PM
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.
09-10-2015 05:26 AM
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.
09-10-2015 08:55 AM - edited 09-10-2015 08:57 AM
@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.
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord