PLC Real Time Clock - Daylight Saving |
Name | DaylightSaving |
Basic Function |
A lightweight Function Block to change the PLC Real Time Clock (RTC) forward and backward by 1 hour for daylight saving time (DST) according to rules set in MonthFwd / WeekNoFwd / HourFwd and MonthBack / WeekNoBack / HourBack. This FB will always treat Sunday for DST changes. This accounts for most of Europe and America's. For more information about daylight saving in selected country/timezone see... http://www.timeanddate.com/time/dst/events.html |
|
Syntax | ||
File Name | DaylightSaving.cxf | |
Applicable models | CPU Unit | CP1L/H, CJ1/CS1 (V3 or above), all CJ2's |
Software | CX-Programmer Version 5.0 or higher | |
Conditions for usage | ||
Function Description |
A Function Block (FB) to take account of Daylight Saving time according Month and ‘Week number in Month’ rules. The FB will move the PLC Real Time Clock on by 1 hour at hour 'HourFwd' on the Sunday set in MonthFwd/WeekNoFwd setting – to Summer Time clock setting. At hour 'HourBack' on the Sunday set in MonthBack/WeekNoBack the clock will be put back by 1 hour. If Month/Week/Hour rules apply in a different world timezones, then this FB can be used for southern hemisphere too. The FB only uses the local PLC RTC and conditions set to adjust the RTC. Timezone information is not used/required. |
|
Kind of FB definition |
Stores variables between executions. Use only one instance in a PLC application. |
|
FB Precautions |
For correct operation, this FB should always be ‘Enabled’ (so detection is made correctly). It is also provided with two inputs that will allow manual increment and decrement of the RTC by 1 hour. Internally the FB is executed for one scan at every new hour of the RTC. This means that overall PLC scan time is kept as low as possible. As a minimum the FB must be running on the Sunday specified in MonthFwd/WeekNoFwd at 'HourFwd' and also on the Saturday from 23:59:59 to Sunday at hour 'HourBack' specified in MonthBack/WeekNoBack.
The RTC ‘Day of Week’ must be set correctly. (0=Sun, 6=Sat)
Test fully in own code to ensure correct operation. |
|
EN input condition | Always On |
- Variable Table
Input variables
Name | Variable name | Data type | Default | Range | Description |
EN |
P_On |
BOOL |
Always Enable (P_On) for correct operation. |
||
MonthFwd |
|
UINT |
1-12 |
Month number (1 to 12) to put RTC forward by 1 hour |
|
WeekNoFwd |
|
UINT |
1-4 |
Week number in MonthFwd to put on by 1 hour. Sunday is always used as the day of week to move clock forward. Week number can be 1 to 4. For last Sunday, set 0 |
|
HourFwd |
|
UINT |
1-23 |
Hour number to move forward on specified Sunday |
|
MonthBack |
|
UINT |
1-12 |
Month number (1 to 12) to put RTC backward by 1 hour |
|
WeekNoBack |
|
UINT |
1-4 |
Week number in MonthBack to put back by 1 hour. Sunday is always used as the day of week to move clock backward. Week number can be 1 to 4. For last Sunday, set 0 |
|
HourBack |
|
UINT |
1-23 |
Hour number to move backward on specified Sunday |
|
IncHour |
Force1HrFwd |
BOOL |
Manual increment of RTC by 1 hour upon rising edge. HourForward flag is Set. |
||
DecHour |
Force1HrBack |
BOOL |
Manual decrement of RTC by 1 hour upon rising edge. HourForward flag is Reset. |
Output variables
Name | Variable name | Data type | Default | Range | Description |
ENO |
ENO |
BOOL |
Unused |
||
HourForward |
HourForward |
Retained During Power Off |
Flag to signify if in Daylight Saving mode (NB this flag is only set automatically at MonthFwd/WeekNoFwd and reset at MonthBack/WeekNoBack). Use Manual (IncHour/DecHour) to set initially. |
- Revision History
Version | Date | Contents |
1.00 | 19 March 2012 | First release |