Pulse output: writing and reading the elapsed value

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:

Example: writing the elapsed value into the high-speed counter

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 
		bChangeElapsedValue: BOOL:=FALSE;
			(*Changes the elapsed value*)
	END_VAR

POU body

An initial value of 3000 (elapsed value) is written into channel 0 of the high-speed counter.

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

Example: reading the elapsed value from pulse output channel 0

POU header

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

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 := 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

ST body

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

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