This program example deals with two special operations for the real-time clock: reading and writing the date and time of day. For these operations, the program needs an 8-byte buffer with the following structure:
| Byte 0: | Year (00 - 99) | Byte 4: | Minute (00 - 59) |
| Byte 1: | Month (1 - 12) | Byte 5: | Second (00 - 59) |
| Byte 2: | Day (1 - 31) | Byte 6: | Not assigned |
| Byte 3: | Hour (00 - 23) | Byte 7: | Day of week (1-7 = Su-Sa) |
The data is stored in binary-coded decimal (BCD) format (for reading or writing). When you operate the switch at input I0.0, the preset date is written to the real-time clock. The switch at input I0.0 displays the current second value, which is copied to output byte QB0. Use the switch at input I0.1 to select BCD format (I0.1 = 1) or binary format (I0.1 = 0).
The time-of-day clock in the S7-200 uses only the least significant two digits for the year, so for the year 2000, the year will be represented as 00. The S7-200 does not use the year information in any way and will not be affected by the century rollover (year 2000).

Program Flowchart :
Download Project Example :
















