TP

Timer with defined period

The function block TP allows you to program a pulse timer with a defined clock period.

Parameters

Input

IN (BOOL)

clock generator

if a rising edge is detected at IN, a clock is generated having the period defined in PT

PT (TIME)

clock period

16-bit value: 0–327.27s

32-bit value: 0–21,474,836.47s (32-bit value not available for FP3, FPC, FP5, FP10/10S)

resolution 10ms each

a timer having the period PT is caused for each rising edge at IN. A new rising edge detected at IN within the pulse period does not cause a new timer.

Output

Q (BOOL)

signal output

is set for the period of PT as soon as a rising edge is detected at IN

ET (TIME)

elapsed time

contains the elapsed period of the timer. If PT = ET, Q will be reset

The value can be changed during counting operation by writing to the variable from the programming editor.

Remarks

  • FP2, FP2SH and FP10SH use a 32-bit value for PT.

  • Independent of the turn-on period of the IN signal, a clock is generated at the output Q having a length defined by PT. The function block TP is triggered if a rising edge is detected at the input IN.

  • A rising edge at the input IN does not have any influence during the processing of PT.

Time chart

Example

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
		copy_name: TP;
		start: BOOL:=FALSE;
		set_value: TIME:=T#0s;
		signal_output: BOOL:=FALSE;
		current_value: TIME:=T#0s;
	END_VAR

POU body

If start is set (status = TRUE), the clock is emitted at signal_output until the set_value for the clock period is reached.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 6 ;
        NETWORK_BODY
B(B_CONTACT,,start,3,2,5,4,);
B(B_VARIN,,set_value,7,3,9,5,);
B(B_VAROUT,,current_value,14,3,16,5,);
B(B_COIL,,signal_output,21,2,23,4,);
B(B_FB,TP!,copy_name,9,1,14,5,,?BIN?BPT?AQ?AET);
L(1,3,3,3);
L(1,0,1,6);
L(5,3,9,3);
L(14,3,21,3);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

copy_name( IN:= start ,
        PT:= set_value ,
        Q=> signal_output ,
        ET=> current_value );

IL body

Example with emergency stop and initializing the preset time

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
		TP1: TP;
		bIN: BOOL:=FALSE;
		tPT: TIME:=T#30s;
		tET: TIME:=T#0s;
		bQ: BOOL:=FALSE;
		bEmergencyStop: BOOL:=FALSE;
	END_VAR

POU body

After a rising edge at IN, the timer starts counting and Q is set to TRUE. When bEmergencyStop is set to TRUE before the clock period has been elapsed, counting stops and the output Q is immediatiely reset. The timer is initialized with the clock period PT of 30s in this example.

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_F,E_MOVE!,,16,0,22,4,,?DEN?D?AENO?C);
B(B_VARIN,,tPT,14,2,16,4,);
B(B_VAROUT,,TP1.ET,22,2,24,4,);
B(B_CONTACT,,TP1.Q,12,1,14,3,);
B(B_CONTACT,,bEmergencyStop,7,1,9,3,);
L(14,2,16,2);
L(1,2,7,2);
L(9,2,12,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_VARIN,,tPT,14,3,16,5,);
B(B_VAROUT,,tET,21,3,23,5,);
B(B_CONTACT,,bIN,7,2,9,4,);
B(B_COIL,,bQ,33,2,35,4,);
B(B_FB,TP!,TP1,16,1,21,5,,?BIN?BPT?AQ?AET);
B(B_CONTACT,,bEmergencyStop,27,2,29,4,N);
L(1,3,7,3);
L(9,3,16,3);
L(29,3,33,3);
L(21,3,27,3);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

if (bEmergencyStop AND TP1.Q) then
    TP1.ET:=tPT;
end_if;
TP1(IN := bIN, PT := tPT, ET => tET);
bQ := NOT bEmergencyStop AND TP1.Q;

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