Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How to synchronize vi with system time

Here is something to get you started.  It uses the Wait Until Next ms Multiple like the others suggested.  Click the button and then the VI waits until the specified time is completed and then adds to the array.  This VI uses 1 second instead of 5 minutes to show how it's done.  It's also not perfectly synced to the exact time needed, but you can very easily account for the difference and adjust.  Hopefully this gives you a good place to start...

 

Synch to System Clock.png 

Message Edited by David_L on 01-11-2010 05:43 PM
Message 11 of 12
(2,634 Views)

I finally found the time to look into your code a bit. 

 

Funny thing about labVIEW- it is data flow dependant- so in order to enforce the precidence of actions -or even to keep them in the same thread- you need some data dependance.time unk.PNG

In this image the loop will execute every 5 minutes on the 5 min mark however it is not determined until COMPLIE time when the wait starts in relation to the other functions because there is no data dependance.  In fact there a two threads spawned the wait will start and the rest of the code will execute in a second thread as soon as the loop is entered.  (essentially this same thing is happening in your sequence structure)

time still unk.PNG

This VI works a bit differently,  When the loop starts the time is read but because error in(no error) is not available at the input of the Write to file untill the system clock is at a 5 minute mark the file will not be modified until the wait function is done.  The file is written at 12:00:00, 12:05:00, 12:10:00...etc but the times in the file may be 11:59:59, 12:00:00.001, 12:05:00.001 (that is the file is written with the value of time up to 5 minutes old every time.

 

time known.PNG

This vi has the functionallity you want.  The structure arround the wait function exits every time a 5 minute mark is reached and then and only the does the time get read and written to the file.


"Should be" isn't "Is" -Jay
Message 12 of 12
(2,616 Views)