06-18-2025 02:51 AM
Hello,
ich want to sample data with 500000kS/s for aprox. 10 minutes. For that i set two while loops (producer and consumer) to write this continously in a tdms file. I do not know what I did wrong but the consumer loop doesnt start while the producer loop seems to run perfect. Only when I set the number of samples in the DAQmxRead manually then the producer and the consumer loop runs 1 time. But then the limit is the size of the puffer storage.
Can anyone help me with that. Im quite new in the Labview community.
Thanks a lot
Martin
Solved! Go to Solution.
06-18-2025 03:02 AM
Hi MaKIT,
@MaKIT wrote:
ich want to sample data with 500000kS/s for aprox. 10 minutes.
500000kS/s = 500MS/s = 0.5TS/s…
Really?
@MaKIT wrote:
For that i set two while loops (producer and consumer) to write this continously in a tdms file.
Why don't you use the TDMS writing feature in DAQmx directly (as explained in the example VIs)?
06-18-2025 03:12 AM
Ah sorry, I wanted to write 500kS/s!
I found online to do it with this both loops. Thank you for your hint. I will try it with this TDMS writing feature. Can you explain where I can find this example VIs?
Best regards
MaKIT
06-18-2025 03:29 AM
In the LabVIEW Panel go to Help ->Find Examples and Search For TDMS Write based on your data to write.
06-18-2025 03:49 AM
Hi,
@PalanivelThiruvenkadam wrote:
In the LabVIEW Panel go to Help ->Find Examples and Search For TDMS Write based on your data to write.
Or look for the DAQmx example VIs, there are several that explain the TDMS logging for DAQmx tasks…
06-18-2025 04:04 AM - edited 06-18-2025 04:12 AM
The way you've wired your Stop button the Writing loop will not start until you press Stop and it'll stop automatically ... The Queues shouldn't have timeouts.
This simple change should solve it, though it's kind of a hack and if you have lots of data still in queue it'll be ditched. A better variant is to send an empty array when you want to quit and check for that in the consumer loop and have the Release queue on the Consumer output.
Something like this (the waveform cluster can be changed to Icon to have a cleaner diagram)
06-18-2025 06:25 AM
@Yamaeda wrote:
The way you've wired your Stop button the Writing loop will not start until you press Stop and it'll stop automatically ... The Queues shouldn't have timeouts.
This simple change should solve it, though it's kind of a hack and if you have lots of data still in queue it'll be ditched. A better variant is to send an empty array when you want to quit and check for that in the consumer loop and have the Release queue on the Consumer output.
Something like this (the waveform cluster can be changed to Icon to have a cleaner diagram)
Thank you,
I deleted the time outs and made the changes as you suggested. Now both loops runs and sample data and write it to the tdms file if the sample time is approx 30s. If I increase the time to 60s for example, I get a pop up window: the size of the memory is too low I cant finished the operation.
With the indicators of the loop counters I can see that the producer loop is almost twice fast as the consumer loop.
Im not sure if I have the correct settings for the DAQmx Timing. I choose "continouus Samples" and for the DAQmx Read I set "analog, multiple channels, multiple samples, 1d"?
06-18-2025 06:57 AM
Since you're going for a high sample rate i'd try Finite samples, buffer size same as sample rate and read 50% of those per loop (so you read and queue 2 times/second)
I see a flaw in my design, change it like this. (i ditched the last samples, now it sends the last sample and then the empty array to signal end)
06-18-2025 07:34 AM
OK. I took a look at the code you originally posted, and have some comments and suggestions.
Bob Schor
06-18-2025 08:08 AM
I'm ashamed of myself. Possibly because I was "tea-deficient", I gave the "LabVIEW 2015" description of the "better way" to structure a Producer/Consumer design. And I consider myself a "Champion of Channel Wires" ...
What you really want to do for a Producer/Consumer is to use a Stream Channel Wire. The Stream Channel Wire is precisely what you want for a Producer/Consumer design. In addition to having a "Write Stream" VI where you put "whatever you want to send" to the "Read Stream", it has two additional Boolean inputs, "element valid?" (which defaults to True) and "last element?" which defaults to False. It's partner, the "Read Stream" VI, also has a pair of Boolean outputs with the same name. Look in the Examples that ship with LabVIEW -- the first two examples under "Channel Basics" show the Stream Channel in action. I haven't used a LabVIEW Queue since 2016 ...
Bob "Asynchronous" Schor