Counter instructions
708
Part III FP Instructions
F118_UDC
UP/DOWN counter
CountTrigger: Adds or subtracts one count at the rising edge of this trigger.
Reset_Preset: The condition is reset when this signal is on.
The area for the elapsed value d becomes 0 when the rising edge of the trigger is detected (OFF
ON). The value in s_PresetValue is transferred to d when the falling edge of the trigger is
detected (ON OFF).
s_PresetValue: Preset (Set) value or area for Preset (Set) value.
d: Area for count (elapsed) value.
PLC types Availability of F118_UDC (see page 1320)
Variable Data type Function
UpDirection BOOL sets counter to count up (ON) or down (0FF)
CountTrigger BOOL starts counter
Reset_Preset BOOL resets counter
s_PresetValue 16-bit area or equivalent constant for counter preset value
d
ANY16
16-bit area for counter elapsed value
The variables s and d have to be of the same data type.
For Relay T/C Register Constant
UpDirection,
CountTrigger,
Reset_Preset
X Y R L T C - - - -
s_PresetValue WX WY WR WL SV EV DT LD FL dec. or hex.
d - WY WR WL SV EV DT LD FL -
Description
DOWN counting if the trigger UpDirection is in the OFF state. UP counting if the trigger
UpDirection is in the ON state.
Data types
Operands
Example
In this example the function has been programmed in ladder diagram (LD) and structured text
(ST).The same POU header is used for all programming languages.
POU header
All input and output variables used for programming this function have been declared in the POU
header.
Body