Time Synchronization


SNAP PAC Controllers and Opto22 EMU have Real Time Clock. WHat are options to synchronize them?

Can i Synchronize them through a GPS Clock through NTP protocol?

Milind Raval

Hi Milind,

You have one stock option and lots more non-stock options for setting the time on the controller.

Take a look at the time commands in the manual. They will show you how (if you have Internet connectivity via a gateway) to set the clock via NTP.
Its as simple as making sure you have a DNS and Gateway IP address configured (use PAC Manager).
Once you have that done, look at the command help, but to get you started here is the command I call once a night;

  time_sync_status = SetTimeZoneConfiguration("PST1,11,0,1,0200/PDT,3,0,2,0200");
  time_sync_status = SynchronizeClockSNTP(5, time_server_url);

The time_server_url is as follows:

Calling it once a day keeps my controller clock accurate to around 1 second or less.
Its kept at a pretty stable temperature, so it does not drift much, so once a day is more than enough.
NOTE! The time zone parameters are for California. You WILL need to change them for you location if its different.

You mention GPS, and this is one of the options you may explore on your system.
What you would do there is to hook a GPS serial port to the serial port on the controller, write some code to parse the GPS data and find the time string, then use that to set the controller time.
If your controller did not have any access to the Internet, then this would be your best option for setting the time. Small GPS units that run off 5v with serial ports (usually around 9600 baud) can be found pretty cheap these days, of course you would need to ensure that you can have a good clear view of the sky to pick up the GPS signal.

Hope that helps, lets know what you end up doing. Its a really interesting topic.



Time Synchronization really a interesting topic.Thanks a lot for sharing this informative thread.