How to utilize IEC timers on the S7-1200?

Unlike the traditional S7-300/400 PLC series, S7-1200/1500 PLC series employ IEC timers. Data for IEC timers, such as set values and current values, are stored in designated data blocks. The number of timers available for use in the user program is only limited by the CPU's storage capacity. 

So how to utilize IEC timers on the S7-1200?

Today, we'll delve into the practical application of IEC timers.

The S7-1200 offers four types of IEC timers: Timer Pulse (TP), Timer ON-Delay (TON), Timer OFF-Delay (TOF), and Timer Accumulator (TONR). When adding IEC timers in the TIA Portal environment, the system automatically allocates background data blocks. In this example, we'll focus on adding a TON timer, with the background DB block depicted as shown below.



The background data block's name can be modified, but default values can also be used. Here, we'll stick with the default values. Upon clicking "OK" to confirm, in the system blocks, you'll find the newly generated IEC timer's background data block containing the following parameters:



Commonly used parameters in IEC timers include five key elements (accessible for control):

  • IN (Input): Initiates timer operation, equivalent to "Start timer".
  • R (Reset): Resets the timer, equivalent to "Reset timer".
  • PT (Preset time): Represents the predetermined time value, which must be greater than 0.
  • ET (Elapsed time): Denotes the current time value, indicating the elapsed time.
  • Q (Output): Represents the output status.

The time value in IEC timers is a 32-bit double integer variable (DInt), defaulted to milliseconds (ms), with a maximum timing value of 2,147,483,647 ms. However, calculating in milliseconds may not always be convenient. The S7-1200 also supports time calculation in the format of days-hours-minutes-seconds. To denote time values in this format, precede the time value with the symbol "T#", such as 200 seconds written as T#200s, or 1 day-2 hours-30 minutes-5 seconds-200 milliseconds written as: T#1d_2h_30m_5s_200ms, as illustrated below:




Timer Pulse (TP) is employed to generate a pulse signal with a specified time duration. When the IN signal transitions from 0 to 1, the timer commences counting. At this point, the output Q becomes 1. Throughout the elapsed time, regardless of any changes in the input IN signal, the output Q remains 1. Once the actual elapsed time ET equals or exceeds the preset value PT, the output Q transitions to 0. Upon the IN signal transitioning from 0 to 1 again, the timer restarts counting.

The timing sequence for the Timer Pulse (TP) is depicted in the following diagram:

 Time Pulse  (Photo: siemens.com/manul)


The Timer ON-Delay (TON) is utilized to delay the activation of a signal.

When the input signal IN transitions from 0 to 1, the timer commences counting. At this moment, the output Q becomes 0. During the timing process, if the elapsed time value ET equals or exceeds the preset value PT, and the input signal IN remains at 1, the output Q becomes 1. If, during the timing process, the input signal IN transitions from 1 to 0, the timer stops counting. If it transitions from 0 to 1 again, the timer restarts counting. When the output Q is 1, if the input signal IN transitions from 1 to 0, the output Q becomes 0.

The timing sequence for the Timer ON-Delay (TON) is illustrated in the following diagram:

 Timer ON-Delay (TON) (Photo: siemens.com/manul)

The Timer Off-Delay (TOF) is employed to delay the disconnection of a signal.

When the input signal IN transitions from 0 to 1, the timer starts, and the output Q becomes 1. When the input signal IN transitions from 1 to 0, the timer begins counting, and the output Q remains at 1. If the elapsed time value ET equals or exceeds the preset time value PT, and the input IN remains at 0, the output Q transitions to 0. During the elapsed time, if the input IN transitions from 0 to 1, the timer resets. When it transitions from 1 to 0 again, the timer restarts counting.

The timing sequence for the Timer Off-Delay (TOF) is shown in the following diagram:


Timer Off-Delay (TOF) (Photo: siemens.com/manul)

The Timer Accumulator (TONR) is capable of accumulating the duration of input signal IN's state at 1.

When the input signal IN transitions from 0 to 1, the timer initiates counting, and at this point, the output Q is 0. During the timer's counting process, the elapsed time is recorded in ET. If, before reaching the preset value PT, the input signal transitions from 1 to 0, the timer ceases counting. Upon the next transition of the input signal IN from 0 to 1, the timer resumes counting from the previously recorded ET value, continuing until the accumulated time in ET exceeds or equals PT, at which point the output Q transitions to 1.

When the output Q is 1, it remains unchanged regardless of any variations in the input IN signal.

When the reset signal R transitions from 0 to 1, both the output Q and the elapsed time value ET are reset to 0.

The timing sequence for the Timer Accumulator (TONR) is depicted in the following diagram:

Timer Accumulator (Photo: siemens.com/manul)


Alright, that's all for the introduction to the S7-1200's IEC timers for now.