9.1.1
Operation of the high-speed counter
The high-speed counter (HSC) counts events that occur faster than the OB execution rate. If
the events to be counted occur within the execution rate of the OB, you can use CTU, CTD,
or CTUD counter instructions. If the events occur faster than the OB execution rate, then use
the HSC. The CTRL_HSC instruction allows your user program to programmatically change
some of the HSC parameters.
For example: You can use the HSC as an input for an incremental shaft encoder. The shaft
encoder provides a specified number of counts per revolution and a reset pulse that occurs
once per revolution. The clock(s) and the reset pulse from the shaft encoder provide the
inputs to the HSC.
The HSC is loaded with the first of several presets, and the outputs are activated for the time
period where the current count is less than the current preset. The HSC provides an interrupt
when the current count is equal to preset, when reset occurs, and also when there is a
direction change.
As each current-count-value-equals-preset-value interrupt event occurs, a new preset is
loaded and the next state for the outputs is set. When the reset interrupt event occurs, the
first preset and the first output states are set, and the cycle is repeated.
Since the interrupts occur at a much lower rate than the counting rate of the HSC, precise
control of high-speed operations can be implemented with relatively minor impact to the scan
cycle of the CPU. The method of interrupt attachment allows each load of a new preset to be
performed in a separate interrupt routine for easy state control. (Alternatively, all interrupt
events can be processed in a single interrupt routine.)
Table 9- 4
Maximum frequency (KHz)
HSC
HSC1
CPU
High-speed SB
SB
HSC2
CPU
High-speed SB
SB
HSC3
CPU
HSC4
CPU
HSC5
CPU
High-speed SB
SB
HSC6
CPU
High-speed SB
SB
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
Single phase
100 KHz
200 KHz
30 KHz
100 KHz
200 KHz
30 KHz
100 KHz
30 KHz
30 KHz
200 KHz
30 KHz
30 KHz
200 KHz
30 KHz
102BTechnology instructions
9.1 High-speed counter
Two phase and AB quadrature
80 KHz
160 KHz
20 KHz
80 KHz
160 KHz
20 KHz
80 KHz
20 KHz
20 KHz
160 KHz
20 KHz
20 KHz
160 KHz
20 KHz
317