Real-time clock - example
The BX Controller features a real-time clock. The current time can be read via a function block. The following example will illustrate this.

FUNCTION_BLOCK RTC
VAR_INPUT
EN :BOOL;
PDT :DT;
Legend
EN: Rising edge sets the time to the value available at the PDT input.
PDT: Date and time to be set.
VAR_OUTPUT
Q :BOOL;
CDT :BOOL;
Legend
CDT: Current time.
Required libraries:
- TcSystemBX.lb6
- TcBaseBX.lb6
Download sample ST program (sample file)
PROGRAM MAIN
VAR
fbTimer: TON;
fbRTC: RTC;
END_VAR
fbTimer(PT:=t#60s,IN:=NOT fbTimer.Q);
IF fbTimer.Q THEN
fbRTC;
END_IF
![]() | Do not call the RTC function block in every PLC cycle Calling the RTC block increases the cycle time by approx. 5 ms, due to the data conversion into a TIME AND DATE variable. The function block should therefore not be called during each PLC cycle. |