Using the pulse generators of the S7-1200
7.1 High-speed counters
Easy Book
82
Manual, 05/2009, A5E02486774-01
7.1
High-speed counters
A high-speed counter (HSC) can be used 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.)
Selecting the functionality for the HSC
All HSCs function the same way for the same counter mode of operation. There are four
basic types of HSC: single-phase counter with internal direction control, single-phase
counter with external direction control, two-phase counter with 2 clock inputs, and A/B phase
quadrature counter. Note that every mode is not supported by every HSC. You can use each
HSC type with or without a reset input. When you activate the reset input, it clears the
current value and holds it clear until you deactivate reset.
Frequency function: Some HSC modes allow the HSC to be configured (type of counting) to
report the frequency instead of a current count of pulses. Three different frequency
measuring periods are available: 0.01, 0.1, or 1.0 seconds.
The frequency measuring period determines how often the HSC calculates and reports a
new frequency value. The reported frequency is an average value determined by the total
number of counts in the last measuring period. If the frequency is rapidly changing, the
reported value will be an intermediate between the highest and lowest frequency occurring
during the measuring period. The frequency is always reported in Hertz (pulses per second),
regardless of the frequency-measuring-period setting.
Counter modes and inputs: The following table shows the inputs used for the clock, direction
control, and reset functions associated with the HSC. The same input cannot be used for two
different functions, but any input not being used by the present mode of its HSC can be used
for another purpose.
For example, if HSC1 is in a mode that uses built-in inputs but does not use the external
reset (I0.3), then I0.3 can be used for edge interrupts or for HSC2.