# RTC

Instructions · `RTC` · verification: source checked

RTC is a function block that calculates elapsed time since a given start time. On a rising edge of EN, CDT is set to PDT and starts increasing; on a falling edge, CDT is set to DT#1970-01-01-00:00:00. It can also return the current date and time by setting PDT to the current local time on the rising edge of EN.

## Specification

| Property | Value |
|---|---|
| Language | structured text |
| Code | RTC |
| Group | Function block |
| Syntax | RTC(EN:=VarBOOL1, PDT:=DT#2006-03-30-14:00:00, Q=>VarBOOL2, CDT=>VarTimeCur); |
| Dialect |  |

### Parameters

| Name | Data type | Description |
|---|---|---|
| EN | BOOL | Rising edge: CDT is set to PDT and CDT starts increasing. Falling edge: CDT is set to DT#1970-01-01-00:00:00. |
| PDT | DT | Preset date and time |
| Q | BOOL | TRUE as long as CDT is counting |
| CDT | DT | Date and time, elapsed since PDT |

## Safety

- The counter overflows on 7 February 2106.

## Study notes

- With PDT set to DT#1970-01-01-00:00:00 or left unconnected, RTC can be used as an operation hour counter.
- To return the current date and time, set PDT to the current local time on the rising edge of EN.

## Sources

1. [CODESYS Group](https://content.helpme-codesys.com/en/libs/Standard/Current/Miscellaneous/RTC.html) (accessed 2026-10-26)

---

Source page: https://machineschema.com/instruction/iec-rtc  
JSON: https://machineschema.com/instruction/iec-rtc.json  
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite Machine Schema and the original sources.
