LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Building array with timestamp/time elapsed and using write to file VI

Solved!
Go to solution

Hello All!

I'm building an 2D array with a dial indicator and meter inputs and would like to add a timestamp to each index/reading.  I have been playing around with format date to number but additionally I would like to make it total time since start or button press. I'm planning on using this event case to trigger a time reset for a new sample to be tested but I get the feeling after reading other forum post that there might be a better way to arrange my array building process. I have also looked into clusters, but I am rather new at LabVIEW so any ideas, directions, or alternative methods would be appreciated. 

King133x_0-1646836620038.png

I am also curious on if I could just use the write to file VI to include a time stamp per column (within configure write to properties) 

 

King133x_1-1646838186773.png

 

the problem with this I wouldn't be able to tell when samples start and stop. This seems to hold a lot of data in buffer and outputs it all even from previous runs. (see data) also does not include enough resolution. 


0.000000,-0.001000,5.727200E-13    First index?  also resolution not used
1.000000,-0.001000,5.731080E-13
0.000000,-0.001000,5.727200E-13     repeats?
1.000000,-0.001000,5.731080E-13
2.000000,-0.001000,5.730780E-13
0.000000,-0.001000,5.727200E-13      either repeats or kept data from last run and this is new data. (i only ran and stopped for a few seconds.) 
1.000000,-0.001000,5.731080E-1

 

 

 

I don't need to know the real world time but it would be nice and so this gave me the idea of maybe I can add a time elapsed since started and add it to my 2d array with append array and some conversion VI's.

 

S.SSS, xxxxx, xxxxx


TLDR: Im trying to create an ideal loop the would collect data every second or so and when button is pressed the array starts building fresh with time since started in seconds, this should be reset so the next sample doesn't have time continued from the first set. Data is coming in continuously 

 

Thanks in advance for any help provided! LabVIEW has been tons of fun learning and I appreciate the expedited assistance by the LabVIEW grandmasters on these forums.  

 

0 Kudos
Message 1 of 5
(1,154 Views)

I like to use the "high resolution relative seconds" to see how much time has elapsed. You might have to install "hidden gems" on VIPM in order to see this.

 

When you write data to file it is being appended (added on) to the file. If you want to start a new file every time you run the VI you should generate a unique file name, or set append to "false" the first time data is written, which would delete all of the data from the previous run.

0 Kudos
Message 2 of 5
(1,115 Views)

Thanks i have replaced these with the high resolution version 

0 Kudos
Message 3 of 5
(1,097 Views)

@King133x wrote:

Hello All!

I'm building an 2D array with a dial indicator and meter inputs and would like to add a timestamp to each index/reading.  I have been playing around with format date to number but additionally I would like to make it total time since start or button press. I'm planning on using this event case to trigger a time reset for a new sample to be tested but I get the feeling after reading other forum post that there might be a better way to arrange my array building process. I have also looked into clusters, but I am rather new at LabVIEW so any ideas, directions, or alternative methods would be appreciated. 

King133x_0-1646836620038.png

I am also curious on if I could just use the write to file VI to include a time stamp per column (within configure write to properties) 

 

King133x_1-1646838186773.png

 

the problem with this I wouldn't be able to tell when samples start and stop. This seems to hold a lot of data in buffer and outputs it all even from previous runs. (see data) also does not include enough resolution. 


0.000000,-0.001000,5.727200E-13    First index?  also resolution not used
1.000000,-0.001000,5.731080E-13
0.000000,-0.001000,5.727200E-13     repeats?
1.000000,-0.001000,5.731080E-13
2.000000,-0.001000,5.730780E-13
0.000000,-0.001000,5.727200E-13      either repeats or kept data from last run and this is new data. (i only ran and stopped for a few seconds.) 
1.000000,-0.001000,5.731080E-1

 

 

 

I don't need to know the real world time but it would be nice and so this gave me the idea of maybe I can add a time elapsed since started and add it to my 2d array with append array and some conversion VI's.

 

S.SSS, xxxxx, xxxxx


TLDR: Im trying to create an ideal loop the would collect data every second or so and when button is pressed the array starts building fresh with time since started in seconds, this should be reset so the next sample doesn't have time continued from the first set. Data is coming in continuously 

 

Thanks in advance for any help provided! LabVIEW has been tons of fun learning and I appreciate the expedited assistance by the LabVIEW grandmasters on these forums.  

 


I can't open your vi because I'm not yet on LabVIEW 2021 (it is usually a good idea to use Save for Previous and go back at least a couple of versions for code that you're uploading to the forum) but I do see one potential issue. Depending on what other events that you have in your event structure there could be gaps that are longer than 1 s.

0 Kudos
Message 4 of 5
(1,075 Views)
Solution
Accepted by topic author King133x

Thanks for the advice! I tried the oldest version and crashed so just let me know what version you would like/recommend is most common. 

 

I have also solved some of my own questions and found that every time the express VI is called it creates a segment and since I wasn't clearing my arrays every iteration/sample it had included every version of my array...if that makes sense. so I started over with my design....

 

I ended up sticking with shift registers and event structures to clear and build my array. I also learned that I Don't need to add an index to the insert into array function. This fixed my multiple segment and repeat problem. i also made it so every time I press down the file is appended with a comment and the array reset.

King133x_0-1647011290262.pngKing133x_2-1647012202204.png

 

 

I do agree that my timing needs work. 

 

I don't mind if the timing of my other loops are losing a few seconds unless they are way off (since there is real world measurements coming in) but I not really sure how I would synch them. IM using crossrulz serial port read (thanks!) and i have a continuous visa read loop (for capacitance bridge) both are outputting to a local variable as fast as I can tune it while allowing enough time for data to be read. 

King133x_1-1647011431234.png

 

0 Kudos
Message 5 of 5
(1,073 Views)