User Manual

Operation
12/06 AWB2724-1584GB
46
The inputs/outputs of the function blocks are essentially the same
as the inputs/outputs listed in the PLC configuration.
Counter functions (inputs/outputs)
The description of the input/output functions in the following
sections applies to the inputs/outputs of function blocks and those
of the PLC configuration.
32-bit counter
Only one 32-bit counter is available. The pulse transmiter must be
connected with the external input I1. It receives the pulses at a
maximum frequency of 50 kHz. The CPU counts these pulses and
provides them as an actual (= Counter) value. The actual value can
then be scanned in the user program. Whether the actual value is
incremented or decremented when a count pulse is received
depends on the setting of the Direction output in the user
program.
The following counter features can be defined via the program:
•Enable:
TRUE: Pulses are counted.
FALSE: Pulses are not counted.
A 1 signal at the Enable input activates the counter: The
incoming pulses are counted. With the next 0 l 1 edge of the
Enable signal, the actual value is set to 0 and the status at
the Direction input and at the Preset input are accepted. Any
direction change during operation is not detected.
Direction:
Incrementing (Direction = FALSE): the counter counts up to
the set reference value (PRESET). Once the reference value
has been reached, this activates the configured interrupt
which branches to a program routine (page 52). The counter
continues counting from zero when the next count pulse is
received.
Decrementing (Direction = TRUE): with the first count pulse,
the actual value is set from 0 to the setpoint. If an interrupt
is programmed, the associated program routine is called
(page 52). With each further pulse, the actual value is
reduced until it reaches 0. On the next count pulse the
reference value is accepted again and the program routine is
called again.
Reset:
A 0 l 1 edge at the Reset input will cause the actual value to
be set to 0 and the direction and reference value to be
accepted, irrespective of the status of the Enable signal.
•Preset
Example: Program with FB for 32-bit counter
16 Bit Counter
Two of these counters are available. The function of this counter is
the same as that of the high-speed counter (32-bit). In order to
identify the two 16-bit counters, the symbolic operands have a
number: 0 or 1. The operands with 0 control count pulses that are
present at input I1. Those with the number 1 are for the count
pulses of I2.
External inputs:
The counter number can be seen in the symbolic operands in the
PLC configurator in the folder “16Bit Counter”.
Figure: 41: 32-bit counter function block
h
You must also program the Enable input in the PLC
configuration to enable the 16-bit and for the 32-bit
counter, in addition to the function block inputs.
h
An interrupt can be generated if the actual value is the
same as the reference value. This causes a program
routine to be executed. To do this, you must activate the
interrupt in the task configuration and assign the program
routine a section “Interrupt processing”, page 52.
Figure: 42: Program with FB for 32-bit counter
Counter
number
Pulse input
0 I1
1 I2