LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timestamp output

Hello,
 
I am having a problem outputting a timestamp to an text file with a sampled analog input at a high sampling rate. The millisecond behavior of the output seems to not be functioning correctly and will hold at discrete time values for multiple stamps before "jumping" to its next time value and holding there once again as such for millisecond output:
.843
.843
.859
.859
.859
.859
.859
.859
.859
.859
.875
.875
.875
.875
.875
.875
.875
.875
.890
.890
.890
 
I have attached a basic vi that created the above output. I am using the basic Get Date/Time In Seconds command.
 
A second question is if there is any sample code available for a triggered start measurement on the computer clock's hour?
 
Thanks in advance,
Nick
0 Kudos
Message 1 of 6
(3,988 Views)
I think what you're seeing here, is simply the limited resolution of the millisecond timer   ~ 15 ms. 
0 Kudos
Message 2 of 6
(3,981 Views)


Anthony de Vries wrote:
I think what you're seeing here, is simply the limited resolution of the millisecond timer   ~ 15 ms. 

That is correct (although it's actually ~16 ms). If you want to get better resolution, you can use the tick counter, which has a 1 ms resolution. Since it doesn't return absolute time, you will need to take the absolute time and the tick count value at the beginning of your program and then substract that from the current value of the tick counter to find out how many ms passed. You can then use the string formatting functions to format your time string.

___________________
Try to take over the world!
0 Kudos
Message 3 of 6
(3,978 Views)
Thanks guys. I had a feeling it might be something with resolution but figured that 15/16 milliseconds was kind of an odd threshold. I think I will put the original timestamp as a header in the output file and use the tick count thereafter and figure it out later in postprocessing.
 
As for my second question, is there any sample code to trigger the start to a loop when there is an hour change on the computers clock?
 
Thanks again in advance,
Nick
0 Kudos
Message 4 of 6
(3,968 Views)


Electramotive wrote:
As for my second question, is there any sample code to trigger the start to a loop when there is an hour change on the computers clock?
 


You basically need a while loop with a shift register.  The shift register holds the previous timestamp.  Compare the new timestamp with the last to see fi the hour has changed.  (There are functions on the timing palette to break out the hour).  If the hour has changed, execute the loop that is running within a case structure.  Feed the new timestampe into the shift register.
0 Kudos
Message 5 of 6
(3,958 Views)

Another option would be to read the time, and then calculate how many second you have to wait till the next whole hour.   Then put that value in a time delay vi.  

This has the advantage that you don't need to keep polling with a while loop.   Disadvantage is that you can't properly abort the operation.

There's a solution for the latter...  In the program I'm editing currently, I use the same approach, but I use a 'wait for notification' in stead of the 'time delay'.  Make the timeout value the same as the time delay, and you have the same functionality.  But now you can abort the time delay, by sending a notification.   

0 Kudos
Message 6 of 6
(3,938 Views)