Siemens SIMATIC S7-200 System Manual page 133

Programmable controller
Hide thumbs Also See for SIMATIC S7-200:
Table of Contents

Advertisement

Typically, a high-speed counter is used as the drive for a drum timer, where a shaft rotating at a
constant speed is fitted with 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 high-speed counter.
The high-speed counter is loaded with the first of several presets, and the desired outputs are
activated for the time period where the current count is less than the current preset. The counter is
set up to provide an interrupt when the current count is equal to preset and also when reset
occurs.
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 rates of the high-speed
counters, precise control of high-speed operations can be implemented with relatively minor
impact to the overall PLC scan cycle. 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.)
Understanding the Different High-Speed Counters
All counters function the same way for the same counter mode of operation. There are four basic
types of counters: 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 counter. You can use each type: without
reset or start inputs, with reset and without start, or with both start and reset inputs.
When you activate the reset input, it clears the current value and holds it clear until you
-
deactivate reset.
When you activate the start input, it allows the counter to count. While start is deactivated,
-
the current value of the counter is held constant and clocking events are ignored.
If reset is activated while start is inactive, the reset is ignored and the current value is not
-
changed. If the start input becomes active while the reset input is active, the current value is
cleared.
Before you use a high-speed counter, you use the HDEF instruction (High-Speed Counter
Definition) to select a counter mode. Use the first scan memory bit, SM0.1 (this bit is turned on for
the first scan and is then turned off), to call a subroutine that contains the HDEF instruction.
Programming a High-Speed Counter
You can use the HSC Instruction Wizard to configure the counter. The wizard uses the following
information: type and mode of counter, counter preset value, counter current value, and initial
counting direction. To start the HSC Instruction Wizard, select the Tools > Instruction Wizard
Instruction
menu command and then select HSC from the Instruction Wizard window.
Wizard
To program a high-speed counter, you must perform the following basic tasks:
Define the counter and mode.
-
Set the control byte.
-
Set the current value (starting value).
-
Set the preset value (target value).
-
Assign and enable the interrupt routine.
-
Activate the high-speed counter.
-
S7-200 Instruction Set
Chapter 6
119

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents