LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data transfer from multiple devices running in parallel

Hi Everyone,

 

Currently, I am working on a application that should be able to connect to several devices in parallel, continuously collect the data they acquire and display the data in main VI.

So far, I am able to connect to the devices, start/stop acquisition, disconnect from the devices. I use for that purpose VI which is set to be reentrant (Preallocated clone), e.g. thread.vi

 

My problem is about strategy of transferring data to the main VI.

My first try was to transfer the data using queue. Queue ref (cluster of a string (device) and 2D DBL array (data)) is input of the thread.vi and all the clones are enqueuing into the same queue. Then, in the main VI, I have a 1D array of Clusters containing string (device) and the 2D DBL array. I sort the data according to device string to append the data into correct cluster. Then I should display all the data from the all the devices in waveform chart where I receive "Not enough memory" kind of dialog box, because certainly I am doing something wrong with those arrays and it grows pretty quick.

 

My second try was to use FGV with the states (add, get) which I use to store the data and send the notification (using queue) that data is ready to be read from the main VI. FGV is set to be reentrant. I send the FGV clone reference along with the boolean to the main VI. In the main VI I am trying to use Call By Reference function to get the data from the FGV. The problem is that it works but I do not get any data in the main VI and I do not know why. I use Open VI Reference (Options is not connected) with the strictly-typed VI reference and CloneName. Then I call Call By Reference function and after "reading" I call Close Reference function. (For Options in Open VI Reference I have tried several combinations but non of them worked)

 

My questions are:

1. Is any of my tries a good way to do this? (beside that I am still facing problems)

2. Is there better way to do this?

3. In the second try, why I do not get the data in the main VI?

 

I am out of ideas and with each try I am stuck somewhere and to be honest do not know which way to go to transfer the data to the main VI.

 

Thanks for the replies.

0 Kudos
Message 1 of 6
(3,593 Views)

Usually queues is the answer, but I have to say I really do not understand your question...

 

Post your code so we can see what you are trying to do and how.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 6
(3,564 Views)

You should make a separate queue for each instrument you want to talk to. They can all send messages back to some User Interface loop.

 

Alternatively, they could use User Events, and trigger an event whenever data is ready.

 

The DQMH toolkit (downloadable with VIPM) has good examples for talking to multiple instruments (even multiple instances of the same instrument).

 

 

0 Kudos
Message 3 of 6
(3,551 Views)

Tukan wrote: I sort the data according to device string to append the data into correct cluster.

This is likely where your problem is.  You should not be continuously adding data to your arrays.  You should just replace the data and write to your CHART (which already has a history).  If necessary, save the data in a TDMS file as you recieve it.

 

But it would be helpful to see some of your code to get a better idea of what you are doing.


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

Let's assume you have three Remotes, call them A, B, and C, all generating data and sending it to the Host via a Data Queue whose payload is a cluster of ID (A, B, or C) and Data (2D array of DBL).  Let's further assume that A, B, and C are sending you packets at 20 Hz.  Let's further assume that in the Host, you want to write the Data into File A, File B, or File C, and to display the average value of Data on Chart A, Chart B, or Chart C.

 

Here's what I would (and, indeed, did) do.  I would make the loop in A that dequeues the data from the Remotes a Producer of a Producer/Consumer pair, feeding Queue A, Queue B, or Queue C with Data (the Dbl Array) depending on whether the data packet came from A, B, or C.  The three Consumers would dequeue Data, write it to the appropriate File (Consumer A writes to File A), computes the mean, and adds it to the appropriate Chart.  All three Consumers run in parallel, and run at the respective "speeds" of the three Remotes (so if Remote C sends packets at 10 Hz instead of 20 Hz, so what?).

 

Bob Schor

0 Kudos
Message 5 of 6
(3,510 Views)

Hi Everyone,

 

thank you for you replies. I am sorry I was not enough clear. An example is attached.

I did it in a hurry but anyway it would be helpfull to know what is good what is not, to improve it.

Project is in LV 2014 32b

 

Basically I am trying to put data from all clones into one queue. Those data is dequeued in a main vi and stored in the array according to their CloneID (it does not really works). When I am debugging and using breakpoints and stepping it works as it is indended. When I run the clones (e.g. two clones) at full speed I ended up with three items in the array in the main vi.

Element 0 of the array is replacing data between clone 1 and clone 2.

Element 1 is clone 2.

Element 2 is clone 1.

Maybe some notification or synchronization needs to be done.

 

Once this works correctly, I would like to display all the data from all the clones/devices in one chart and also store the data into the file. In the future all the devices will acquire the data at the same rate.

 

Bob I did not really understand this


@Bob_Schor wrote:
Here's what I would (and, indeed, did) do.  I would make the loop in A that dequeues the data from the Remotes a Producer of a Producer/Consumer pair, feeding Queue A, Queue B, or Queue C with Data (the Dbl Array) depending on whether the data packet came from A, B, or C.  The three Consumers would dequeue Data, write it to the appropriate File (Consumer A writes to File A), computes the mean, and adds it to the appropriate Chart.  All three Consumers run in parallel, and run at the respective "speeds" of the three Remotes (so if Remote C sends packets at 10 Hz instead of 20 Hz, so what?).

 

Bob Schor


So in a Remote A would be dequeue from all the Remotes including A? or it should be Host?

 

Please let me know if I was not clear again. Thanks.

 

Tukan

0 Kudos
Message 6 of 6
(3,462 Views)