0% found this document useful (0 votes)
106 views32 pages

Time-Of-Day Functions

This manual provides instructions for time-of-day functions in Siemens S7-1200 and S7-1500 systems, including setting and reading the CPU clock's date and time. It emphasizes the importance of safety notices, qualified personnel, and proper use of Siemens products. Additionally, it outlines the parameters and error codes associated with various time-related instructions, ensuring users can effectively manage time settings in their applications.

Uploaded by

Uhule Peter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views32 pages

Time-Of-Day Functions

This manual provides instructions for time-of-day functions in Siemens S7-1200 and S7-1500 systems, including setting and reading the CPU clock's date and time. It emphasizes the importance of safety notices, qualified personnel, and proper use of Siemens products. Additionally, it outlines the parameters and error codes associated with various time-related instructions, ensuring users can effectively manage time settings in their applications.

Uploaded by

Uhule Peter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Time-of-day functions (S7-1200,

S7-1500) 1

Extended instructions (S7-1200,


S7-1500)

Manual

V20

11/2024
Legal information
Warning notice system

This manual contains notices you have to observe in order to ensure your personal safety, as
well as to prevent damage to property. The notices referring to your personal safety are
highlighted in the manual by a safety alert symbol, notices referring only to property damage
have no safety alert symbol. These notices shown below are graded according to the degree of
danger.

DANGER

indicates that death or severe personal injury will result if proper precautions are not taken.

WARNING

indicates that death or severe personal injury may result if proper precautions are not taken.

CAUTION

indicates that minor personal injury can result if proper precautions are not taken.

NOTICE

indicates that property damage can result if proper precautions are not taken.

If more than one degree of danger is present, the warning notice representing the highest
degree of danger will be used. A notice warning of injury to persons with a safety alert symbol
may also include a warning relating to property damage.

Qualified Personnel

The product/system described in this documentation may be operated only by personnel


qualified for the specific task in accordance with the relevant documentation, in particular its
warning notices and safety instructions. Qualified personnel are those who, based on their
training and experience, are capable of identifying risks and avoiding potential hazards when
working with these products/systems.

Proper use of Siemens products

Note the following:

WARNING

Siemens products may only be used for the applications described in the catalog and in the
relevant technical documentation. If products and components from other manufacturers are
used, these must be recommended or approved by Siemens. Proper transport, storage,
installation, assembly, commissioning, operation and maintenance are required to ensure
that the products operate safely and without any problems. The permissible ambient

2 Manual, 11/2024
conditions must be complied with. The information in the relevant documentation must be
observed.

Trademarks

All names identified by ® are registered trademarks of Siemens Aktiengesellschaft. The


remaining trademarks in this publication may be trademarks whose use by third parties for their
own purposes could violate the rights of the owner.

Disclaimer of Liability

We have reviewed the contents of this publication to ensure consistency with the hardware and
software described. Since variance cannot be precluded entirely, we cannot guarantee full
consistency. However, the information in this publication is reviewed regularly and any
necessary corrections are included in subsequent editions.

Siemens Aktiengesellschaft
Copyright © Siemens 2024.
Digital Industries
11/2024 Subject to change All rights reserved
Postfach 48 48
90026 NÜRNBERG
GERMANY

Manual, 11/2024 3
Table of content

1 Time-of-day functions (S7-1200, S7-1500) 6


1.1 WR_SYS_T: Set time-of-day (S7-1200, S7-1500) 6
1.2 RD_SYS_T: Read time-of-day (S7-1200, S7-1500) 9
1.3 RD_LOC_T: Read local time (S7-1200, S7-1500) 11
1.4 WR_LOC_T: Write local time (S7-1200, S7-1500) 13
1.5 SET_TIMEZONE: Set time zone (S7-1200, S7-1500) 17
1.6 SNC_RTCB: Synchronize slave clocks (S7-1500) 26
1.7 TIME_TCK: Read time counter (S7-1500) 27
1.8 RTM: Runtime meters (S7-1200, S7-1500) 29

4 Manual, 11/2024
Manual, 11/2024 5
Time-of-day functions (S7-1200, S7-1500)

1.1 WR_SYS_T: Set time-of-day (S7-1200, S7-1500)


1
Description
You use this instruction to set the date and time-of-day (module time) of the CPU clock. Enter
the date and time-of-day at the input parameter IN . The value must be in the following range:

With DT: min. DT#1990-01-01-[Link], max. DT#2089-12-31-[Link].999

With LDT: min. LDT#1970-01-01-[Link].000000000, max. LDT#2200-12-31-[Link].999999999

With DTL: min. DTL#1970-01-01-[Link].0, max. DTL#2200-12-31-[Link].999999999

You can query whether errors have occurred during execution of the instruction in the RET_VAL
output parameter.
The "WR_SYS_T" instruction is not used to pass information about the local time zone or daylight
saving time.

Note
Module time of CPU clock
The CPU clock interprets the module time as the coordinated universal time (UTC).
Accordingly, the module time is always stored without the factors "local time zone"
or "summer time" in the CPU clock. The CPU clock then calculates the local time of
the CPU clock based on the module time.
The module time of the CPU clock is used as template for all time processes
starting from the CPU. Examples of use:

Calculation of local time of CPU clock based on module time

Representation of the module time in local time under "Online & Diagnostics"

Block properties

Entries in the diagnostics buffer of the CPU

Parameter
The following table shows the parameters of the "WR_SYS_T" instruction:

Parameter Declaration Data type Memory Description


area

S7-1200 S7-1500

6 Manual, 11/2024
IN Input DTL DT **, DTL, I, Q, M, D, L, P or Date and time
LDT constant *

RET_VAL Return INT INT I, Q, M, D, L, P Status of the


instruction

* The data types DT and DTL are not used for the following memory areas: input, output
and bit memory.
** When using the data type DT the milliseconds are not transferred to the CPU.

You can find additional information on valid data types under "Overview of the valid data types".

Parameter RET_VAL

Error Description
code*
(W#16#....)

0000 No error

8080 Error in date

8081 Error in time

8082** Invalid value specified for the month (byte 2 in DTL format).

8083** Invalid value specified for the day (byte 3 in DTL format).

8084** Invalid value specified for the hour (byte 5 in DTL format).

8085** Invalid value specified for the minute (byte 6 in DTL format).

8086** Invalid value specified for the second (byte 7 in DTL format).

8087** Invalid value specified for the nanosecond (bytes 8 to 11 in DTL format).

80B0 The real-time clock has failed

* The error codes can be displayed as integer or hexadecimal values in the program
editor. For information on switching the display formats, refer to "See also".

** Only if the date and time are specified at the parameter IN in DTL format

Example

Manual, 11/2024 7
Create three tags in a global data block for storing the data.

Interconnect the parameters of the instruction as follows. Select the DATE AND TIME data type.

If the normally open contact ("execute") supplies the signal state "TRUE", the "WR_SYS_T"
instruction is executed. The module time of the CPU clock is overwritten with the time to be set
("inputTIME"). The output parameter RET_VAL ("returnValueT") indicates that processing took
place without errors.

You can establish whether the new module time ("inputTIME") has been correctly received by
the CPU clock as follows:

Using the display of an S7-1500 CPU: Navigate on the CPU display to "Settings > Date &

Time > General".

Using TIA Portal: Read out the module time of the CPU clock using the "RD_SYS_T"

instruction.

Using TIA Portal: Navigate to the "Online & Diagnostics" entry of the CPU, and open the

"Functions > Set time of day" tab.

The Coordinated Universal Time (UTC) is set for the module time of the CPU clock. Central

European Time is set as local time in the TIA Portal in this example. Accordingly, an hour is

added to the time to be set ("inputTIME") in the "Online & Diagnostics" entry in the TIA

8 Manual, 11/2024
Portal. Another hour is added when daylight saving time is used. The calculated local time is

output in 12-hour clock format.

See also
Switching display formats in the program status
Sample Library for Instructions (S7-1200, S7-1500)

1.2 RD_SYS_T: Read time-of-day (S7-1200, S7-1500)

Description
You use this instruction to read the current date and current time-of-day (module time) of the
CPU clock.
The read dates are output at the OUT output parameter of the instruction. The provided value
does not include information about the local time zone or daylight saving time.

Note
Module time of CPU clock
The CPU clock interprets the module time as the coordinated universal time (UTC).
Accordingly, the module time is always stored without the factors "local time zone"
or "summer time" in the CPU clock. The CPU clock then calculates the local time of
the CPU clock based on the module time.
The module time of the CPU clock is used as template for all time processes
starting from the CPU. Examples of use:

Calculation of local time of CPU clock based on module time

Representation of the module time in local time under "Online & Diagnostics"

Block properties

Entries in the diagnostics buffer of the CPU

You can query whether errors have occurred during execution of the instruction in the
RET_VALoutput.

Parameters
The following table shows the parameters of the "RD_SYS_T" instruction:

Manual, 11/2024 9
RET_VAL Return INT INT I, Q, M, D, L, P Status of the
instruction

OUT Output DTL DT, DTL, I, Q, M, D, L, P Date and time of CPU


LDT *

* The data types DT and DTL cannot be used for the memory areas: input, output and bit
memory.

You can find additional information on valid data types under "Overview of the valid data types".

Parameter RET_VAL

Error Description
code*
(W#16#....)

0000 No error

8081 The data read out cannot be saved because it is outside the permissible
range for the selected data type of OUT parameter.

With DT: min. DT#1990-01-01-[Link], max. DT#2089-12-31-[Link].999

With LDT: min. LDT#1970-01-01-[Link].000000000, max. LDT#2262-04-

11-[Link].854775807

With DTL: min. DTL#1970-01-01-[Link].0, max. DTL#2262-04-11-

[Link].854775807

* The error codes can be displayed as integer or hexadecimal values in the program
editor. For information on switching the display formats, refer to "See also".

Example
In the following example, you read out the module time of the CPU clock. The data type used is
DATE AND TIME.
Create two tags in a global data block for storing the data.

Interconnect the parameters of the instruction as follows. Select the DATE AND TIME data type.

10 Manual, 11/2024
The module time of the CPU clock is read out and displayed at output parameter OUT
("outputTIME"). The output parameter RET_VAL ("returnValue") indicates that processing took
place without errors.

See also
Switching display formats in the program status
Sample Library for Instructions (S7-1200, S7-1500)

1.3 RD_LOC_T: Read local time (S7-1200, S7-1500)

Description
You use this instruction to read the current local time from the CPU clock and output this at the
OUT output. Information on the time zone and the start of daylight saving time and standard
time, which you have set in the configuration of the CPU clock, is used to output the local time.

Parameters
The following table shows the parameters of the "RD_LOC_T" instruction:

Parameter Declaration Data type Memory area Description

S7-1200 S7-1500

RET_VAL Return INT INT I, Q, M, D, L, Status of the


P instruction

Manual, 11/2024 11
OUT Output DTL DT, LDT, DTL I, Q, M, D, L, P * Local time

* The data types DT and DTL cannot be used for the memory areas: input, output and bit
memory.

You can find additional information on valid data types under "Overview of the valid data types".

Parameter RET_VAL

Error Description
code*
(W#16#....)

0000 No error

0001 No error. Local time is output as daylight saving time.

8080 Local time cannot be read.

8081 The current local time cannot be saved because it is outside the
permissible range for the selected data type of OUT parameter.

With DT: min. DT#1990-01-01-[Link], max. DT#2089-12-31-[Link].999

With LDT: min. LDT#1970-01-01-[Link].000000000, max. LDT#2262-04-

11-[Link].854775807

With DTL: min. DTL#1970-01-01-[Link].0, max. DTL#2262-04-11-

[Link].854775807

* The error codes can be displayed as integer or hexadecimal values in the program
editor. For information on switching the display formats, refer to "See also".

Example
In the following example, you read out the local time of the CPU clock. The data type used is
DATE AND TIME.
Create two tags in a global data block for storing the data.

Interconnect the parameters of the instruction as follows. Select the DATE AND TIME data type.

12 Manual, 11/2024
The local time of the CPU clock is read out and displayed at output parameter OUT
("outputLocTIME"). Output parameter RET_VAL ("returnValue") indicates that processing took
place without errors and the local time is output as daylight saving time with this call.

See also
Switching display formats in the program status
Sample Library for Instructions (S7-1200, S7-1500)

1.4 WR_LOC_T: Write local time (S7-1200, S7-1500)

Description
The instruction "WR_LOC_T" is used to set the date and time of the CPU clock. Enter the date and
time-of-day as local time at the input parameter LOCTIME.
The value must be in the following range:

With DTL: min. DTL#1970-01-01-[Link].0, max. DTL#2200-12-31 [Link].999999999

With LDT: min. LDT#1970-01-01-[Link].000000000, max. LDT#2200-12-31 [Link].999999999

The granularity of the time information for local time and system time is product-specific and is
at least one millisecond. Input values at the LOCTIME parameter which are less than those
supported by the CPU are rounded up during system time calculation.
You can query whether errors have occurred during execution of the instruction in the RET_VAL
output parameter.

Parameters
The following table shows the parameters of the "WR_LOC_T" instruction:

Manual, 11/2024 13
LOCTIME Input DTL DTL, I, Q, M, D, L, P Local time
LDT or constant *

DST Input BOOL BOOL I, Q, M, D, L, P, Daylight Saving Time


T, C or
Is only evaluated during the
constant "double hour" at changeover
to standard time.

TRUE = daylight saving

time (first hour)

FALSE = standard time

(second hour)

RET_VAL Return INT INT I, Q, M, D, L, P Error message (see "RET_VAL


parameter")

* The data type DTL cannot be used for the memory areas: input, output and bit
memory.

You can find additional information on valid data types under "Overview of the valid data types".

Parameter DST (Daylight Saving Time)


The parameter DST is evaluated only during the changeover from daylight saving to standard
time:

Use of DST during changeover from daylight saving to standard time

The clock is set back by (1) one hour at 3 a.m. This means there are two hours between

[Link]0 AM and [Link]9 AM.

For all times for LOCTIME that are between [Link]0 AM and [Link]9

AM, you therefore need to declare whether the time is before or after the time changeover.
The DST parameter is used for this:

- With DST=TRUE, the time is in the first of the two hours, i.e. still in daylight saving time.

- With DST=FALSE, the time is in the second of the two hours, i.e. in standard time.

For all times for LOCTIME that are outside the double hour, DST is irrelevant.

Changeover from standard to daylight saving time


The parameter DST is not relevant for the changeover from standard to daylight saving time.

The clock is set forward by (1) one hour at 2 a.m. This means there is no hour between
[Link]0 AM and [Link]9 AM.

If you specify a time within this hour at LOCTIME, the error code W#16#8089 is output.

14 Manual, 11/2024
(1)The description here assumes Central European Time (CET). The changeover time for CET is
2:00 AM (start of daylight saving), or 3:00 AM (end of daylight saving). Different changeover
times may apply correspondingly to other time zones.

Parameter RET_VAL

Error Description
code*
(W#16#....)

0000 No error.

8080 The LOCTIME parameter has an invalid value.

8081 Time value specified at the LOCTIME parameter is outside the valid value
range:

With DTL: min. DTL#1970-01-01-[Link].0, max. DTL#2200-12-31

[Link].999999999

With LDT: min. LDT#1970-1-1-[Link].000000000, max. LDT#2200-12-31

[Link].999999999

8082** Invalid value specified for the month (byte 2 in DTL format).

8083** Invalid value specified for the day (byte 3 in DTL format).

8084** Invalid value specified for the hour (byte 5 in DTL format).

8085** Invalid value specified for the minute (byte 6 in format DTL).

8086** Invalid value specified for the second (byte 7 in DTL format).

8087** Invalid value specified for the nanosecond (byte 8 to 11 in DTL format).

8089 Time value does not exist (hour already passed upon changeover to
daylight saving time).

80B0 The real-time clock has failed.

* The error codes can be displayed as integer or hexadecimal values in the program
editor. For information on switching the display formats, refer to "See also".

** Only for local time information at the LOCTIME parameter in DTL format.

Example

Manual, 11/2024 15
In the following example, you set the local time of the CPU clock. The data type used is DTL.
Create four tags in a global data block for storing the data.

Interconnect the parameters of the instruction as follows. Select the DTL data type.

If the normally open contact ("execute") supplies the signal state "TRUE", the "WR_LOC_T"
instruction is executed. The local time of the CPU clock is overwritten with the time to be set
("inputLocTIME"). The output parameter RET_VAL ("returnValue") indicates that the process took
place without errors. Input parameter DST ("dstValue") specifies that the time information refers
to standard time. This parameter is only relevant for the "double hour" (see description
"Parameter DST").

You can establish whether the new local time ("inputLocTIME") has been correctly received by
the CPU clock as follows:

Using the display of an S7-1500 CPU: Navigate on the CPU display to "Settings > Date &

Time > General".

16 Manual, 11/2024
Using TIA Portal: Read out the local time of the CPU clock using the "RD_LOC_T" instruction.

Using TIA Portal: Navigate to the "Online & Diagnostics" entry of the CPU, and open the

"Functions > Set time of day" tab.

The local time is output in a 12-hour clock format.

See also
Switching display formats in the program status
Sample Library for Instructions (S7-1200, S7-1500)

1.5 SET_TIMEZONE: Set time zone (S7-1200, S7-1500)

Description
Use the instruction "SET_TIMEZONE" to set the parameter for the local time zone and the
daylight saving / standard time changeover.
The settings which are carried out with the instruction "SET_TIMEZONE" correspond with the
settings for the time-of-day in the properties of the CPU. Define the corresponding parameters in
the system data type TimeTransformationRule for execution of the instruction "SET_TIMEZONE".
The local time is calculated based on the system time using the settings for the time zone and
the daylight saving / standard time changeover. The system time of the CPU is the UTC time. The
system time is used exclusively for communication within the system.

Note
Calling the "SET_TIMEZONE" instruction
The instruction "SET_TIMEZONE" writes data internally to the load memory of the
CPU. Accordingly, the change in time zone also applies after a power failure.
Calling the instruction again is unnecessary.
Call the instruction once every time the time zone has to be changed. For example,
it is advisable to call "SET_TIMEZONE" in a startup OB.

Note
Use with CPUs of the S7-1500 series
The "SET_TIMEZONE" instruction can only be used with a CPU of the S7-1500 series
starting from firmware version V1.7.

Parameters
The following table shows the parameters of the "SET_TIMEZONE" instruction:

Manual, 11/2024 17
Parameter Declaration Data type Memory Description
area

REQ Input BOOL I, Q, M, S7-1200: The


D, L, P
or function is executed
constant
on a positive edge of
REQ.

S7-1500 and version


of SET_TIMEZONE <

V2.0: When REQ=1,

the function is
executed.

S7-1500 and version


of SET_TIMEZONE

>= V2.0: The

function is executed
on a positive edge of

REQ.

The execution of the


function means that the
transfer of the time
zone and writing of the
load memory are
started.

TimeZone Input TimeTransformationRule D, L You interconnect the


TimeTransformationRule
system data type (see
below) at parameter
TimeZone.

DONE Output BOOL I, Q, M, Status parameter:


D, L, P
0: Job not yet started

or still in progress

1: Job completed

without error

18 Manual, 11/2024
BUSY Output BOOL I, Q, Status parameter:
M,
D, L, 0: Job not yet started or already completed
P
1: Job not yet completed. A new job cannot be

started.

ERROR Output BOOL I, Q, Status parameter:


M,
D, L, 0: No error
P
1: Error occurred

STATUS Output WORD I, Q, Detailed error and status information is output at


M, the parameter STATUS. The parameter is only set
D, L, for the duration of one call. To display the status,
P you should therefore copy the STATUS parameter
to a free data area.

You can find additional information on valid data types under "Overview of the valid data types".

Parameter TimeZone
You store the parameters for the local time zone and the daylight saving/standard time
changeover in the TimeTransformationRule system data type
You create the TimeTransformationRule by entering TimeTransformationRule as the data type in
a data block or the local interface of a function block.
The structure of the TimeTransformationRule is as follows:

Name Data Description


type

TimeTransformationRule STRUCT

Bias INT Time difference between the local time and the
system time (UTC) in minutes. The value must be
between -720 and +780 minutes (-12 to +13
hours).
The value (UTC -12 to +13 hours) corresponds to
the time zones that you specify in the properties
of the CPU.

DaylightBias INT Time difference between standard and daylight


saving time in minutes. The value must be
between 0 and 120 minutes.

The value "0" deactivates the changeover

between daylight saving time and standard

time. The values for "DaylightStart..." and

Manual, 11/2024 19
"StandardStart..." are set to "0". Only the value of

Bias is evaluated (time difference local time/system


time).

If the value is not "0", all tags of the


TimeTransformationRule structure are evaluated. If

an entry is invalid, error code 808F is output at

parameter STATUS.

Specification of the time of day for changeover to daylight saving time. The following
times always refer to the local time.

DaylightStartMonth USINT Month in which change is made to daylight saving


time:
1 = January
2 = February
3 = March
...
12 = December

DaylightStartWeek USINT Week in which change is made to daylight saving


time.
1 = First occurrence of the weekday in the month
...
5 = Last occurrence of the weekday in the month

DaylightStartWeekday USINT Weekday on which change is made to daylight saving


time:
1 = Sunday
...
7 = Saturday

DaylightStartHour USINT Hour in which change is made to daylight saving time

DaylightStartMinute USINT Minute in which change is made to daylight saving


time

Specification of the time of day for changeover to standard time. The following times
always refer to the local time.

StandardStartMonth USINT Month in which change is made to standard time:


1 = January
2 = February

20 Manual, 11/2024
...
12 = December

StandardStartWeek USINT Week in which change is made to standard


time:
1 = First occurrence of the weekday in the
month
...
5 = Last occurrence of the weekday in the
month

StandardStartWeekday USINT Weekday on which change is made to standard


time:
1 = Sunday
...
7 = Saturday

StandardStartHour USINT Hour in which change is made to standard time

StandardStartMinute USINT Minute in which change is made to standard


time

TimeZoneName STRING[80] Not used: The configured character string is


ignored and not written to the CPU-internal
data.

Parameter STATUS

Error Description
code*
(W#16#....)

7000 No job processing active.

7001 Start of job processing. Parameter BUSY = 1, DONE = 0

7002 Intermediate call (REQ irrelevant): Instruction already active; BUSY has the
value "1".

808F The structure, content or data types of the TimeTransformationRule at the


TimeZone parameter are invalid or inconsistent.

8092 The "SET_TIMEZONE" instruction is not supported by your CPU type or this
firmware version of your CPU.

Manual, 11/2024 21
executed until at least one of the block calls is finished.

* The error codes can be displayed as integer or hexadecimal values in the program
editor. For information on switching the display formats, refer to "See also".

Example

Note
Validity of the example
The following example applies in this form only to S7-1500 with instruction version
< V2.0.

In the following example, you set the parameters for the local time zone and the daylight
saving/standard time changeover. You are advised to call the example in a startup OB.
Create the following for storing the data in a global data block: The "timezone" structure (with
the TimeTransformationRule data type) and five additional tags.

Note
If you want to call the example in a startup OB: Set the start value of the tag
"execute" to "TRUE".

Create a local tag for the interconnection of the output parameter DONE.

22 Manual, 11/2024
Network 1: Interconnect the parameters of the "SET_TIMEZONE" instruction as follows.

Also, create the following additional interconnections:


Network 2: In case of error, you save the status in the "memErrStatus" tag.

Network 3: After successful processing, have the input parameter REQ ("execute") automatically
reset as follows.

Network 4: To ensure that the instruction "SET_TIMEZONE" is fully processed when called in a
startup OB, use the instructions JMP (in network 4) and Label (see network 1).

Manual, 11/2024 23
Note
If you want to call the example in a startup OB, the CPU for processing the example
must be in startup. Set the CPU to STOP mode before you load the example to the
CPU. Then set the CPU to RUN mode.

If the input parameter REQ ("execute) returns the signal state "TRUE", the data for the time zone
of the CPU clock is overwritten by the data to be set ("timezone"). That also means that:

Output parameter BUSY ("modeBUSY") goes to signal state "TRUE". After processing, output

parameter BUSY shows the value "FALSE" and output parameter DONE ("#statDone") shows

the value "TRUE". The success status is saved to the "modeDONE" tag.

The output parameter STATUS ("statusTime") indicates how processing is running*. (*The job

processing begins (value "7001") and the instruction is then shown as already active (value
"7002").)

The output parameter ERROR ("modeERROR") indicates that processing is running without
errors (signal state is "FALSE").

24 Manual, 11/2024
Note: The "SET_TIMEZONE" instruction is level-triggered. The instruction is executed only when
the input parameter REQ ("execute") returns the signal state "TRUE".
After successful processing of SET_TIMEZONE ("modeDONE" is "TRUE"), the input parameter REQ
("execute") is automatically reset to the value "FALSE". The value "16#7002" is queried for
"statusTime" for this purpose. After the reset, the status value "16#7000" is output.

Manual, 11/2024 25
You can establish whether the data to be set ("timezone") has been correctly received by the
CPU clock as follows:

Using the display of an S7-1500 CPU: Navigate on the CPU display to "Settings > Date &
Time > Daylight Saving Time".

Using TIA Portal: Read out the local time of the CPU clock using the "RD_LOC_T" instruction.

Using TIA Portal: Read out the module time of the CPU clock using the "RD_SYS_T"

instruction.

See also
Sample Library for Instructions (S7-1200, S7-1500)

1.6 SNC_RTCB: Synchronize slave clocks (S7-1500)

Definition: Synchronization of slave clocks


The synchronization of clock slaves refers to the transfer of the date and time-of-day from the
clock master of a bus segment to all clock slaves of this bus segment.

Description

26 Manual, 11/2024
You use this instruction to synchronize all slave clocks present locally on the CPU or locally on a
bus segment independent of the set synchronization interval (the external interface of a CP or
CM belongs to a different bus segment). Successful synchronization is only possible if
"SNC_RTCB" is called on a CPU whose real-time clock was assigned as the master clock for at
least one bus segment.

Parameters
The following table shows the parameters of the "SNC_RTCB" instruction:

Parameter Declaration Data Memory area Description


type

RET_VAL Output INT I, Q, M, D, L If an error occurs while the


instruction is being
executed, the return value
contains an error code.

You can find additional information on valid data types under "Overview of the valid data types".

Parameter RET_VAL

Error code* Explanation


(W#16#...)

0000 No error occurred during synchronization.

0001 The existing clock was not assigned the master clock function for any of
the bus segments.

General See also: GET_ERR_ID: Get error ID locally


error
information

* The error codes can be displayed as integer or hexadecimal values in the program
editor. For information on switching the display formats, refer to "See also".

See also
Switching display formats in the program status

1.7 TIME_TCK: Read time counter (S7-1500)

Description
With the "TIME_TCK" instruction, you read a time counter which counts the ms in which the CPU
is in RUN. The time counter counts from 0 to max. 2147483647 ms. In the case of an overflow,
counting restarts from 0. The time scale and the accuracy amount to 1 ms. The time counter is
only influenced by the operating modes of the CPU. You can, for example, use it to measure the

Manual, 11/2024 27
duration of processes by differentiation of the results of two "TIME_TCK" calls. The instruction
does not provide any error information.
The following table provides an overview of how the time counter changes depending on the
operating modes of the CPU.

Operating mode Time counter ...

Startup ... is constantly updated.

RUN ... is constantly updated.

STOP ... is stopped and retains the current value.

Warm restart ... is deleted and restarts with "0".

Parameters
The following table shows the parameters of the "TIME_TCK" instruction:

Parameter Declaration Data type Memory area Description

RET_VAL Return TIME I, Q, M, D, L The RET_VAL parameter


contains the read time
counter in the range
from 0 to 231 -1 ms.

You can find additional information on valid data types under "Overview of the valid data types".

Example
In the following example, you read out the time counter. You specify the return value in the
TIME data type.
Create one tag for storing the data in a global data block.

Interconnect the parameters of the instruction as follows.

28 Manual, 11/2024
The time counter is read out and displayed at the output parameter RET_VAL
("outputCPUtimer").

See also
Switching display formats in the program status
Sample Library for Instructions (S7-1200, S7-1500)

1.8 RTM: Runtime meters (S7-1200, S7-1500)

Description
You can use this instruction to set, start, stop, and read out a 32-bit operating hours counter of
your CPU.
Ensure that the operating hours counter can also be stopped or restarted during execution of
the user program, which may render the saved values incorrect.

Parameters
The following table shows the parameters of the "RTM" instruction:

Manual, 11/2024 29
highest value that can be displayed

and outputs an "Overflow" error


message.

1: start (at the last counter value)

2: stop

4: set to the value specified in the

parameter PV

5: set to the value specified in the

parameter PV and start

6: set to the value specified in the

parameter PV and stop

PV Input DINT I, Q, M, D, L New value for the operating hours


or constant counter

RET_VAL Return INT I, Q, M, D, L If an error occurs while the instruction is


being executed, the return value
contains an error code.

CQ Output BOOL I, Q, M, D, L Status of the operating hours counter (1:


running)

CV Output DINT I, Q, M, D, L Current value of the operating hours


counter

You can find additional information on valid data types under "Overview of the valid data types".

Parameter RET_VAL

Error code Explanation


(W#16#...)

0000 No error

8080 Wrong number for the operating hours counter

8081 A negative value was passed to the PV parameter.

8082 Overflow of the operating hours counter

8091 The MODE input parameter contains an invalid value.

30 Manual, 11/2024
General error information See also: Evaluating errors with GET_ERR_ID

Example
In the following example, you set the operating hours counter of the CPU and read out the value
after an hour.
Create six tags in a global data block for storing the data.

Interconnect the parameters of the instruction as follows. At input parameter NR, specify the
number of the operating hours counter of the CPU.

If the normally open contact ("execute") supplies the signal state "TRUE", the "RTM" instruction is
executed. The operating hours counter of the CPU is set to the value to be set
("in_processValue") and started. After the start of the operating hours counter, set the value of
input parameter MODE ("comandMODE") to "0". (To do so, click the parameter and select
"Modify operand > Set to 0".) As a result, the "RTM" instruction only reads the current value
("currentValue") of the operating hours counter without changing it. Output parameter CQ
("statusRTM") indicates after the start of the operating hours counter that the operating hours
counter is running (value is "TRUE"). The output parameter RET_VAL ("returnValue") indicates
that processing is running without errors.

Manual, 11/2024 31
After an hour, output parameter CV ("currentValue") indicates the value "6".

See also
Sample Library for Instructions (S7-1200, S7-1500)

32 Manual, 11/2024

You might also like