High-speed counter: writing and reading the elapsed value

The elapsed value is stored as a double word in the special data registers.

  • When programming with F instructions:Access the special data registers using the system variable sys_diHscChannelxElapsedValue (where x=channel number).

  • When programming with tool instructions:Use universal high-speed counter information and control instructions and pulse information and control instructions which apply to all PLC types to read and write the elapsed value.

System variables for memory areas used:

PLC type

High-speed counter: elapsed value of channel

System variables

FP-Sigma, FP-e

0-3

sys_diHscChannel0ElapsedValue- sys_diHscChannel3ElapsedValue

FP-X, Transistor types

0-7

sys_diHscChannel0ElapsedValue- sys_diHscChannel7ElapsedValue

FP-X, Relay types

0-B

sys_diHscChannel0ElapsedValue- sys_diHscChannelBElapsedValue

FP0R

0-5

sys_diHscChannel0ElapsedValue- sys_diHscChannel5ElapsedValue

Example: reading the elapsed value from high-speed counter channel 0

POU header

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 
		bReadElapsedValue: BOOL:=FALSE;
			(*Reads the elapsed value*)
		diElapsedValue: DINT:=0;
			(*Outputs elapsed value*)
	END_VAR

POU body

The elapsed value of the high-speed counter is read from channel 0 of the high-speed counter and copied to the variable diElapsedValue.

LD body

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

ST body

if DF(bReadElapsedValue) then
    diElapsedValue:=sys_diHscChannel0ElapsedValue;
end_if;

Modified on: 2019-01-25Feedback on this pagePanasonic hotline