RTC_EX
The function block RTC_EX (Extended Real Time Clock) allows an internal software clock to be implemented in TwinCAT PLC. The clock must be initialized with a starting date and time. After the initialization the time and date are updated with each call of the function block. A CPU system clock is used to calculate the current time and date. The function block should be called in every PLC cycle, so that the current time can be calculated. At the output of the function block the current date and time are available in the common DATE_AND_TIME (DT) format. In contrast to the RTC function block, RTC_EX has an accuracy of one millisecond. Multiple instances of the RTC_EX function block can be created within one PLC program.
Deviation of the RTC_EX time from a reference time The way the system works means that the RTC_EX time can differ from the reference time. The deviation depends on the PLC's cycle time, the value of the basic system ticks, and on the hardware being used. In order to avoid larger deviations the RTC_EX instance should be synchronized cyclically (e.g. with a radio clock or with the local Windows system time). The local Windows system time you can be synchronized with a reference time via the SNTP protocol. |
Inputs
VAR_INPUT
EN : BOOL;
PDT : DATE_AND_TIME;
PMSEK : DWORD;
END_VAR
Name | Type | Description |
---|---|---|
EN | BOOL | The RTC_EX2 function block is re-initialized with a specified date, time and millisecond by a rising edge at this input. |
PDT | (Preset Date and Time) | |
PMSEK | DWORD | (Preset Microseconds) |
Outputs
VAR_OUTPUT
Q : BOOL;
CDT : DATE_AND_TIME;
CMSEK : DWORD;
END_VAR
Name | Type | Description |
---|---|---|
Q | BOOL | This output is set if the function block has been initialized at least once. If the output is set, the values for the date, time and milliseconds at the PDT and CMICRO outputs are valid. |
CDT | DATE_AND_TIME | Current Date and Time |
CMSEK | DWORD | (Current Milliseconds) The milliseconds output. |
Requirements
Development environment |
Target platform |
PLC libraries to be integrated (category group) |
---|---|---|
TwinCAT v3.1.0 |
PC or CX (x86, x64, ARM) |
Tc2_Utilities (System) |