Counter/Posi2 5V, Counter 2 5V
Kendrion Kuhnke Automation GmbH
222
17 May 2021
Every Ref signal is to set the counter to the preset value (2000). The counter is to count down to 0 within one
encoder revolution.
(The incremental encoder's sense of rotation sets the counting direction.)
PROGRAM Referencing
VAR
bInit: BOOL := TRUE ;
StepInit: USINT;
bInitReady: BOOL;
Step: USINT;
END_VAR
--------------------------------------------------------------------------------
(*1. Initialising: enable counter and set preset value*)
IF bInit THEN
CASE StepInit OF
(*Choose options and accept with rising edge of "Set_Options"*)
0:
Term2_EnableCounter_1:=TRUE;
Term2_SetValue_1:=2000;
Term2_SetPreset_1:=TRUE;
Term2_SetOptions_1:=TRUE;
StepInit:=1;
(*Wait until accepting "OptionsSet" and "PresetSet" has been confirmed*)
1:
IF Term2_OptionsSet_1 AND Term2_PresetSet_1 THEN
StepInit:=2;
END_IF
(*Reset "Set_Options" and " Set_Preset" to default*)
2:
Term2_SetOptions_1:=FALSE;
Term2_SetPreset_1:=FALSE;
StepInit:=0;
bInit:=FALSE;
bInitReady:=TRUE;
END_CASE
END_IF
(*2. Control referencing*)
IF bInitReady THEN
CASE Step OF
(*Enable referencing*)
0:
Term2_EnableReferencing_1:=TRUE;
Step:=1;
(*Wait for Referencing*)
1:
IF Term2_Referenced_1 THEN
Step:=2;
END_IF
(*Reset referencing message*)
2:
Term2_ResetReferenced_1:=TRUE;
Step:=3;
3:
IF NOT Term2_Referenced_1 THEN
(*Terminate reset of referencing message*)
Term2_ResetReferenced_1:=FALSE;
(*Disable referencing*)