Kendrion Kuhnke Automation GmbH
Counter2, Counter/Posi2
221
17 May 2021
Set Preset Value
A rising edge of "SetPreset_1" accepts the value of "SetValue_1" as the preset value. "PresetSet_1=TRUE"
indicates that the function is running.
Returning "SetPreset_1" to FALSE also returns "PresetSet_1" to FALSE.
Term2_SetValue_1:=diPresetValue ;
(*Write value to register*)
Term2_SetPreset_1:=TRUE;
(*and accept as preset value*)
Term2_PresetSet_1;
(*TRUE when accepted*)
Set Maximum Value
A rising edge of "SetMax_1" accepts the value of "SetValue_1" as the final counter value.
"MaxSet_1=TRUE" indicates that the function is running.
Returning "SetMax_1" to FALSE also returns "MaxSet_1" to FALSE.
Term2_SetValue_1:=diMaxValue ;
(*Write value to register*)
Term2_SetMax_1:=TRUE;
(*and accept as final counter value*)
Term2_MaxSet_1;
(*TRUE when accepted*)
Digital Output
Refer to page 214: Counter 1 Options.
The output can be optionally controlled by variable "Output_0_0" or the reference value function. Use
variable "ControlOutput_1" to decide.
(Refer to page 220 to know how to set options)
The state of the output is retrieved from the module and shown in "In_Output_0_0".
Term2_ControlOutput_1:=FALSE;
(*Term2_Output_0_0 sets output*)
Term2_ControlOutput_1:=TRUE;
(*Reference function sets output*)
Term2_In_Output_0_0;
(*State of output*)
A-B-Ref or Event Counter
(Refer to page 214: Counter 1 Options)
You may use the counter as A, B, Ref counter with detection of direction or as event counter. Use variable
"ControlOutput_1" to decide.
(Refer to page 220 to know how to set options)
Term2_SelectEncoder_1:=FALSE;
(*A, B, Ref and detection of direction*)
Term2_SelectEncoder_1:=TRUE;
(*Event counter at A*)
(*B=FALSE:down, B=TRUE:up*)
Single and Multi-counting
The option applies to event counter mode only
(Refer to page 214: Counter 1 Options)
You can set the counter to count (all rising and falling) edges or (rising edges only) pulses. Use variable
"SetResolution_1" to decide.
(Refer to page 220 to know how to set options)
Term2_SetResolution_1:=FALSE;
(*All edges*)
Term2_SetResolution_1:=TRUE;
(*Pulses*)
Referencing
You can set the counter to a preset value when a pulse occurs at the Ref input. The preset value can be 0 or
any other 32-bit value.
Task:
A 500-pulse rotary encoder running in 4-fold mode outputs 2000 increments per revolution.