Synchronizing clock


Recommended Posts

Now I must synchronize the equipment's clock with the server computer's clock, and then start logging when the time is a multiple of 5 minutes, so that the database starts and logs at 5 min intervals. My starting thought on this is the following:

if((SysTime()/60)%5 > 1)
		 WaitFor((SysTime()/60)%5 < 1)

This is not working, the WaitFor() is not running.

Maybe with WaitUntil() would be better, but then I must get the minutes and do a sun to find what the exact seconds for the next multiple of 5 minutes is.

Link to comment
Share on other sites

WaitFor() takes two parameters, the condition to wait for and how often you want to check for it. So, you want:

waitfor((systime()/60)%5 < 1,1)

Waituntil() is better because there is less latency and it uses less processor time. You can find the next 5 minute point by doing:

floor(systime() / 300) * 300 + 300

so you can do:

waituntil(floor(systime()/300) * 300 + 300)

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.