Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 8736315, Entry date: 12/15/2008

How can you create a timer for the "S7" without using an "S7 Timer"?

  • Entry
  • Associated product(s)

The "S7 CPUs" have a time cell (TIMETICK) that counts cyclically in [ms] from 0x0 to 0x7FFFFFFF. The "S7-400 CPUs" and "CPU 318" do this in "ms resolution" and very accurately. The other "S7-300 CPUs" (except CPU 318) count in 10ms resolution.
The "TIMETICK" is also in "WinAC" Basic (SoftPLC) and counts in 10ms resolution.
The following concept is based on the "SFC64"(TIMETICK), which reads out the current "TIMETICK" of the "CPU". This makes it possible to create as many timers as you want without using up the "TIMER resources" of the "CPU".

The principle of timing generation is simple. If timing is to be started, the current "TIMETICK" is read from the "CPU" and stored. If the timer is to be queried at a later time, you need a function that calculates the time that has passed since the timer was started.
Based on this simple functionality you can create as complex pulse and time functions as you want.

A cycle-based timing suffices in many applications; in fact it is often demanded for the sake of consistency. The concept takes this demand into account, but it is also suitable for call-based timing in the ms range.

Advantages of this concept:

  • Optimum for runtime.
  • The "TIMER" system resource is not used.
  • Scalable accuracy (cycle-based as in the example, or call-based if "SFC64" is called when the time is started and queried).
  • Application makes memory resources (DW) available for the FC, which makes it possible to have as many timers as you want.

Infrastructure for the cycle-based TIMER

The basis for timing generation is the "TIMETICK" of the "CPU". For cycle-based timing, it is sufficient to read the "TIMETICK" once per cycle, save it and make it accessible to all applications (FB, FC). Central, cyclic readout saves cycle time. The "SFC64" doesn't have to be called for each timer in each cycle.

A sample application for "TIMETICK" is available in Entry ID 8736822.

All S7-300 CPU modules from firmware V2.4 onwards have a granularity of 1ms.

Timer, Resources

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