06-16-2016 03:55 PM
I am writing data to a file collected with a dt = 0.005 sampling interval (but not from DAC hardware. I would like to save the data to a LVM file with one column the timestamp and the second column the data, and I'm using the "Write to Measurement File" Express VI in the following Labview code snippet:
The dt value of the local variable is 0.005. This delta T is recorded in the saved file, but the timestamps do not change from the initial value of o,o:
What am I missing?
Thanks,
John
Solved! Go to Solution.
06-16-2016 04:17 PM
06-16-2016 04:17 PM - edited 06-16-2016 04:17 PM
Express VIs and the Dynamic Datatype can be very limiting in these cases.
Effectively, you are writing single point waveforms with the same t0 which results in them all displaying t0 as 0.
You might consider using Write to Delimited File instead.
Or you can construct your waveforms so that they log the right t0.
I generally avoid using Express VIs and the Dynamic Datatype but I think that's where your issue lies.
Unpacking your scalar to dynamic data and then repacking it into a single element array to pack into a waveform is more manipulation than necessary and you should probably just skip that part.
06-16-2016 04:34 PM
Thanks for the comments. In my previous version of code, I used the dequeued elements as direct input to the Express VI, and a timestamp that incremented (I surmise it was when the data point was saved?) was automatically added. So my thinking was to create a waveform from the elements with a specified delta t, and I would get the timestamps I wanted.
Is there any workaround? Client would like to continue with the LVM file format. If I built an array, would that get around the problem of single-points with t0=0.0? Perhapas creating a second stream of data which starts at 0 and increments by delta t, combined with the data?
Thanks,
John
06-17-2016 07:13 AM - edited 06-17-2016 07:17 AM
i wouldn't really call it a workaround. It is the intended behavior.
Build and write as an array and your waveform will be recorded correctly.
If you're going to write a point at a time, all you have to do is keep track of what you want to use for t0 and wire that in when you build your single point waveform.
EDIT: Does the "Untitled" column name bug your client at all? It would bug me. You can fix it by doing Set Waveform Attribute for "NI_ChannelName".
06-17-2016 06:32 PM - edited 06-17-2016 06:35 PM
I took your suggestion and reworked the code to write a single-point waveform with the correct t0. In the diagram below, the t0 increased by dt for each element dequeued. The code is inefficient because I'm writing one point at a time, but I get the desired result:
A 1-D array of size one is built for each element dequeued. Are you suggesting that if I instead built an array of length >1, then t0 would be a constant and the timestamp would increase by dt?
Also, thanks for pointing out the use of Set Waveform Attribute for the channel name--I will implement that.
John
Edit: In my latest code, I did replace the scalar to dynamic data to array with just a build array, as you suggested.
06-17-2016 07:42 PM
I just tried building and writing an array instead of a single-point waveform, but each time the array was written to the file, t0 was reset back to 0.0.
06-20-2016 09:18 AM
Hello wygonski
As far as I know and using the screenshot you put before, if you want to avoid to reset the t0 I believe you should double check what do you have in the true case, because it sounds like you have a constant of 0.
Regards
06-20-2016 09:28 AM
@wygonski wrote:I just tried building and writing an array instead of a single-point waveform, but each time the array was written to the file, t0 was reset back to 0.0.
That's correct. If you want it to work out of the box, you can only do a single array write once you have all of your data. Otherwise, you'll have to keep track of your t0 yourself and add waveforms with the correct t0. How much data are you collecting? Is writing at the end an option? I don't do much with LVM since I like to customize my datafiles quite a bit. Are you tied to LVM or is TDMS an option?
You might also consider just eliminating the time column since you know your data set is equally spaced.
06-21-2016 01:58 PM
The application requires streaming the data to the file continuously until the user clicks "Done", so the amount of data to save is unknown. For that reason, I'm using the single-point write approach and I'm keeping t0 updated. Thanks for confirming the behavior of the array write.