Jump to content

Update RTC hangs


fmin

Recommended Posts

Hello everybody,
I'm new to the Unitronics world.
I have to synchronize the PLC clock and the idea is to read the time zone and the UTC from the MySQL database and set the time with the Set PLC date/time elements.
However, sometimes the updating functions hang, with the status 1, and date and times are not set.
The tags RtcDateSql, RtcTimeSql and RtcTzFromSql contain the right values, and they are updated correctly everytime RtcQueryTrigger is pulled up.
I have done some test, anyway I wasn't able to find the reason this function sometimes works and sometimes not.
Am I doing something wrong?

The PLC is a USP-070-B08 with the USC-P-B10 CPU, no I/O or COM installed. CPU OS 1.28.35, Panel 1.28.58, UniLogic 1.28.34

Thank you for your attention

Screenshot_20191217_095419.png

Link to comment
Share on other sites

Hi,

Bear in mind, that NTP servers are grouped under some names.

Each name may include number of NTP servers with different IPs.

There is an organization by name "Pool NTP" https://www.pool.ntp.org/

You can find here local or nearest NTP pools.

Some NTP servers or pools may be not active at the time you wish to make time correction, some may be busy at specific time.

So, it is recommended to keep in internal list number of NTP pools, resolve IP of less loaded NTP server , then use it to correct time.

If NTP return error (in most cases returned time is 0xFFFFFFFF as well), repeat request, then repeat IP resolution, and then replace NTP server name from list and repeat until you have good replay.

B.R.

 

It is recommended

  • Like 1
Link to comment
Share on other sites

I have only modified the example function for synchronization with NTP in the example Unitronics package. I suppose the set PLC date/time elements are triggered in several consecutive cycles before RtcUpdate and RtcSetTime are resetted, and this may be bad.

Anyway, I followed your suggestion and I rewrote the function from scratch, now it works perfectly.

Thank you for your help.

[EDIT]

Isakovic & Alex, I prefer use MySQL because is easier to manage the timezone and the DST changes, and, if I understend correctly, I have to use the CPU IP for NTP syncing, and I have the network connection on the Panel IP.

 

Screenshot_20191219_095441.png

Edited by fmin
Add notes on NTP
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...