Siemens Industry Online Support
Siemens AG
Entry type: Application example, Entry ID: 109754525, Entry date: 06/21/2018

How do you realize Length and Speed Measurement using High-Speed Counters of SIMATIC S7-1200?

  • Entry
  • Associated product(s)
In most cases, high-speed counters are used in conjunction with a rotary encoder to measure motor speed or the distance or length of workpieces on a conveyor belt. Using the following example, the length and speed measurement is shown strikingly by the high-speed counters, by the simplest means, such as the integrated PWM generator of the S7-1200 and light barriers.

Figure 1: Setup

Mode of operation
The device is a sloping aluminum rail on which a pencil is passed through two light barriers (mounted on a board). The light barriers are connected to the digital inputs of the S7-1200. A pulse generator of the S7-1200 outputs constant digital time pulses via pulse width modulation (PWM). The pulse output is fed back to the digital input of the high-speed counter (HSC). When the first light barrier (gate) is darkened, the high-speed counter measures the number of pulses. A second light barrier (capture), at a known distance from the gate light barrier, detects the speed of the pencil. The length of the pencil can be determined from the speed and time of darkening and displayed on an HMI panel.
The pencil is accelerated by the inclined plane and can also be decelerated by a magnet (principle: eddy current brake) or can be re-accelerated with a tensioning device (principle: bow and arrow). A cardboard tunnel is mounted directly in front of the board to guide the pencil and protect the light barriers (Video for this Application Example).

The present application provides the following advantages:
  • Illustration of the High-Speed Counter function by the simplest means
  • Affordable in purchase by self-build instructions
  • Practical experience of physical laws (e.g. eddy current brake) 


Further Information
Security information
In order to protect plants, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about industrial security, please visit