The elapsed value is stored as a double word in the special data registers. Access the special data registers using the system variable sys_diPulseChannelxElapsedValue (where x=channel number).
System variables for memory areas used
Pulse output: elapsed value for channel |
System variable |
PLC types |
||
---|---|---|---|---|
FPS |
FP-X, Transistor types FP0 |
FP-X, Relay types FP0R |
||
0 |
sys_diPulseChannel0ElapsedValue |
● |
● |
● |
1 |
sys_diPulseChannel1ElapsedValue |
● |
● |
|
2 |
sys_diPulseChannel2ElapsedValue |
● |
● |
|
3 |
sys_diPulseChannel3ElapsedValue |
● |
Available channel: ●
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
bChangeElapsedValue: BOOL:=FALSE;
(*Changes the elapsed value*)
END_VAR
An initial value of 3000 (elapsed value) is written into channel 0 of the high-speed counter.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 4 ;
NETWORK_BODY
B(B_CONTACT,,bChangeElapsedValue,5,1,7,3,R);
B(B_VARIN,,3000,9,2,11,4,);
B(B_F,E_MOVE!,Instance,11,0,17,4,,?DEN?D?AENO?C);
B(B_VAROUT,,sys_diHscChannel0ElapsedValue,17,2,19,4,);
L(1,2,5,2);
L(1,0,1,4);
L(7,2,11,2);
END_NETWORK_BODY
END_NET_WORK
END_BODY
All input and output variables used for programming this function have been declared in the POU header.
VAR
bReadElapsedValue: BOOL:=FALSE;
(*Reads the elapsed value*)
diElapsedValue: DINT:=0;
(*Outputs elapsed value*)
END_VAR
The elapsed value of the high-speed counter is read from channel 0 of the high-speed counter and copied to the variable diElapsedValue.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 5 ;
NETWORK_BODY
B(B_CONTACT,,bReadElapsedValue,7,1,9,3,R);
B(B_F,E_MOVE!,,18,0,24,4,,?DEN?D?AENO?C);
B(B_VAROUT,,diElapsedValue,24,2,26,4,);
B(B_VARIN,,sys_diPulseChannel0ElapsedValue,16,2,18,4,);
L(9,2,18,2);
L(1,2,7,2);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
if DF(bReadElapsedValue) then
diElapsedValue:=sys_diHscChannel0ElapsedValue;
end_if;