Siemens S7-1200PLC Motion Control Foundation - High Speed Counter

Nov 23, 2023

The counting process of the ordinary counter in PLC is related to the scanning operation mode. The CPU captures the rising edge of the measured signal by reading it once per scanning cycle. When the frequency of the measured signal is high, the counting pulse will be lost.

Therefore, the maximum operating frequency of ordinary counters is generally only a few tens of hertz. High speed counter (HSC) can count events that occur faster than the execution rate of program loop OB.


High speed counters are generally used in conjunction with incremental encoders, where each count pulse or reset pulse emitted by the latter serves as the input signal for the high speed counter. There are several types of encoders.

(1) Incremental encoder

The encoder disc of the photoelectric incremental encoder has uniformly engraved gratings. When the encoder rotates, it outputs pulses proportional to the increment of the rotation angle, and a counter is needed to count the number of pulses.

The single channel incremental encoder has only one pair of optocouplers inside, which can only generate one pulse train.

A dual channel incremental encoder, also known as an A/B phase or quadrature phase encoder, has two pairs of photosynthetic devices internally and outputs two independent pulse trains with a 90 ° difference.

The leading and lagging relationships of the two pulses during forward and reverse rotation are opposite. If an A/B phase encoder is used, the PLC can recognize the direction of shaft rotation and the output waveform of the A/B phase encoder.

Input points used by high-speed counters

The system manual of S7-1200 provides the default digital input points for HSCI-HSC6 of various CPU models when referring to humans in single-phase, two-phase, and A/B phases, as well as the highest counting frequency for each input point in different counting modes.

The data type of the actual count value of HSC1-HSC6 is DInt, and the default address is ID100-ID1020.

(1) The working mode of HSC

All HSCs have 5 high-speed counting operating modes: a single-phase counter with internal directional control, a timer with external directional length control, a biphase counter with two input channels of the clock, an AB phase orthogonal counter, and a monitoring P1O output. Each HSC mode can use or do not use a support input.

When the reset input is in the 1 state, the kinetic energy of the HSC's real count value can only start counting when it reaches the point where the reset input becomes the port.

The maximum measurable single pulse frequency is 100 kHz, and the maximum frequency for dual phase and A/B phase can be 30 kHz. The high-speed counter can be connected to an external rotary encoder, and users can use this function in software by configuring the PLC hardware and calling relevant instructions.

(1) Hardware Configuration of HSC

Open the device view of the PLC and select the CPU within it. Select the "General" high-speed counter HSC1 on the left side of the "Properties" tab in the inspection window, and check the checkbox "Enable this high-speed counter".

Select the 'Function' in the left window, set the 'Count Type' to 'Count', select the 'Work Mode' as the external direction control of the A/B phase counter, and set the initial counting direction to 'Add Count'.

Select "Hardware Input" in the left window and set the "Input for Clock Generator Phase A" address to 10.0, and the "Input for Clock Generator Phase B" address to 10.1. Select "I/O Address" in the left window. The default address of HSC1 is ID1000, which can be used to monitor the count value and hardware configuration of HSC1 during runtime.

(2) Set the filtering time for digital input

The default filtering time of the input filter for the digital input channels of the CPU and signal board is 6.4 ms. If the filtering time is too long, it is easy to filter out the input pulses during the filtering cycle.

For the digital input of high-speed counters, set the corresponding digital input filter using the expected minimum pulse width. The shorter filtering time in the input filtering time list for CPU digital input can be selected, such as 0.1 ms. If the width of the input pulse is changed, the filtering time of the input filter should also be changed.

6SN1118-0BK11-0AA0 6GK1100-0AT01 6GK1611-0TA01-1BV0 6GK1415-0AA01 6ES7292-1AF20-0AA0
6SN1118-0NH01-0AA0 6GK1100-0BA00 6GK1900-0KL00-0AA0 6GK1704-5DW60-3AA0 6ES7290-2AA00-0XA0
6SN1118-0NH01-0AA1 6GK1100-2AB00 6GK7443-5FX01-0XE0 6GK1970-1TA43-0AA2 6ES7298-0AA20-0AA3
6SN1118-0DA11-0AA0 6GK1100-2AC00 6GK1611-0TA01-1BX0 6GK1415-2AA00 6ES7291-8BA00-0XA0
6SN1118-0DA12-0AA0 6GK1101-0AA01 6GK1901-0AA00-0AA0 6GK1704-5DW61-3AA0 6ES7292-1AG20-0AA0
6SN1118-0NH10-0AA0 6GK1101-0AB01 6GK7443-5FX02-0XE0 6GK1970-1TA43-0AA4 6ES7290-2BA00-0XA0
6SN1118-0NH10-0AA2 6GK1102-0AA00 6GK1611-0TA01-1DV0 6GK1415-2AA01 6ES7298-0AA20-0BA3
6SN1118-0DA13-0AA0 6GK1102-0AB00 6GK1901-0AA00-0AC0 6GK1704-5DW62-3AA0 6ES7291-8BA20-0XA0

Need Help? Chat with us

leave a message
For any request of information or technical support, fill in the form. All fields marked with an asterisk* are required.
Looking for FAQs?
Contact us #
+86 -15259245292

Our hours

Mon 11/21 - Wed 11/23: 9 AM - 8 PM
Thu 11/24: closed - Happy Thanksgiving!
Fri 11/25: 8 AM - 10 PM
Sat 11/26 - Sun 11/27: 10 AM - 9 PM
(all hours are Eastern Time)




Contacts Us