LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delta t not updating using Write to Measurement file

Solved!
Go to solution

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:

WriteToMeasurementFile.jpg 

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:

 

WriteToMeasurementFile2.jpg

 

What am I missing?   

 

Thanks,

John 

0 Kudos
Message 1 of 10
(4,626 Views)
Hi John,

so you create a waveform (in a funny way) with t0 always being zero - and you wonder about zeros in your file?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(4,616 Views)

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.

Message 3 of 10
(4,615 Views)

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

 

 

0 Kudos
Message 4 of 10
(4,609 Views)
Solution
Accepted by topic author wygonski

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".

Message 5 of 10
(4,583 Views)

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:

WriteToMeasurementFile3.jpg

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.

 

0 Kudos
Message 6 of 10
(4,563 Views)

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.

0 Kudos
Message 7 of 10
(4,556 Views)

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

Message 8 of 10
(4,511 Views)

@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.

Message 9 of 10
(4,507 Views)

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.   

0 Kudos
Message 10 of 10
(4,484 Views)