Timer in a PLC

Timer in PLC
Timer in PLC

Timer in a PLC program, for example, to trigger a time-controlled action. This can be, for example, a cylinder that should remain in the end position for several seconds before it is moved back again. Or an alarm light that should light up for several seconds. For such actions, you need timers with which time-controlled functions can be programmed. According to the programming standard 61131-3, four-time functions have been defined. These are:
Real-time clock
Function block for generating a pulse (TP)
Function block for the switch-on delay (TON)
Function block for the switch-off delay (TOF)

Overview of standard function blocks according to DIN EN 61131-3

  • Explanation of the operands:
  • IN = start condition, signal change from 0 to 1
  • PT = time preset
  • Q = status of time
  • ET = current time value

Time functions in the programming software

The four-time functions specified in the programming standard 61131-3 did not meet the demands of many programmers. For example, the time functions according to 61131-3 do not see any possibility of resetting a timer. This is why many manufacturers of PLC programming software have their own time functions with extended functionality. The following extended time functions are included in Step7:

  • Time function SA: switch-off delay
  • Time function SE: switch-on delay
  • Time function SI: impulse
  • Time function SS: Retentive switch-on delay
  • Time function SV: Extended pulse

Overview of the designations and pulse diagrams of time functions in Step7

If you want to use the three standard time functions TP, TON and TOF in Step7, you have to do this by calling the following system function blocks:

  • SFB3: For TP
  • SFB4: For TON
  • SFB5: For TOF

If these system function blocks are used, an instance data block must be assigned for each of them so that the necessary data is available as static local variables. If, on the other hand, the company-specific time functions are used, a time operand, e.g. T1, must be used instead of an instance data block. The time operands can also be defined globally in the symbol table.
The company-specific time functions in Step7 are easier to handle and have a larger range of functions. For example, every time function has a reset input. S5TIME is used as the data type for the time.
How the PLC implements the timing internally is irrelevant for the programmer. You just have to know that an internal clock generator provides counting impulses through which the time runs backwards. So if you set a time on a timer, then the counter is preset. The time runs down due to the counting pulses and the counter receives the count 0 when the time has elapsed.
The cyclical processing of the program is not affected because the time function is updated asynchronously to the program processing. As a result, timers have a different value at the start of the cycle than at the end of the cycle. To get complete physical and online training in Timer in a PLC chick here

Use of the real-time clock

A clock, either as a real-time clock or a software clock, has been implemented in all CPUs of the S7-300 and S7-400 series. An integrated clock can be used in two different ways:
Master: In this case, the integrated clock acts as the master clock.
Slave: In this case, the clock plays a subordinate role of a master and is synchronized with the master.
With an integrated clock, time-of-day alarms or operating hours counters can be implemented if required. The watch shows the following values:
Time, at least with the display of seconds
Whether the milliseconds are also displayed depends on the CPU used. Here you have to look in the reference manual of the device to find out more.
The date and time can be set by the programmer himself. To do this, you need to call up the following system function and in the PLC program:
Alternatively, you can do this via the programming device menu. To do this, go online in the programming device, open the target system menu and select Set time from the menu. You can either take the time directly from the programming device / PC or enter a date and time yourself.
In this way, you can also read out the current time and date of the CPU. The system function SFC1 (READ_CLK) is used to read out the date and time directly in the program.