LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

strange behavior from timestamp

Hello,
 
I have noticed some interesting behavior with regards to the "Get time in seconds" function.  As I understand it, this function queries the computer's clock and returns a timestamp data type. 
 
I have an application which runs this function once per second and updates a front panel indicator.  This timestamp is then correlated to a timestamp I read from a file, and a control / data acquistion sequence is run when the two timestamps match (to within 1sec).  In order to force the acquisition sequence for debugging, I change the time on the computer's clock -- it's easier than going into the file and changing the timestamp there.
 
If the application is running when I change the computer's clock, the "Get time in seconds" function ignores the change.  Why?  For instance, let's say the time when I started the application was 01:23:30.  The "Get time in seconds" function returns 01:23:30, 01:23:31, etc.  If I change the computer clock, while my application is running, so that it reads, say, 02:20:00, the "Get time in seconds" function returns 01:23:32, 01:23:33, etc.  It does not seem to know that I've changed the computer clock.  If I stop the application and re-start, the time stamp returned by "Get time in seconds" once again matches the computer clock.
 
Why does this happen?  What is this function really doing?
d
0 Kudos
Message 1 of 15
(3,775 Views)
What LabVIEW version are you using?
If just tested the following code in 8.5.1 and it works as expected:

The timestamp is updated while I run this VI to the actual computer time.

Ton


Message Edited by TonP on 07-10-2008 07:50 PM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 15
(3,768 Views)
I see the correct behavior in 8.2 as well.
0 Kudos
Message 3 of 15
(3,760 Views)

I'm using LV 8.5.1.  The time stamp function is located inside a loop which updates once per second (I borrowed a timer function that I found in another discussion forum and modified it to do what I wanted), so no event structure involved.

Here is a screen shot of the guilty snippet of code...anything obvious that you can see?

d

0 Kudos
Message 4 of 15
(3,758 Views)
First your loop will run every 100 ms.

Then what's inside the GetTime function?

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 5 of 15
(3,749 Views)

Ignoring for the moment that the notifier is currently set to 100msec...here is a screenshot of the main program.  The upper loop does all the actual work...the bottom loop just tracks the time and updates the front panel.  Neither of the timestamp functions that you see register the change in the computer clock.  The function in the bottom loop labeled "Time Stamper" is one I found on one of the discussion forum threads and modified to fit my needs.  I can post a screenshot of that one too if you want.

Thanks...

d

0 Kudos
Message 6 of 15
(3,749 Views)
The "get time" function just converts the timestamp into a string for display.
0 Kudos
Message 7 of 15
(3,746 Views)
OK, now I'm confused. First you were talking about the built-in function in LabVIEW. Now it seems that you're talking about a subVI that's not returning the right time.

Please post your code so we can run it ourselves.
0 Kudos
Message 8 of 15
(3,745 Views)
Here you go...
0 Kudos
Message 9 of 15
(3,742 Views)
Your get time function gets the initial time, and then adds to it based on tick counts.  So your code takes 1:20:30, then adds one second to it to get 1:20:31, it doesn't poll the system clock to get 1:20:31.  Instead of using a shift register and adding like fifteen math functions, just use a Get Date/Time in Seconds, and pass it into Get Date/Time String. 
 
Also, your First Call? into a shift register is unused, so it's needlessly taking up memory and cycles.  Try something like this. 
 
edit - here's one with your wait function, also


Message Edited by JeffOverton on 07-10-2008 02:33 PM
Download All
Message 10 of 15
(3,734 Views)