06-21-2018 01:14 PM
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!!
Solved! Go to Solution.
06-21-2018 01:38 PM
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.
06-22-2018 12:21 AM
HI hdempseyjones,
You have to initialize your queque with this.
I have also attached the update vi. Give kudos if you like it.
06-25-2018 05:53 AM
Thank you! I really need to learn more about type defs
06-25-2018 08:32 AM
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!