LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

saving a timestamp to memory

I want to save a timestamp to memory. I later want to read a new time stamp to see how much time has passed.
0 Kudos
Message 1 of 7
(3,284 Views)
I'm not sure, what you exactly mean by saving a time stamp to memory, but if you want to measure time elapsed since some event it depends on precision your measurents require.
The simpliest is to use LV Date/time function that returns a number of seconds elapsed since 1st january 1904, but precision is low - order of second (system dependent).
Then, there is also Tick Count function in labview - it returns to you the value of interior millisecond counter. You can use this to measure time differences more preciously (precision is about milliseconds and also system-dependent), but pay attention to the fact that the return value of this function cycle inside I32 boundaries.
0 Kudos
Message 2 of 7
(3,284 Views)
My elapsed time does not have to be very accurate. I am measuring time over weeks and as long as it is accurate to several minute I am okay. I know how to use the date/time function. What I don't know how to do is save off an initial date stamp and then compare it the latest date stamp. I am working in LabView 6.0
0 Kudos
Message 3 of 7
(3,284 Views)
There's a couple of ways to do this. One way is get the time outside the while loop and wire the value in through a tunnel. This value won't change until the program is restarted. Another way is to write it once to a shift register. an example would be to put the get date/time inside a case structure and wire the case selector to the iteration terminal. Have it write a new value when iteration is equal to zero and all other cases do nothing.
0 Kudos
Message 4 of 7
(3,284 Views)
Keeping things in memory can be done in numerous ways in LabVIEW; wires, controls and indicators, globals, functional globals, locals, ques etc etc... The wires keep values in memory so if you have read the time and you need it later to subtract it from a new one just wire the old time value to the place in the code where you need it. Now you have to make sure you get the time prior to the start of the operation you want to time, and that the end time is read afterwards...to do that you can control the execution order using data dependancies. In some cases that's easily done just with wires, in other cases it can be useful to use a sequence structure or two...(people new to LV has a tendency to use sequences for everything. The best way to control execution in
LV is by data flow, a single frame sequence can be useful though).

If you want to calculate the time used by n iterations of a loop...use a shift register. Right-click on the border of the loop and select to create a shift register. The shift register is a way to pass data from one iteration to another; when you want to get the start time, read it and write the value to the right hand shift register terminal...Now you can read that value on the next iteration(s) from the left terminal. Put a case around the get time part and only run it when you want a new start time, in the other cases just wire the value from the left to the right shift register terminal.

In the attached example the average time per iteration is calculated every five iterations for a loop containing just a wait function (you would replace that with whatever code you have...).
0 Kudos
Message 5 of 7
(3,284 Views)
Dennis answered you already, so I'm just wondering in case we misunderstand you - what you want to do exactly? Regarding your example vi I see that you try to continuosly save the timestamp in a file on disk - not in memory (yes, this is also possible but slightly other way...)?
0 Kudos
Message 6 of 7
(3,284 Views)
Yes Dennis's suggestions have been very helpful. First I want to log to memory but eventually I want to save this off to disk. The example vi I sent to you was an attempt to log to the disk. I think I should be all set for now.
0 Kudos
Message 7 of 7
(3,284 Views)