Real Time Clock (RTC)

The P2CDS-622 has a battery-backed RTC that will maintain the time for many months without power being applied to the system.

Operation

Set the CPUs Real Time Clock

(1). In the Device Tree, Double-click on the Device(P2CDS622).

A Device tab should appear with the first tab on the left selected entitled Communication Settings selected. Now we need to scan the network (Scan Network) to find our device.

Connect to the device of interest.

(2). In the PLC Shell section of that same view, type in the lower dialogue the command and the current local time as follows: rtc-set YYYY-MM-DDThh:mm:ss.

For example, to set the time to March 4th, 2023 at 1:07pm and 44 seconds, type the following dialog: rtc-set 2023-03-04T13:07:44.

alternate text

The Device connection to the CPU will reset/disconnect after this command, so you will need to reconnect to the CPU.

To verify the time got set correctly, type rtc-get in the dialogue.

alternate text

Access Time in Program

To be able to access the Time-of-Day and do other time measurements, you can install the SYSTimerRTC library.

Further information, refer to CODESYS Help section .

An example project is located at CODESYS site .

Overall, an Excellent detailed reference and example can be found in “SYSTimeRTC” section of Textbook: “The Book of CODESYS”