12-01-2014 05:33 PM
Hello,
I have several devices that I need to read using RS232. The results should be stored in an measurement file. The measurment is around 15 minutes long.
I did the following:
Several while loops in parallel. Lets say loop 1, loop 2 and loop 3 read the RS232 and generate data.
Loop 4 is reading the data, merge the data (merge signals) and write everything into a measument file.
For the communication between Loop 1,2,3 and loop 4 I use local variables.
In that way:
- a slow loop gets read several times (same value) which is all right.
- a fast loop gets read and may loose some values. Not nice but acceptable.
Has anybody a better idea how to implement something like that? Thanks you so much for reading.
Cheers,
12-01-2014 11:42 PM
You should take a look at queues. They're meant to handle the desired task more than local variables.
12-02-2014
12:14 AM
- last edited on
05-11-2025
08:58 PM
by
Content Cleaner
Hi,
Don't use local variables. If you don't want to lose data, and don't want to read data twice, the best suggestion I have is to use queues. Look at the Producer/Consumer Design Pattern (Data) from File->New...->VI->From Template->Frameworks->Design Patterns. You can easily have a number of producers as shown in the snippet. You can also get more information here.
Good luck,
Danielle
12-02-2014 08:14 AM
Combining data from multiple loops can be interesting, especially if they all run at different rates. You should use a single queue to send the data to your file write loop. The data type of the queue should be a cluster of a string and a number (or array of number). The string can tell you what the data is and you can react accordingly from there.
12-02-2014 03:57 PM
Sorry for the late reply.
Thank you for all your tips. I will look into the queue suggestion.
Thanks.
12-02-2014 05:32 PM - edited 12-02-2014 05:36 PM
What crossrulz wrote, would work nice. I would go in this way on:
in every data producer loop you can insert the measurement data into a cluster, and a label describing the source for example. Beside, generate a local timestamp, and put it also into the cluster.
In your file write loop where you dequeue your data from all of your parallel loops, use a TDMS file data management. Here you have several options. I would create two channels for each producer loop: first column (you see it this way if you import it to Excel) time stamp1, second column data1, third column time stamp2, fourth data2, and so on...
In this way you will have a TDMS file including all your data and every single data value has an exact time stamp. No loss of info... Since TDMS is binary, you can develope pretty fast data evaluator in Labview to do whatever you want with your measurement data...
12-03-2014 07:07 AM
The TDMS file format is an excellent idea. Just make a different group for each acquisition loop. Then you don't have to worry about all of the synchronization and what not.
12-03-2014 07:09 AM
@crossrulz wrote:
The TDMS file format is an excellent idea. Just make a different group for each acquisition loop. Then you don't have to worry about all of the synchronization and what not.
yep, this way better: use a separate group for each DAQ loop, and in each group make two channels: one for the time stamp, the other for the data.