each timer function have input i.e. IN(input) and PT(preset time) and outputs, ET (elapsed time) and Q (output).To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor).
IN (input) :- bool data type input for start and stop timer.
PT (preset time) :- it preset time or clock period of a timer.
Q (Output) :- bool type output, it is depend on types of timer.
ET (elapsed time) :- data type for ET is time elapsed time of timer.it is elapsed period of timer.
instances :- instances is important when you define any type of function block, By declaring the function Block(FB) you create a copy of the original FB. This copy is saved under instance name. A separate data area is reserved for this copy.The property InstanceName of the base class returns a string which contains the name of the module instance.
diffrent timer instace name
TP : instance type TP
TON : instance type TON
TOF : instance type TOF
TP, Timer with defined period
The function block TP allows you to program a pulse timer with a defined clock period. define input and output
instance TP_instance data type TP
IN start_timer data type BOOL
PT preset TIME for example t#10s or t#10ms
ET tp_elapsed_time data type time
Q tp_out data type bool
If IN(start_time) is set (status = TRUE), output Q (tp_out) set until the clock period PT is reached. when IN(start_timer) is set to 1(true) timer generate clock for defined Preset value(10s) and output is set to 1(true) until PT = ET. if PT = ET output is set to 0. so output(Q) of this type of timer is set to 1 only in defined Preset value.
TON, Timer with switch-on delay
The function block TON allows you to program a switch-on delay. If IN is set (status = TRUE), the input signal is transferred to OUTPUT Q with a delay by the time period PT .
instance instance data type TON
IN start_timer data type BOOL
PT preset TIME for example t#10s or t#10ms
ET timer_elapsed_time data type time
Q timer_out data type bool
when IN is set(1) timer start running for specified Preset Time. output (Q) of this timer is set when PT is equal to ET otherwise output of this timer is 0.
TOF, Timer with switch-off delay
The function block TOF allows you to program a switch-off delay. If IN is reset, this signal is transferred to output Q with a delay corresponding to the period of PT.
instance tof_instance data type TOf
IN start_timer data type BOOL
PT preset TIME for example t#10s or t#10ms
ET TOF_elapsed_time data type time
Q TOF_out data type bool
when timer IN signal is reset timer start runing for specified timer preset value. when PT = ET output reset(0) otherwise output of timer is 1.
if IN is 0 and PT t#10s so the out put of TON,TOF AND TP is 0
if IN is set and PT t#10s and PT ≠ ET so the out put of TON is 0 and TOF AND TP output is 1
if IN is set and PT t#10s and PT = ET so the out put of TON, TOF is 1 and TP output is 0
if IN is reset and PT t#10s and PT ≠ ET so the out put of TON , TP is 0 and TOF output is 1
if IN is reset and PT t#10s and PT = ET so the out put of TON , TP and TOF is 0.
manualy insert timer preset value during running plc
if you want to enter manualy preset value during running plc so use a conversion instrunction block so convert enterd value into time.
WORD_TO_TIME, WORD in TIME
WORD_TO_TIME converts a value of the data type WORD into a value of the data type TIME. example Input 12345 then output T#123.45s
if input 16#0012 then output T#180.00ms
DWORD_TO_TIME, DOUBLE WORD in TIME
DWORD_TO_TIME converts a value of the data type DWORD into a value of the data type TIME. A value of 1 corresponds to a time of 10ms, e.g. the input value 12345 (16#3039) is converted to a TIME T#2m3s450.00ms.
INT_TO_TIME, INTEGER into TIME
INT_TO_TIME converts a value of the data type INT into a value of the data type TIME. The resolution is 10ms, e.g. when the INT value = 350, the TIME value = 3s500ms.
DINT_TO_TIME, DOUBLE INTEGER into TIME
DINT_TO_TIME converts a value of the data type DINT into a value of the data type TIME. A value of 1 corresponds to a time of 10ms, e.g. an input value of 123 is converted to a TIME T#1s230.00ms.
REAL_TO_TIME, REAL into TIME
REAL_TO_TIME converts a value of the data type REAL to a value of the data type TIME. 10ms of the data type TIME correspond to 1.0 REAL unit, e.g. when REAL = 1.0, TIME = 10ms; when REAL = 100.0, TIME = 1s. The value of the data type real is rounded off to the nearest whole number for the conversion.
conversion of time value to other data types
for conversion of time value into another data type used following blocks
TIME_TO_WORD, TIME into WORD
TIME_TO_WORD converts a value of the data type TIME into a value of the data type WORD.
TIME_TO_DWORD, TIME into DOUBLE WORD
TIME_TO_DWORD converts a value of the data type TIME into a value of the data type DWORD. The time 10ms corresponds to the value 1, e.g. an input value of T#1s is converted to the value 100 (16#64).
TIME_TO_INT, TIME into INTEGER
TIME_TO_INT converts a value of the data type TIME into a value of the data type INT.
TIME_TO_DINT, TIME into DOUBLE INTEGER
TIME_TO_DINT converts a value of the data type TIME into a value of the data type DINT. The time 10ms corresponds to the value 1, e.g. an input value of T#1m0s is converted to the value 6000.
TIME_TO_REAL, TIME into REAL
TIME_TO_REAL converts a value of the data type TIME to a value of the data type REAL. 10ms of the data type TIME correspond to 1.0 REAL unit, e.g. when TIME = 10ms, REAL = 1.0; when TIME = 1s, REAL = 100.0. The resolution amounts to 10ms.
timer example
in this example timer run continuously. INT_TO_TIME block convert enterd int value into the time and set timer preset value. Time_TO_INT block convert eapsed time value into INT. equal comparison block are used for comparing preset value and elapsed value of timer if both value are equal then output set to 1 and timer stop and ET =0, then timer start again because of condition so this timer run continue.