05-10-2017 12:41 PM
Problem 1;
I have [serial device A] connected to my computer that sends data from n [sensor device B]s. What is the best way to structure my code so that my vi's can process data from device B0 to Bn in parallel?
I'm guessing that I can clone a single vi (n+1) times and have them listen (via a named queue?), but I'm not sure the best way to implement that
______
Problem 2;
After I get multiple processors running in parallel, what is the best way to recombine them into a single display? Would it be possible/advisable to have a vi that is just an array of sub-panels that asynchronously reads the state of each clone?
05-10-2017 10:18 PM
I've done something like this -- (up to) 24 balances spitting out a serial stream of weights, all run through a serial-to-TCP/IP device. MAX can "see" all of the serial devices coming in on a single Network Connection, configured as 24 VISA devices.
What we did was to write a VI to handle one balance. We wrote the VI with a parameter, which we called a "station", that would serve to select the particular VISA channel we were using. In our case, we were streaming the data to disk, rather than sending them to a common "listener" VI, but if we wanted to do the latter, we could set up either a single Named Queue that all the Stations would send their data (perhaps as a Cluster, one member of which is the Station ID) or as individual Named Queues and let the Listener handle the multiple dequeues.
In any case, the Stations were configured as Pre-allocated Reentrant Clones and were spawned with Start Asynchronous Call, passing in the Station ID as an input parameter (a single For loop handled spawning all the Stations, with the Loop Index serving as the Station ID).
In this particular instance, the Serial Data, while nominally being acquired at the same rate, was really coming in at "approximately" the same rate, so plotting multiple Stations was a little problematic. What we did was choose which Station we wanted to plot. Each Station maintained a Lossy Queue that served as the "initial plot" points -- when a new Station was selected, it passed these points to the Plotting Routine which started the plot, adding subsequent points as they became available. Crude, but effective.
Bob Schor
05-11-2017 07:54 AM
Bob_Schor wrote:What we did was choose which Station we wanted to plot. Each Station maintained a Lossy Queue that served as the "initial plot" points -- when a new Station was selected, it passed these points to the Plotting Routine which started the plot, adding subsequent points as they became available. Crude, but effective.
If you are just showing 1 plot at a time, subpanels would be easier.
I did the same as Bob, ut used User Events to sent messages to all of the stations. The station ID was always part of the event data, so each station could react to messages addressed to it.
05-11-2017 07:59 AM
05-11-2017 03:29 PM
You say you need to see the data from "all the sub-VIs at once", but your data are coming from independently-running serial streams (which are not always so accurate in their transmission rate). But if you are really interested in only displaying the data, you might be able to "have your cake and eat it, too". Note that I've actually implemented a similar scheme, but for synchronous data ...
Let's say your data are coming in at around 100 points/second, but you are really interested in slower changes, say with a time resolution of 0.1 second (if your display is 600 pixel wide, you'd see a minute of data on the screen). Let's also say you want a Chart, i.e. a scrolling display.
Send all of your data to your Display routine. It doesn't much matter if you send in a single Queue (with Station information to identify the points) or one Queue per Station (easier, perhaps, to manage). You want a Receiver that does the following: for 100 msec, it acquires (and averages) whatever data have come in on each Station. Since they are sending independently and at possibly slightly different rates, you might get 9 points from Station 1 and 11 points from Station 2, but an Average should be more-or-less independent of the number of points. When the 100 msec is up, bundle the Averages from all the Stations and sent the N-channel "single point" to your Chart. Your Chart will update smoothly (independent of the varying rates of your Serial data), the plotted data will be synchronous, and you won't need to worry about time jitter between the channels.
Bob Schor