S7-1200 HSC Frequency Measurement Setup and Configuration

David Krause13 min read
S7-1200SiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

The S7-1200 high-speed counter (HSC) supports a frequency measurement mode that updates the live pulse rate in Hz directly to a default input image address. No user program instruction, no cyclic interrupt, and no CTRL_HSC call is required. The CPU samples the configured digital input, integrates the pulse count over an internal measurement window, and writes the result to ID1000 (for HSC1) at a rate set by the window length. This behaviour is fundamentally different from the S7-300/400 HSC, where a separate block or interrupt is required to read the value, and it is the most common source of confusion for engineers moving to the S7-1200 platform.

Frequency measurement is the simplest HSC operating mode to commission and the right starting point for any "is the counter seeing my pulses at all?" diagnostic. If the value at ID1000 stabilises around the expected pulse rate, the input wiring, the filter, and the HSC enable logic are all proven correct in a single observation. The application logic (gate control, reset, scaling to engineering units) can be layered on top of the working base once the raw frequency is being read.

Prerequisites

Confirm the following in the project and at the panel before starting the configuration:

  • CPU 1211C / 1212C / 1214C / 1215C / 1217C with firmware V4.0 or later. Frequency measurement is supported on all variants, but firmware V4.2 and newer exposes configurable measurement windows (10 ms, 100 ms, 1000 ms) in the device properties.
  • TIA Portal V13 SP1 or later. V15.1 and newer place the HSC configuration directly in the CPU device properties; earlier portals require the legacy HSC configuration tool under Tools > High Speed Counter.
  • HSC-capable digital input selected. The S7-1200 reserves specific onboard inputs for HSC use: I0.0 through I0.5 on the 1211C/1212C, I0.0 through I0.7 on the 1214C, and an extended set on the 1215C and 1217C. Refer to the S7-1200 System Manual for the per-CPU allocation table.
  • Wiring that supports the maximum count frequency. Standard 24 V sourcing inputs accept up to 100 kHz single-ended; the 200 kHz rating applies only to the differential HSC inputs on the 1217C.
  • For HMI display: a KTP600 or compatible Siemens HMI, an HMI connection configured in Devices & Networks, and the HMI tag list wired to the PLC tag or directly to ID1000.

HSC Operating Modes on the S7-1200

The S7-1200 HSC supports four operating modes per channel, selected in the device configuration. The choice changes the meaning of the value at the HSC address and the inputs that need to be wired:

Mode Use Case Default Value Address (HSC1) Inputs Required
Counter (single-phase) Event counting, batch totals, position pulses ID1000 (count value) Count, optional gate, optional reset, optional load
Counter (two-phase) Count up / count down on two pulse trains ID1000 Count up, count down, optional gate
Counter (AB quadrature) Incremental encoder feedback with x1, x2, x4 evaluation ID1000 A phase, B phase, optional zero pulse
Frequency measurement Direct Hz reading from the input pulse train ID1000 (Hz, floating-point) Count input only

The default addresses ID1000 through ID1020 are reserved in the input process image for HSC data. Each enabled HSC consumes an 8-byte block: HSC1 occupies ID1000-ID1007, HSC2 occupies ID1008-ID1015, HSC3 occupies ID1016-ID1023, and so on. The default address can be remapped in the device configuration under Properties > HSC > Input addresses if the application needs to keep ID1000 free for other use.

Hardware Configuration in TIA Portal

  1. Open the project and double-click the CPU in the device tree.
  2. In the inspector window, navigate to Properties > General > Digital inputs > HSC.
  3. Check Enable high-speed counter (HSC1).
  4. Set Operating mode to Frequency measurement.
  5. Set Input to the physical terminal that will carry the pulse train, for example I0.0.
  6. Leave the Default address at ID1000 unless the application requires a remap.
  7. If the CPU firmware supports it, set the Measurement window to 10 ms (fast update, lower resolution), 100 ms (default, 0.01 Hz resolution), or 1000 ms (slow update, 0.001 Hz resolution).
  8. Compile and download the hardware configuration to the CPU.
Critical: The HSC must be enabled in the device configuration. A program-side CTRL_HSC call is not required for frequency measurement and will not start the counter if the enable bit is missing in the hardware configuration. This is the most common commissioning failure: the program is correct, the wiring is correct, but ID1000 reads 0 because the HSC was never enabled in the device properties.

For a single CPU, all six HSCs are configured independently. Each HSC gets its own operating mode, input assignment, and address range. Do not enable more HSCs than the application uses, because each enabled HSC reserves its 8-byte address block from the global process image and blocks that block from being used for ordinary I/O.

Wiring and Input Assignment

Wire the pulse source directly to the configured digital input. The S7-1200 onboard digital inputs support PNP (sourcing) sensors by default; NPN (sinking) sensors require a 24 V common return and a different input filter setting in the device configuration. Confirm the wiring type matches the input filter setting, because a mismatch on this point will either invert the count or block it entirely.

For a bench test, the field-proven method is to drive the HSC input from a free digital output on the same CPU. A PNP output wired to I0.0 with the common returns tied together lets the engineer toggle the input under program control and confirm the HSC is reading the right terminal:

// Q0.0  ---->  I0.0  (wired externally)
// Q0.0 follows the test pulse selected by I0.1
//     I0.1 = 0  ->  Q0.0 = M0.0  (10 Hz clock bit)
//     I0.1 = 1  ->  Q0.0 = M0.1  (5 Hz clock bit)
U     "I0.1"
=     "Q0.0"

If the value at ID1000 does not change when the input is toggled, the wiring, the filter setting, or the HSC enable bit is wrong. Re-check the device configuration first: 90% of "I cannot see the count" complaints in the field are caused by the HSC being enabled on a different input than the one wired to the sensor. The TIA Portal device properties dialog will show the actual input selected in the configuration; cross-check this against the wiring diagram before suspecting the sensor or the cable.

Reading the Frequency Value at ID1000

In frequency measurement mode, the CPU writes the live frequency in Hz to ID1000. The value is updated every measurement window. The default window on firmware V4.0 / V4.1 is 100 ms, yielding a resolution of 0.01 Hz. On firmware V4.2 and later, the window can be set in TIA Portal to 10 ms (0.1 Hz resolution), 100 ms (0.01 Hz), or 1000 ms (0.001 Hz).

To monitor the value online, connect to the CPU with TIA Portal and add ID1000 to a watch table. The value will float around the expected frequency with a small jitter on the order of one or two least-significant bits:

// Copy ID1000 to a named tag for trending and HMI binding
L     %ID1000
T     "HSC1_Frequency_Hz"

// Optional: scale to millihertz for slow processes
L     "HSC1_Frequency_Hz"
L     1000
*R
T     "HSC1_Frequency_mHz"

No program-side instruction is required to keep ID1000 updated. The CPU hardware performs the integration; the user program is only needed to copy the value somewhere the HMI or SCADA can read it, or to scale the value into engineering units.

Test Pulse Generation with Clock Memory Byte MB0

The S7-1200 clock memory byte produces a fixed set of pulse trains that are useful for HSC bench testing. Enable the clock byte in the device configuration under Properties > General > System and clock memory. The default address is MB0; the bits toggle at fixed periods regardless of OB1 scan time, which makes them deterministic test sources.

Bit Period (s) Frequency (Hz) Duty
M0.0 0.1 10.0 50%
M0.1 0.2 5.0 50%
M0.2 0.4 2.5 50%
M0.3 0.5 2.0 50%
M0.4 0.8 1.25 50%
M0.5 1.0 1.0 50%
M0.6 1.6 0.625 50%
M0.7 2.0 0.5 50%

Driving the HSC input from a clock bit gives a known frequency against which the reading at ID1000 can be sanity-checked. If ID1000 reads 10.00 when M0.0 is wired to the input, the input wiring, the HSC enable, the address, and the input filter are all confirmed working in a single observation. If it reads 0, the input is not toggling or the HSC is on the wrong terminal. If it reads 5.00 when M0.0 is selected, the input filter is doubling the edges or the wiring has a noise pickup at twice the fundamental frequency.

HMI Integration on KTP600

  1. Add the PLC tag HSC1_Frequency_Hz (or ID1000 directly) to the HMI tag list with the connection set to the S7-1200 PLC.
  2. Insert an I/O field on the KTP600 screen. Set the process tag to HSC1_Frequency_Hz.
  3. Set the display format to a floating-point or integer pattern that matches the expected range. For pulse rates up to 1000 Hz, %0.0f displays the integer Hz with no decimals; for slow processes or sub-Hz readings, %0.2f or %0.3f is more useful.
  4. Compile and download the HMI project.

If the value displays as "0" on the HMI but ID1000 in the watch table shows the correct frequency, the HMI tag is not connected to the right PLC address. Verify the HMI connection in Devices & Networks and confirm the tag points to HSC1_Frequency_Hz on the correct PLC, not a local HMI tag. The HMI tag list shows the connection name in the tag properties; the most common commissioning error is leaving the default "local HMI tag" connection on a tag that should be a PLC tag.

For SCADA interfaces (WinCC, third-party OPC servers), the same HSC1_Frequency_Hz tag is exposed. With OPC UA on the S7-1200 (firmware V4.4 and later with the OPC UA server activated), the tag can be read directly without an external OPC server, using the S7-1200's built-in OPC UA endpoint.

Common Configuration Pitfalls

Symptom Likely Cause Corrective Action
ID1000 stays at 0 with pulses on the input HSC not enabled in device configuration, or enabled on the wrong terminal Open Properties > HSC and verify the correct input is selected and the channel is enabled
ID1000 reads half or double the expected value Quadrature mode accidentally selected, or input filter set to a value that is doubling pulses Confirm operating mode = "Frequency measurement" and reset input filter to the default 6.4 ms or the sensor's specified value
ID1000 jitters by 5-10 Hz on a stable input Measurement window too short for the input frequency, or noise on the wiring Increase the measurement window to 1000 ms and check the cable shield grounding at the panel entry
ID1000 reads a constant 32767 or -32768 Input frequency exceeds the HSC maximum rating for the CPU variant, or counter mode is selected and the value has wrapped Check CPU input frequency spec; reduce pulse rate or move to a faster CPU (1217C supports 200 kHz on differential inputs)
Watch table shows correct value, HMI shows 0 HMI tag bound to wrong PLC or to a local HMI tag Verify the HMI connection in Devices & Networks and re-link the tag to the PLC variable
Frequency value reads back as scaled incorrectly User program scaling the value twice (once in OB1, once on the HMI) Choose a single point of scaling; either in the PLC or on the HMI, not both
ID1000 reads negative value on a forward-running pulse train Wiring polarity inverted (NPN sensor wired to a PNP input without a common return) Re-check sensor wiring against the input type; for PNP inputs, the signal line switches to 24 V, the common returns to 0 V
Frequency reads correctly with a wired Q0.0 test pulse but not with the field sensor Sensor output type or level mismatch with the input rating, or sensor pull-up/down missing Check sensor datasheet for output type (PNP / NPN / push-pull) and confirm the load resistor / pull-up is sized for the input impedance

Cross-Platform Reference: HSC Implementation on Other Controllers

Frequency measurement is a common HSC feature, but the implementation differs across platforms. The table below compares the S7-1200 onboard HSC with the Allen-Bradley 1769-HSC CompactLogix module on the points most relevant to a commissioning engineer:

Feature S7-1200 onboard HSC 1769-HSC module
Maximum input frequency 100 kHz single-ended, 200 kHz differential (1217C only) 1 MHz counter, 250 kHz with input filter enabled
Default frequency address ID1000 (HSC1), no block call required Input words from the module, e.g. I:1.0, with the "Present Frequency" word configured in Adv Config
Operating modes Counter (1/2/A/B) or Frequency Counter, Quadrature, Pulse / Period / Rate measurement, Totalizer
User program required None for frequency mode None; read input words directly or use the HSC Add-On Instruction
Configuration tool TIA Portal device properties Studio 5000 / RSLogix 5000 module profile with Adv Config dialog
Configurable measurement window 10 / 100 / 1000 ms (firmware V4.2+) Configurable per channel via module profile

For full details on the 1769-HSC module configuration, see the 1769-HSC Compact High-speed Counter Module User Manual (1769-UM006). The Siemens S7-1200 HSC details, including the per-CPU input allocation and the diagnostic status bits, are documented in the S7-1200 System Manual and the S7-1200 product page.

Commissioning Verification Checklist

Run through the following checks in order. Stop at the first failure and resolve it before moving on:

  1. HSC1 enabled in device configuration, operating mode = Frequency measurement, input = the wired terminal.
  2. Clock memory byte enabled at MB0 (or the byte the program expects).
  3. Wire Q0.0 to I0.0 (or the configured input) for a bench test. Confirm the wiring is PNP/NPN-correct for the input type.
  4. CPU in RUN. ID1000 in the watch table should reflect the input pulse rate within the measurement window.
  5. HMI connection online. The I/O field should display the same value as the watch table.
  6. Toggle I0.1 between M0.0 and M0.1; the displayed frequency should switch between 10.00 Hz and 5.00 Hz within one measurement window.
  7. Re-wire the field sensor. ID1000 should now reflect the sensor pulse rate. If it does not, swap in a known-good sensor to localise the fault to the sensor or the wiring.
  8. Record the expected and observed frequency in the commissioning log. A 5-10% deviation is normal for cheap encoders; anything more indicates a wiring or filter problem.

If all eight checks pass, the HSC subsystem is commissioned. The remaining configuration (gate control, reset, count limits, scaling to engineering units) can be added on top of the working base without disturbing the frequency read path.

Frequently Asked Questions

Do I need a CTRL_HSC instruction or cyclic interrupt to read the HSC frequency on the S7-1200?

No. The S7-1200 HSC in frequency mode writes the live Hz value directly to ID1000 (HSC1) without any user program. Add a watch table on ID1000 to confirm the value, and copy it to a named tag only if the HMI requires a renamed variable.

What is the default address of the frequency value when I enable HSC1?

The default input address is ID1000. The HSC reserves ID1000 through ID1020 in 8-byte blocks, with HSC1 occupying ID1000-ID1007. The address can be remapped under Properties > HSC > Input addresses if required.

How do I generate a 10 Hz test pulse without a signal generator?

Enable the clock memory byte (default MB0) under Properties > System and clock memory. Bit M0.0 toggles at 10.0 Hz and bit M0.1 at 5.0 Hz. Wire M0.0 to Q0.0 and Q0.0 to the HSC input as a bench test.

Why does the watch table show the right frequency but the HMI shows zero?

Almost always the HMI tag is bound to a local HMI variable or to a different PLC connection. Open Devices & Networks on the HMI, confirm the S7-1200 connection, and re-link the I/O field process tag to HSC1_Frequency_Hz on the correct PLC.

My ID1000 reads 32767 even with no input. What is wrong?

The HSC is in counter mode (or the input frequency exceeds the rated max) and the value has wrapped. Confirm operating mode = Frequency measurement in the device configuration and verify the input pulse rate is within the CPU spec (100 kHz on most S7-1200 inputs, 200 kHz on the 1217C differential inputs).

Back to blog