LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Time column in a file

Hi all,

 

what is the best way to implement a column for time in a file. And I do not mean a timestamp but a column that shows the time elapsed. So if it measures 100 samples per second I would like it to show 100 rows of samples per second.

 

I need my file to be easy to read for data analysis.

 

That is:

1st column: one column for time in seconds

2nd: samples per second

 

Here is my VI.

 

Kind regards,

Emilie.

0 Kudos
Message 1 of 8
(1,330 Views)

Hi Emilie,

 

you forgot to attach your VI.

 


@erabrannan wrote:

I need my file to be easy to read for data analysis.

That is:

1st column: one column for time in seconds

2nd: samples per second


Best would be an example file to show what you want!

 

I would just add one column in front of your measurement data holding the elapsed time value…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(1,311 Views)

@erabrannan wrote:

That is:

1st column: one column for time in seconds

2nd: samples per second

 


can we assume that "samples per second" is constant? So why do you need a second column for boring data. More typical would be  time in the first column and  the sample value in the second column.

 

So you have two columns of data. Can you define "easy to read"? If it should be read by a human later, I would recommend delimited text with tabs separating columns and linefeeds separating rows. If it should be read by another program, consider binary (lossless and fast).

 

How many rows do you expect to have in the end? Do you want to keep everything in memory and write to file at the end or do you want to stream to file while data is measured?

0 Kudos
Message 3 of 8
(1,296 Views)

Here it is!

 

Something like this:

erabrannan_1-1600929862152.png

 

And as you can see if I chose to have 10 samples per second, for samples it will show 10 rows of data for each second along with its corresponding time

 

Could you show me how to code that?

0 Kudos
Message 4 of 8
(1,243 Views)

Hi,

 

yes sorry I meant there should be 100 samples per second, for instance, but the second column would just be the sample value (data). Sorry for the confusion.

 

Sure, I tried binary. I was told to go for either a text extension or TDMS extension.

 

I tried to implement a timestamp as described in: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000PAUbSAO&l=en-GB

 

However, this is not practical for data analysis. I don't want the exact time (day/month/year) and the second column is in a strange formate (why 0.001?) it doesn't include the time elapsed in seconds as I would need.

 

 

0 Kudos
Message 5 of 8
(1,240 Views)

Hi erabrannan,

 


@erabrannan wrote:

And as you can see if I chose to have 10 samples per second, for samples it will show 10 rows of data for each second along with its corresponding time

Could you show me how to code that?


A simple approach would use something like this:

This will only work for low sample rates! It will give errors very quickly when you use the samplerate of 1000S/s as is set as default in your VI…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 8
(1,235 Views)
 

 

 

 

So I tried to change it like this.

 
 
 

 

 

j.png

I changed the sample rate to 10.

This is the file I got:

 

Capture.JPG

I don’t understand why there are more than a 1000 rows of data when I left it on for like 2 seconds. Shouldn’t it be just 20 rows of data? In any case the first column is still not showing me the time? Maybe I coded it wrong?

0 Kudos
Message 7 of 8
(1,225 Views)

Hi,

 

it will be read by either python or excel.

 

But considering it is a couple GB of data, and the TDMS can only be opened by excel, and excel could not open a file that large.

 

I am not sure to figure how many rows it should have. How do you determine that?

 

And write to file at the end.

0 Kudos
Message 8 of 8
(1,213 Views)