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

  • MVP 2023

Swap the reset and set locations of update and set time in your shown 3rd rung? 

Why use so many set/resets in the first place?  For me I always try to use the least possible, as expected sequencing often goes astray due to things changing in one scan.

cheers, Aus

  • Like 1
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

Panel and CPU should have different IPs.

UDFB is running from Ladder, so it use CPU IP, which should be set up.

CPU and Panel use an internal LAN switch, which is presented outside as 1 or 2 LAN ports.

You can use any method you find good for time correction.

B. R. 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.