LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write to tdms file from queue?

Hello, Pleas let me know how to do this. I measure analog data with using DAQmx and save unscaled to the tdms file. I need use queue before saving. But is not possible connect remaining elements from Release Queue to Data TDMS write. how I can transfer data type from queue to write to tdms? I am using example of continual measure and write unscaled data to file. Thanks a lot with regards Martin
0 Kudos
Message 1 of 14
(5,478 Views)
The 'Release Queue' will return an array of the element type (or a an array of clusters if your data type is an array), so you need to put the 'Write to TDMS' in a for-loop.

Good luck,

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 14
(5,472 Views)
Hi, I did tray it, but the same problem stays.. And I dont understand how loop removed problem with datatype?
0 Kudos
Message 3 of 14
(5,464 Views)
Please post your code so we can see what you are trying to do.  The idea is that if there are 5 things remaining in the queue, an array of 5 elements would be passed out.  The write to file would be in a loop to iterate through those 5 elements.  You may need to turn on Auto-indexing where the array wire enters the loop.
0 Kudos
Message 4 of 14
(5,453 Views)
Hi, first thanks to all for help. Problem is about saving data to disk. I am using sample rate 1 MHz. When I save data to disk, program give me back error. Writing to disk is too slow compared to quantity of data. So I have to use Queue. After fisrt problem with complete scheme in block diagram without error, I have new problem - and it is the same like as I am getting started. The Queue look like doesnt help me. Can You somebady help me pleas? Thanks a lot Martin
0 Kudos
Message 5 of 14
(5,430 Views)
Not 100% sure I understand exactly where your problem is.  It would help if you could post code.
 
Meanwhile, could the problem be that TDMS doesn't support the datatype used in the Queue?  For example, I don't believe TDMS allows you to write user-defined clusters as channel data.
 
Another tidbit I *think* I recall is that when feeding a 2D array to TDMS Write, you need to provide a 1D array of channel names.  I remember doing a fair amount of trial and error on stuff like this.  Depending on whether you wire the data or channel name(s) first, a specific flavor of TDMS Write was linked in.  When you subsequently wired the other input, one or the other wire would break.

-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 6 of 14
(5,420 Views)
Hi, I am sorry that i am late, but now i am adding attachment, so you can see what i want to do.. Martin
0 Kudos
Message 7 of 14
(5,370 Views)
There are a few problems with your code.
 
1.  You obtain a queue in every iteration of the loop.  This will occur without bounds an eventually you'll run out of memory.
2.  You never release any of the queus you create.
3.  I don't understand why you are just enqueing and dequeing in the loop.  It is a meaningless operation, although it should work in that you get back out what you put in.   Queues are used to pass data between different parts of the code, or even across sub-VI's, but you aren't doing anything like that here.
0 Kudos
Message 8 of 14
(5,368 Views)
Hi, thank you, I just wanted make buffer, but i did not know how. So can I use the queue for my problem? Do you think that will be better when I move all Queues and write to the file out of loop?
0 Kudos
Message 9 of 14
(5,343 Views)

A good pattern is to move the write to file to its own loop.  Look at the producer/consumer design pattern.  You would create a queue at the beginning of the program.  Feed that queue reference to 2 parallel loops.  In the top loop where you do the DAQ, you enqueue the data.  In the other loop, you have a dequeue operation to take the data out and write it to the file.  You release the queue only at the end of the program after both loops have finished.

Depending on the speed of acquisition, you may not need to do this.  In the VI you show, you've created a buffer, but it is really just another step in the process and is really not buffering anything.  Data flow requires the data to go into the queue, and then it requires it to come right back out before the rest of the code can continue.  The biggest problem is that the queue is getting created every iteration.

0 Kudos
Message 10 of 14
(5,326 Views)