LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Enqueue and dequeue cluster then save to TDMS file (or other file?) in producer-consumer

Solved!
Go to solution

Hi all,

 

I have a producer that is reading from an accelerometer using DAQmx Read

 

I want to send the waveform data from this (2 channels of data, X axis and Y), as well as the current time (using the 'Get Date/ Time in seconds' VI, i.e. a timestamp), the loop iteration count (32 bit integer), and a reading from a clock I made on the front panel (output is a 1D array of doubles) - for each loop to a consumer, that saves it in TDMS (or other) format.

 

I am having some weird issues. I can't seem to set up the cluster constant right. I put in 2 waveforms, a timestamp, an integer and a double but I get an error saying I am trying to put a 'cluster with a waveform and a waveform double' a cluster with '2 measurements, and a waveform of doubles'. I noticed that when I go to dequeue the cluster where I put in two waveforms, it is showing 2 'measurements'... so its changing the data type in the queue.

 

I thought maybe you cant send a whole waveform into a queue, so tried breaking it down into its dt, Y and t0 (and changing the cluster constant to allow this) - but then it said I was trying to connect 7 items to 9 - which I wasn't. So I know I am missing something, but I can't quite see what...

 

Also, will a cluster just save into a TDMS file? or do I have to flatten it/ write it to a string or something (things I read online but not sure apply). I would like to have each input in a different column (waveform1, waveform2, time etc...) and then each sample/ iteration in a different row in my saved file...

 

Any help would be amazing... I have added some pictures - the first is the original, the second has some broken stuff in it I tried (mostly disconnected, but to show my *working*)

 

Thank you!!

 

 

0 Kudos
Message 1 of 5
(2,903 Views)

Make a type-def of your cluster and use it to both create the queue and at the point where you enqueue.  Then you will not have these mismatch problems.

0 Kudos
Message 2 of 5
(2,896 Views)
Solution
Accepted by topic author hdempseyjones

HI hdempseyjones, 

You have to initialize your queque with this. 

queque dequque.PNG

 

I have also attached the update vi. Give kudos if you like it.

 


CLD Using LabVIEW since 2013
Message 3 of 5
(2,868 Views)

Thank you! I really need to learn more about type defs

0 Kudos
Message 4 of 5
(2,852 Views)

Ahh, I see! So the cluster I was initialising contained two 'measurements' with waveforms inside, which you now replaced for just waveform elements. This seems to work nicely! Thank you

 

I was just wondering, regarding the second part of my question - how to save the output of this cluster to a file. I am not sure the best way to do this. In my ideal scenario I would have each element of the cluster in its own column of a TDMS file (with one row per loop iteration). At the moment I have just unbundled everything, formatted it all into a string together and saved that string (one row per loop iteration). Is there a better way to do this, ideally so I can get one cluster element per column)?? [first image]

 

In a related question, I am saving two arrays into a TDMS file with single values (doubles) [second image]. The way I am doing it seems to work fine but I think there is also probably a nicer cleaner way (also maybe where I could label the values?)

 

Thank you all!

0 Kudos
Message 5 of 5
(2,843 Views)