Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 42781160, Entry date: 01/19/2017

How do you program the starting time of an event for the S7-1200/S7-1500 in STEP 7 (TIA Portal)?

  • Entry
  • Associated product(s)
With the "ClockAlarm" function, it is possible to schedule events once, or by the year, month, day, hour, minute or second.

You define the starting time of the event via the input parameters of the "ClockAlarm" function. You can disable the time units you do not need (for example, year, month, day, ...) with the parameters underneath. The block synchronizes the configured parameters with the system time. When the defined time is reached, the "ClockAlarm" function value receives the True signal until the time at the inputs corresponds to the system time.

A daily event is to be configured with the "ClockAlarm" function for 14:50 local time. Details about the parameters are described in the following table.

  1. Set the input parameters "enableHour" and "enableMinute" to the True signal. This enables the input parameters "hour" and "minute".
  2. Configure the "hour" parameter with the value 14 and the "minute" parameter with the value 50.
  3. Disable all the parameters not needed ("year", "month", "day", "second" and "week") by setting the False signal for the parameters underneath (that begin with "enable...").
  4. The function value "Ret_Val" is parameterized with the output "WakeUp" (Q0.0).
  5. Save and compile the block and load the program into the CPU.

The digital function value "Ret_Val" is now programmed daily to 14:50 local time. Figure 1 shows the example with the described parameters.

Fig. 1

You can also set the parameters of the "ClockAlarm" function with DB variables and control them via a panel, for example.

The "ClockAlarm" function was created in the SCL programming language and includes German and English comments. The following table describes the block parameters.

 Data type
Input parameter
yearUInt1970 to 2554
enableYearBool"1": year enabled; "0": disabled (no monitoring)
monthUSInt 1 to 12
enableMonthBool1": month enabled, "0": disabled (no monitoring)
dayUSInt 0 to 31
enableDayBool1": day enabled, "0": disabled (no monitoring)
hourUSInt 0 to 23
enableHourBool1": hour enabled, "0": disabled (no monitoring)


USInt 0 to 59
enableMinuteBool1": minute enabled, "0": disabled (no monitoring)
secondUSInt 0 to 59
enableSecondBool1": second enabled, "0": disabled (no monitoring)
weekUSInt 1 to 7; "-1": day of the week; "1": Sunday
enableWeekBool1": week enabled, "0": disabled (no monitoring)
localTimeBool"1": local time; "0": system time
Return parameter
ClockAlarmBoolCurrent date and time correspond to setpoint values

The download includes the STEP 7 (TIA Portal) library with the block described above for the S7-1200 and for the S7-1500. Unpack the Zip file in a separate directory on your hard disk. Then you can open and edit the library in STEP 7 (TIA Portal).

You can only open and edit the library in STEP 7 (TIA Portal). Further information about opening libraries is available in Entry ID: 37364723.

Creation Environment
The picture and download in this entry were created with STEP 7 (TIA Portal) V13 and V15.

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
Rate entry
no rating
Requests and feedback
What do you want to do?
Note: The feedback always relates to the current entry / product. Your message will be forwarded to our technical editors working in the Online Support. In a few days, you will receive a response if your feedback requires one. If we have no further questions, you will not hear from us.