Topic: DMD0222 Managing the Date and Time in a Do-more Controller |
|
Current Date and Time Stored as UTC TimeThe current date and time in the Do-more controller is internally stored
as a UTC (Coordinated Universal Time) value. The UTC value is the number
of seconds that have elapsed since a particular point in time. Do-more
controllers use the 1970 Epoch - which began at
There are three predefined locations in the controller that contain
UTC-centric time values, they are:
While it is true that storing timestamps in native UTC form can be very useful (they only consume a single DWord location), viewing the UTC values native form is not all that useful. The Data View has a display format called '1970 Epoch' which will display a UTC value in human-readable form (DD-MMM-YYYY Day Hour:Minute:Second).
In the Data View below, the first entry is $UTC in native format, the second is $UTC displayed in the 1970 Epoch format. At the end are similar entries for $LocalTime.
|
|
System and User Date/Time StructuresThere are two predefined memory blocks of Date/Time structures, they are SDT0 - SDT7 (System Date/Time) which contain system generated date and time values, and UDT0 - UDT31 (User Date/Time) which the programmer can use in the ladder logic project to for runtime management of date and time and values.
Date/Time structures have the following members: .Year
- contains a 4-digit number representing the year .Month
- contains a value 1 to 12 representing the month (1 - January, 2 - February,
...12 - December) .Day
- contains a value from 1 to 31 representing the day of the month .DayOfWeek
- contains a value from 0 to 6 representing the day of the week (0 - Sunday,
1 - Monday ... 6 - Saturday) .Hour
- contains a value from 0 to 23 representing the hours .Minute
- contains a value from 0 to 59 representing the hours .Second - contains a value from 0 to 59 representing the hours
There are three predefined System Date/Time structures: $Now
- (SDT0) - which contains the system-generated current date and time value,
including adjustment for time zone and daylight savings time. $SysShutdown
- (SDT1) - contains the date and time when the controller was last powered
OFF. $SysStartup
- (SDT2) - contains the date and time when the
|
|
Converting between UTC values and Date/Time StructuresDo-more controllers have two instructions
that make converting UTC time values to Date/Time structures and vice
versa very easy, they are:
Performing MATH-style operations on Date/time Structures
Setting the Clock at Runtime
|
|
See Also:
|
|