12-14-2017 11:46 AM
Hi all,
I am measuring voltage using DAQmx and writing those measurements to a TDMS file with a time stamp. In my tirth column i'm trying to get the time in seconds.
I build a new waveform with a time stamp starting from 0 and convert the time array so that it writs into the tirth column of my TDMS file. But for some reason this is not working, as you can see in the file I've attached.
So what I want in my TDMS file is a column with the date/time, one with the voltage output and one with the sample time. ( In this case the sample rate is 1000 so I want the 0.001, 0.002, 0.003..... and so on in the last column).
Solved! Go to Solution.
12-14-2017 12:02 PM
So just to be clear TDMS doesn't have columns. If you are seeing columns it is likely being imported into Excel where it can be viewed that way. What TDMS does have is channels. The channel can have properties like when the channel sampling started and what the time between samples is. Often times it is more efficient in file size to write this information once, rather than writing a new value with every sample. That being said I can understand for report viewing purposes, that having a sample for each write is useful. For getting relative time like that I usually just use a for loop adding dT for every sample. Here is an example.
But as I said you can try to write the waveform the way it is and all this information will be written as channel properties.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
12-15-2017 03:48 AM
Thank you for your reply and clarification.
This solution is a lot more simple, I didnt think about it that way.
But my worksheet still doesn't show me the right value of dt.
As you can see in the snapshot below....
12-15-2017 04:40 AM
12-15-2017 05:42 AM
I'm not sure how to fix the problem with the samples.
Later in the file, it reads more than 10 samples, but at some certain point it goes back to zero again.
12-15-2017 05:46 AM
Hi Cappon,
I'm not sure how to fix the problem with the samples.
You already use ArraySize to know the number of samples from last DAQmxRead function.
All you need to do is to keep the overall number of samples by adding the "sample per loop" in a shift register.
When the number of samples is fixed for DAQmxRead then you just need to calculate "number of iterations" * "samples per iteration"…
12-15-2017 08:07 AM
Oh you are so right, sorry I missed that. This should keep it from going back to zero once in a while.
Noticed that here we start at 0, and add dT for every sample we get, but keep track of where we left off with a second shift register so that the next time we take a reading out time continues where it left off.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
12-15-2017 10:04 AM
Thanks for the reply all.
I solved it with this:
Not sure if it's 100 % correct, but it works!
10-11-2024 05:03 AM - edited 10-11-2024 05:04 AM
Hello,
I'm trying to achieve the same functionality but without using a for loop, as it needs time to execute N iterations, there for increases the execution time of the overall while loop.
In my case, I'm sampling 2000 elements at a time, so N = 2000. When I rewrite the code without the for loop, it still counts correctly, but there are only X time values, where X = (Total number of samples) / N.
Do you have any suggestions on how to solve this issue more efficiently?
Is there maybe another way to get time out of Waveform? Or out of Cluster?
Thank you for your help!