Time sync a PAC Controller with an Internet time server

Like most microcontrollers / PLC’s, the PAC Controller uses a real time chip for its date/time functions.
That chip will have some drift in its accuracy due to lots of reasons, not the least of which is temperature.
Thus, over time, the clock will be off by some amount.

If you are running PAC Display all the time, there is an option under the ‘Configure’ -> ‘Runtime’ -> ‘Control Engine’ tab to allow you to synchronize the control engine clock with the PC clock every day or so.
Also, when you double click on a control engine with PAC Terminal, there is an option there to click a button to ‘Sync time to PC’.
But what if you do not have PAC Display running all the time on the same network as the controller, then what?
Well, thanks to the Ethernet connectivity smarts built into PAC controllers, you can, if you have Internet connectivity from the PAC, connect with a time server on the Internet and sync the clock from there… Here is a chart to do just that…

This is a screen shot of the chart we have been using for a while to do the time sync.

A quick over view shows that it checks to see if its 3am, and if so, open a comm handle with the NIST server, get the string back from it, parse it, convert the string to numbers and then use those numbers to set the clock.
Thats it.
Note, its critical that you have a gateway IP address set in the controller so it can find its way out to the net. (Set it in PAC Manager).

I have exported the chart from PAC Control Basic, ver 8.5 and attached it to this thread.
Just unzip the file once you download it and you will be ready to go.
All the variables are prefixed with ‘time_’, so it should be clear which ones are used in this chart.
With a bit of tweaking, there is no reason why this chart could not be made to work in Factory Floor.

If you have any other ways to do this important function, please let us all know.

Code on!

Just a heads up to all you time lords out there (my 16 year old son has just discovered Dr Who)…

PAC Project 9.2 now includes a whole raft of really cool (and time saving) time commands and capability, here is a list;

• Set Time Zone Configuration
• Get Time Zone Offset
• Get Time Zone Description
• Synchronize Clock SNTP
• Convert Date & Time to NTP Timestamp
• Convert NTP Timestamp to Date & Time

So, I am really happy to send the post and chart above this post into the distant past and leave it there!
(Face it, it was a hack that now we can happily live with out!)

I for one welcome our new time commands!

Hey Ben, is there a way to synchronize the clocks to the PC time? In our applications, the controllers are connected to a VLAN, so they are isolated in that network. The computer running the PAC Display, has internet connectivity. Is there a way to sync the controller time to the PC time?

There’s this little program [click here], which you could have PAC Display launch (it will connect to your Ethernet-based controllers to sync time to your PC). Would that help?

It might. How does it work? I tried running it but I get:
device at ip|tcp:10.192.54.70:22001 timed out waiting for TCP/IP connect
device at ip|tcp:10.192.54.79:2001 timed out waiting for TCP/IP connect
device at ip|tcp:10.192.54.48:22001 timed out waiting for TCP/IP connect
device at ip|tcp:10.192.54.42:22001 timed out waiting for TCP/IP connect
device at ip|tcp:10.192.54.71:22001 timed out waiting for TCP/IP connect

Looks like you were using the default file: “device_list.txt” which includes some instructions. You’ll need to change that to list the IP addresses, etc., of your controller(s) instead.

Ok, I read the document, I modified the ip addresses. I have one question, what is the difference between the line that begins with “t” and the line that begins with “c” in the device_list.txt? I do not understand what these do. Thanks for the help.

I think I must be missing something…

You say you have PAC Display running??

In PAC Display Configurator, click on Configure -> Runtime, then ‘Control Engine’ tab.
Tick the box that says ‘Synchronize Control Engine Clocks to PC Clock’.
Save and run.

Done.

Am I missing something?

The computer in the plant does not allow most operators to exit the PAC Runtime program. The menu bar is hidden, so all they see is a full screen of the PAC Display. The synchronization has to happen without human intervention. This becomes a problem when Daylight Savings Time happens because now either the allowed operators or us engineers have to manually go in and click on ‘Synchronize Control Engine Clocks to PC Clocks’ on every deployed controller. If an alarm happens to go off while the clock is out of sync, then it becomes hard to pinpoint when it really happened.

Ok, sounds like its going to work a treat…

In config, its a one time set up. You tick the box and you don’t have to go back into config ever again.
The tick box tells Runtime that it has to do the time sync function.
It will synch all the controllers at the time you set up with no operator intervention.
Simply set it up for 2:01 am 7 days a week, and daylight savings will be automatically taken care of.

Sorry to give the impression that it was a one time only event. It happens as per the times and days you set up in that config box.

Cheers.

This might work like a charm then.

Resurrecting an old thread…

Any suggestions for synchronizing to a PC clock automatically when not running PAC display and not having access to internet? Have multiple SNAP-PAC-S1’s with an Ignition SCADA.

Andy

Hello Andy,

There’s also this little utility which I just tested w/my -R1 (would be the same with your -S1). It does the same thing as the “Sync time to PC” in this inspect dialog (see before/after times).

In that zip file, see the “device_list” text file for some instructions. Just edit that file for your IP address(es) and time interval.

Happy syncing!
-OptoMary



Thanks Mary,

Looks like that works!

Andy