RTC block

Short summary

Name

RTC

→POU type

→function block

Category

IEC-block, TimerEnh

Conform to →IEC-standard

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/add.svg not defined in IEC-standard

Graphical interface

images/download/thumbnails/414782805/RTC-version-1-modificationdate-1535105176989-api-v2.png

Available since

version 1.20.0 (for logi.CAD 3)

Functionality

This is a real-time clock.

Enter a date and time at input PT. If input IN is →turned on, output CDT returns the current date and time (starting with the date and time entered at input PT). If input IN is →turned off, the real-time clock stops, i.e. output CDT returns the last date and time. Output Q always returns the same value as the input IN.

This block receives the current system time from the runtime system. This time remains constant while the same task is executed. However, in case of different tasks, it is possible that a different system time is used when the belonging programs are executed (even if the different tasks have the same cycle time).

In-/outputs


Identifier

→Data type

Description

Inputs:

IN

BOOL

input/start

PDT

DATE_AND_TIME

preset date and time

Outputs:

Q

BOOL

output

CDT

DATE_AND_TIME

current date and time

Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

See:

Example for usage within ST-editor

PROGRAM Test
VAR
rtc1 : RTC;
rtc2 : RTC;
current_dt1 : DT;
current_dt2 : DT;
END_VAR
rtc1(IN := TRUE, PDT := DT#2014-09-23-10:00:00, CDT => current_dt1);
(* Instance of block 'RTC' is called. Variable 'current_dt1' is set to current date/time starting with 2014-09-23-10:00:00 after the first call. *)
rtc2(IN := TRUE, PDT := DT#1990-01-01-08:00:00, CDT => current_dt2);
(* Instance of block 'RTC' is called. Variable 'current_dt2' is set to current date/time starting with 1990-01-01-08:00:00 after the first call. *)
END_PROGRAM

If the cycle time is 500 ms, the variables are set to the following date and time for the first 4 cycles :

Cycle

current_dt1

current_dt2

1

DT#2014-09-23-10:00:00.000
DT#1990-01-01-08:00:00.000

2

DT#2014-09-23-10:00:00.500
DT#1990-01-01-08:00:00.500

3

DT#2014-09-23-10:00:01.000
DT#1990-01-01-08:00:01.000

4

DT#2014-09-23-10:00:01.500
DT#1990-01-01-08:00:01.500

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.