The special data register where the high-speed counter and pulse output control code are stored can be accessed with the system variable sys_wHscOrPulseControlCode. (The system variable sys_wHscOrPulseControlCode corresponds to special data register DT90052.)
Operations performed by the high-speed counter control code
To cancel execution of an instruction, set bit 3 of the data register storing the high-speed counter control code (sys_wHscOrPulseControlCode) to TRUE. The high-speed counter control flag then changes to FALSE. To re-enable execution of the high-speed counter instruction, reset bit 3 to FALSE.
X0 High-speed counter input
When bit 2 of the control code is set to TRUE, a hardware reset using the reset input specified in the system registers is not possible. Counting will continue even if the reset input has turned to TRUE. The hardware reset is disabled until bit 2 is reset to 0.
Count input control operation
X0 High-speed counter input
When bit 1 of the control code is set to TRUE, counting is prohibited and the elapsed value keeps its current value. Counting is continued when bit 1 is reset to FALSE.
X0 High-speed counter input
When bit 0 of the control code is set to TRUE, a software reset is performed and the elapsed value is set to 0. The elapsed value keeps the value 0 until bit 0 is reset to FALSE.
Bits 0–15 of the control code are allocated in groups of four. The bit setting in each group is represented by a hex number (e.g. 00020000 0000 1001 = 16#2009).
0: continue/1: cancel
0: enabled/1: disabled
0: permit/1: prohibit
0: no/1: yes
Example: 16#2009
Group |
Value |
Description |
|
---|---|---|---|
IV |
2 |
Channel number: 2 |
|
III |
0 |
(fixed) |
|
II |
0 |
(fixed) |
|
I |
9 |
Hex 9 corresponds to binary 1001 |
|
Cancel high-speed counter instruction: cancel (bit 3) |
1 |
||
Reset input: enabled (bit 2) |
0 |
||
Count: permit (bit 1) |
0 |
||
Reset elapsed value to 0: yes (bit 0) |
1 |
Bits 0–15 of the control code are allocated in groups of four, each group containing the settings for one channel. The bit setting in each group is represented by a hex number (e.g. 0000 0000 1001 0000 = 16#90).
0: continue/1: cancel
0: enabled/1: disabled
0: permit/1: prohibit
0: no/1: yes
Group |
IV |
III |
II |
I |
Channel |
3 |
2 |
1 |
0 |
Group |
Value |
Description |
|
---|---|---|---|
IV |
0 |
– |
|
III |
0 |
– |
|
II |
9 |
Channel number: 1 Hex 9 corresponds to binary 1001 |
|
Cancel high-speed counter instruction: cancel (bit 3) |
1 |
||
Reset input: enabled (bit 2) |
0 |
||
Count: permit (bit 1) |
0 |
||
Reset elapsed value to 0: yes (bit 0) |
1 |
||
I |
0 |
– |
Turning the reset input to TRUE, sets the elapsed value to 0. Use the reset input setting (bit 2) to disable the reset input allocated in the system registers.
All input and output variables used for programming this function have been declared in the POU header.The same POU header is used for all programming languages.
VAR
bSoftwareReset: BOOL:=FALSE;
(*Activates the function*)
END_VAR
VAR CONSTANT
HSC_CH0_RESET_ELAPSED_VALUE: WORD:=16#0001;
(*Resets elapsed value of channel 0*)
HSC_CH0_CONTINUE: WORD:=16#0000;
(*Continues counting in channel 0*)
END_VAR
VAR
END_VAR
The reset is performed in step 1, and 0 is entered just after that in step 2 to start counting. A reset alone does not start counting.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 8 ;
NETWORK_BODY
B(B_VARIN,,HSC_CH0_RESET_ELAPSED_VALUE,22,2,24,4,);
B(B_CONTACT,,bSoftwareReset,5,1,7,3,R);
B(B_VARIN,,HSC_CH0_CONTINUE,22,6,24,8,);
B(B_F,E_MOVE!,Instance,24,0,30,4,,?DEN?D?AENO?C);
B(B_VAROUT,,sys_wHscOrPulseControlCode,30,2,32,4,);
B(B_F,E_MOVE!,Instance,24,4,30,8,,?DEN?D?AENO?C);
B(B_VAROUT,,sys_wHscOrPulseControlCode,30,6,32,8,);
L(1,2,5,2);
L(7,2,8,2);
L(8,2,24,2);
L(8,6,24,6);
L(8,2,8,6);
L(1,0,1,8);
END_NETWORK_BODY
END_NET_WORK
END_BODY
if DF(bSoftwareReset) then
sys_wHscOrPulseControlCode:=HSC_CH0_RESET_ELAPSED_VALUE;
sys_wHscOrPulseControlCode:=HSC_CH0_CONTINUE;
end_if;
All input and output variables used for programming this function have been declared in the POU header.The same POU header is used for all programming languages.
VAR
bSoftwareReset: BOOL:=FALSE;
(*Activates the function*)
END_VAR
VAR CONSTANT
HSC_CH1_RESET_ELAPSED_VALUE: WORD:=16#1001;
(*Resets elapsed value of channel 1*)
HSC_CH1_CONTINUE: WORD:=16#1000;
(*Continues counting in channel 1*)
END_VAR
VAR
END_VAR
The reset is performed in step 1, and 0 is entered just after that in step 2 to start counting. A reset alone does not start counting.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 8 ;
NETWORK_BODY
B(B_VARIN,,HSC_CH1_RESET_ELAPSED_VALUE,24,2,26,4,);
B(B_CONTACT,,bSoftwareReset,5,1,7,3,R);
B(B_VARIN,,HSC_CH1_CONTINUE,24,6,26,8,);
B(B_F,E_MOVE!,Instance,26,0,32,4,,?DEN?D?AENO?C);
B(B_VAROUT,,sys_wHscOrPulseControlCode,32,2,34,4,);
B(B_F,E_MOVE!,Instance,26,4,32,8,,?DEN?D?AENO?C);
B(B_VAROUT,,sys_wHscOrPulseControlCode,32,6,34,8,);
L(1,2,5,2);
L(7,2,8,2);
L(8,2,26,2);
L(1,0,1,8);
L(8,6,26,6);
L(8,2,8,6);
END_NETWORK_BODY
END_NET_WORK
END_BODY
if DF(bSoftwareReset) then
sys_wHscOrPulseControlCode:=HSC_CH1_RESET_ELAPSED_VALUE;
sys_wHscOrPulseControlCode:=HSC_CH1_CONTINUE;
end_if;