Operation
10/10 MN05003003Z-EN
46
It must be taken into account that the operations, such as Reset
are processed via the program image. The output “Reset
AT%QX1.2” is not active until the end of the program.
You can also achieve faster access times by bypassing the image
register, such as may be required in an Interrupt routine. In this
case, use the function blocks – as an alternative to programming
with symbols. The library EC_Util2.lib contains a function block for
every counter type. The function block for the 32-bit counter has
the following parameters:
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 (
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
Figure 42: 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
section “Interrupt processing”, page 52.
Figure 43: Program with FB for 32-bit counter
Summary of Contents for easyControl EC4-200
Page 4: ...II...
Page 10: ...10 10 MN05003003Z EN 6...
Page 14: ...10 10 MN05003003Z EN 10...
Page 22: ...10 10 MN05003003Z EN 18...
Page 38: ...10 10 MN05003003Z EN 34...
Page 62: ...10 10 MN05003003Z EN 58...
Page 78: ...10 10 MN05003003Z EN 74...
Page 96: ...10 10 MN05003003Z EN 92...