07-02-2021 03:55 PM
Hi, I have an array of 8 elements, each containing a timestamp, double and integer (as shown below).
I cannot get this array to log into TDMS. Is there a trick to doing this? TDMS seems to want the constant shown below?
Solved! Go to Solution.
07-02-2021 06:58 PM
We can't debug a picture. Please post your code if you want to demonstrate something.
The data type you have there is the "Waveform" data type, which contains a timestamp, a dt value, an array, and an attributes variant. Ignore the last one for now- it's optional.
The Waveform datatype is used for periodic data. The Timestamp in there is when the dataset was started. It's technically optional as well, though it can be helpful. The dt value is the time step between each successive sample. For example, a 10 Hz signal would have a dt of 0.1. The array is the actual sampled data.
You said you have a timestamp, double, and integer. If you're taking data at a constant rate, I'd recommend using a waveform datatype as it's quite handy. If you're taking data at a non-constant rate (like, say, every time the user clicks a button or something) you'll need to store the data separately.
If you open the Help file for TDMS Write and scroll to the "data" section, you'll see it can take an input of a waveform datatype, array of waveform datatypes, some digital stuff, and 1D and 2D arrays of numbers including timestamps.
With your data you should be able to go about this in a few different ways. The first, and simplest, method is to just convert everything you have there to a double value, and write it all as a 2D array. If you want to get a little more advanced, you can just use multiple TDMS Write functions, each writing a single array of each datatype, with your Channel Name set to something different each time. You should then be able to read out each of your channels as 1D arrays. This is probably the better choice as it preserves the "intent" of your data and you don't have to move a bunch of stuff around. Last, assuming you have constant-period sampling, you could change your data to be of Waveform datatype and can write an array of Waveforms.
07-12-2021 10:51 AM
Thank you, I did get it working finally. I had to basically take those clusters and split them out to arrays them send the arrays out the to the TDMS.
07-12-2021 11:06 AM
I'm not seeing a point in the Array To Cluster. You could just use Index Array to get the clusters you want. Or, even better, just autoindex a FOR loop and parse each element building array(s) on the output that you can then wire to the TDMS Write.
07-12-2021 01:53 PM
What crossrulz said!