修改PLCnext时间

目录

一:默认时区

二:在控制器中修改系统时间

Setting via PLCnext Engineer

Setting via shell

三:Using the NTP client

Setting via PLCnext Engineer

Setting via shell

Additional information

四:Using NTP and time settings via PLCnextBase library

五:NTP client configuration via WBM

六:Sync time with NTP server on AXC F 2152

七:Time sync through a proxy-server


一:默认时区

所有 PLCnext 控制设备默认设置为 UTC0,即协调世界时 (UTC) 的 UTC±00:00。

注意:由OPC UA or DataLogger创建的时间戳始终为 UTC0。
​​

二:在控制器中修改系统时间

Setting via PLCnextEngineer

您可以通过PLCnext Engineer软件设置系统时间。使用PLCnext Engineer进行访问需要使用用户名和密码进行身份验证。.

Defining RTC parameters

  • In the PLANT area, click on PLCnext.
  • 在 Online Parameters页签, 选择Real time clock.
  • 在相应的输入框中输入想要的值(格式见圈内的ℹ)

在PLCnext Engineer导航栏中使用Clock button

通过时钟按钮,可以将主机当前系统时间写入控制器的实时时钟中,作为控制器的UTC0时间。

注意:控制器将忽略任何给定的偏移量或时区! 

目前,在 PLCnext 设备上使用 UTC0 或特定时区(自动切换到/从夏令时)的唯一方法是使用PLCnextBase library中的 PLCnextBase 库。  

Setting via shell

您还可以通过 shell 手动更改系统时间。 SSH 访问 shell 需要使用用户名和密码进行身份验证。 具有管理员权限的访问:

  • User name: admin
  • Password: 印在controller上

请求系统时间

  • Open the shell.
  • 通过date命令请求系统时间。

Setting the system time

  • 输入shell命令 sudo date -s "YYYY-MM-DD hh:mm:ss", with
    • YYYY: Year
    • MM: Month
    • TT: Day
    • hh: Hours
    • mm: Minutes
    • ss: Seconds

三:Using the NTP client

可以连接到网络时间协议(NTP)服务器或启动自己的服务器。

NTP服务器可以通过PLCnext Engineer和RSC服务配置。

Setting via PLCnextEngineer

  • In the PLANT area, click on PLCnext
  • In the Online Parameters tab, select the NTP section
  • 在输入栏中最多输入3个NTP服务器(以空格隔开)
  • 重新启动PLCnext设备,使更改生效

Setting via shell

ntpd (Network Time Protocol daemon) 来自 Network Time Protocol project (see ntp.org) 被集成到操作系统中.

  • 以Admin用户登录控制器,具有修改数据的权限。
  • 进入 /etc/ 目录.
  • 在“ntp.conf”配置文件中输入IP地址和名称
    注意:WBM也使用相同的文件。
  • 通过执行重启NTP守护进程 sudo /etc/init.d/ntpd

Additional information

四:Using NTP and time settings via PLCnextBase library

设置系统时间的另一种方法是 PLCnextBase library,它在 PLCnext Store 中免费提供,无需许可证。 将此库导入 PLCnextEngineer 后,它提供了一些有助于开发基于 PLCnext 的自动化解决方案的函数、功能块和程序。 它附带导入和设置说明,以及 IEC 61131-3 接口和所有组件的详细说明。

对于系统时间,PLCnextBase library依赖于本机 Linux 功能。 在 PLCnext Engineer 中导入此库后,您可以通过读取时区以及与 UTC 的本地偏移量来使用本地时间设置,并自动切换。

Note: Time stamps created by OPC UA or DataLogger are always UTC0. 

五:NTP client configuration via WBM

Available from 2022.0LTS

NTP 客户端能够配置通过Date and TimeWBM页面.

六:Sync time with NTP server on AXC F 2152

This tutorial will shortly explain the steps to set the current ntp time for UTC. This is very useful when the PLC sends TSD data to PROFICLOUD and far superior to the hand-set version!

This assumes that you are not behind a proxy-server! When you are behind a proxy server your company has to provide their own ntp server (which address you must then use in this tutorial. If  you are behind a proxy-server and your company does not provide ntp, then jump to the end of this document to see a non-ntp version for time synchronization!

Connect to the PLC via SSH.

Become root by entering the command “su” (this will ask for the password, which is written on the PLC)

Check the timezone using the following command. It should show “Universal”.

Now we need to configure ntp by editing the file “/etc/ntp.conf” and add the lines

server timeserver.europe.phoenixcontact.com

server pool.ntp.org

Save the file. The address pool.ntp.org will forward to the ntp server which is closest to you.

Now stop (!) the ntp daemon:

/etc/init.d/ntpd stop

We can now synchronize time using the following command:

ntpd -qg && hwclock -w

We can now check the date with the command “date” and compare it to the current UTC time (e.g. UTC - exact time now - Time.is)

Now we can schedule a crontab to regularly update the time. Edit the file “/etc/crontab”. Since we must stop the ntp daemon beforehande we need to add the following line to update the time at system start:

@reboot root /etc/init.d/ntpd stop && ntpd -qg && hwclock -w

Then, for an hourly update, also add the line:

1 * * * * root ntpd -qg && hwclock –w

to the file and save it.

Enjoy!

七:Time sync through a proxy-server:

To synchronize time behind a proxy-server and without company ntp server, just add the following 2 lines to the /etc/crontab file (instead of the above):

@reboot root date -u --set="$(curl -H 'Cache-Control: no-cache' -sD - http://google.com |grep '^Date:' |cut -d' ' -f3-6)"

1 * * * * root date -u --set="$(curl -H 'Cache-Control: no-cache' -sD - http://google.com |grep '^Date:' |cut -d' ' -f3-6)"

This assumes that you configured the proxy server (if any) in the environment variables. See the proxy-tutorial for more information on dealing with proxy-servers!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Proficloud&Greenpro

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值