Browse FAQs

In the M580 CPU, why does the system word %SW51 (RTC Hour) show a different value?

Published date: 09 July 2019

Issue
In the M580 CPU, why does the system word %SW51 (RTC Hour) show a different value?
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

Enviroment
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.

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 (in BCD Format) containing:
DateAndTime_ARRAY[1] = 16#SS00  (Seconds)
DateAndTime_ARRAY[2] = 16#HHMM (Hour and Minute)
DateAndTime_ARRAY[3] = 16#MMDD (Month and Day)
DateAndTime_ARRAY[4] = 16#YYYY (Year)

These 4 INTs are structured in the same way as %SW50 to %SW53 in the M340.

Furthermore, to extract the Local time hour 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).


To see more information about the System Words, please see:
EcoStruxure™ Control Expert - System Bits and Words, Reference Manual
https://www.schneider-electric.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.schneider-electric.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.schneider-electric.ca/en/download/document/33002519K01000/

Was this helpful?

What can we do to improve the information ?

Can't find what you are looking for?

Reach out to our customer care team to receive information on technical support, assistance for complaints and more.