我們的品牌

Impact-Company-Logo-English Black-01-177x54

歡迎造訪施耐德電機全球網站

歡迎訪問我們的網站
		
我们今天能为您提供什么帮助?
In the M580 CPU, why does the system word %SW51 (RTC Hour) show a different value?

Issue
In the M580 CPU, why does the system word %SW51 (RTC Hour) show a different value than Local Time or UTC?
How do I extract the value of the current local time hour from an M580 PLC's Runtime Clock (RTC) in a program?

Product Line
Modicon M580

Environment
EcoStruxure Control Expert
Unity Pro

Cause
There is a new behaviour of %SW51 in M580 platform compared to the previous M340 generation of PLC. The local time Hour is not represented in %SW51 in the M580. You will see the UTC time (Coordinated Universal Time) in %SW51 of M580 CPUs.


Resolution
The local time can be read using the RRTC_DT function.

The RRTC_DT function returns the date and time in DateTime Type format.

This value can then be converted to an Array of 4 INTs using the DT_TO_ARINT function block which will contain the following values in BCD format:
PLC_TIME_ARRAY[0] = 16#SS00
High Byte = Seconds
Low Byte = (not used) returns 0

PLC_TIME_ARRAY[1] = 16#HHmm
High Byte = Hour (24h format)
Low Byte = Minutes

PLC_TIME_ARRAY[2] = 16#MMDD
High Byte = Month of the year
Low Byte = Day of the month

PLC_TIME_ARRAY[3] = 16#YYYY
Whole INT = 4 digit Year

These 4 INTs are structured in the same way as %SW50 to %SW53 in the M340 where the High and Low Bytes contain separate information on the date and time data.

[Simple Example]
To extract just the Local time Hour value using the RRTC_DT function, see the screenshot below as an example:
The value from the DT_TO_ARINT array of INT variables is originally in BCD format and must be converted from BCD to INT. Then the left-most two digits represents the local time hour, which can be extracted by dividing the BCD value by 100 (with no remainder using the DIV function).

Simple Ladder Example to get only the Local Hour

The value from the DT_TO_ARINT array of INT variables is originally in BCD format and must be converted from BCD to INT. Then the left-most two digits represents the local time hour, which can be extracted by dividing the BCD value by 100 (with no remainder using the DIV function).

To extract all 6 values of the Date and Time, see below for full implementation in both Ladder Logic (LD) and Function Block Diagram (FBD) languages:

[Ladder Logic Code]
Required Variables:Required Variables
Note that in the first rung, we need to write the output of the RRTC_DT function block into an intermediary Variable (PLC_DateTime) of type DT before writing it to the IN Pin of DT_TO_ARINT. This is a requirement in the Ladder Logic programming of Control Expert for this data type.
LD Code Part 1
LD Code Part 2

When run in the Simulator, the Runtime Clock is the Windows Clock:
LD Simulation 1
LD Simulation 2


[FBD Language Example]
Implemented in FBD, there is no longer a requirement for these highlighted Variables:Highlighted Variables not required for FBD
The intermediary BYTE variables containing the BCD values are not required because we can just use lines across more Function blocks in FBD language.
And same with the PLC_DateTime (DT type) variable is not required in FBD.

Meaning a smaller subset of Variables is required:FBD Required Variables

Using the identical logic as in the LD language example translated to FBD, the code would appear as follows:
FBD Code

When run in the Simulator:
FBD Simulation

These sections can be downloaded from this FAQ's attached "RRTC_DT_Example_SRs.zip" file.
In the zipped file, there are two files:
RRTCDateTimeExtract_FBD.XBD - Function Block Implementation Example
RRTCDateTimeExtract_LD.XLD - Ladder Logic Implementation Example

They can be imported individually into your EcoStruxure Control Expert application by right clicking under Project Browser > Programs > Tasks > MAST > Logic:
Import Logic


To see more information about the System Words, please see:
EcoStruxure™ Control Expert - System Bits and Words, Reference Manual
https://www.se.com/ca/en/download/document/EIO0000002135/

To see more information about the RRTC_DT function block, please see:
EcoStruxure™ Control Expert - System Block Library
https://www.se.com/ca/en/download/document/33002539K01000/

To see more information about the DT_TO_ARINT and BCD_TO_INT function blocks, please see this guide:
EcoStruxure™ Control Expert - Standard Block Library
https://www.se.com/ca/en/download/document/33002519K01000/


施耐德電機Taiwan

附件
RRTC_DT_Example_SRs.zip [4.22 KB]
探索更多
系列:
探索更多
系列:

需要協助?

  • 產品選型工具

    快速輕鬆地為您的應用找到合適的產品和附件。

  • 取得報價

    立即線上提交您的銷售需求,專業團隊將主動聯繫您。

  • 購買地點

    輕鬆在您所在地區找到最近的施耐德電機經銷商。

  • 支援中心

    在同一位置找到滿足您所有需求的支援資源。

  • 產品文檔
  • 軟體下載
  • 產品選型工具
  • 產品替代和替換
  • 幫助和聯絡中心
  • 尋找我們的辦公室
  • 取得報價
  • 人才招募
  • 公司簡介
  • 舉報不當行為
  • 無障礙
  • 新聞中心
  • 投資者
  • 專業洞察
  • 台灣施耐德電機學院
  • 綠色影響力落差調查
  • Schneider Go Green 2025
  • 隱私政策
  • Cookie通告
  • 使用條款
  • Change your cookie settings