Danny Van den Heuvel
Member
Hi guys,
Is it possible to make a function to use a timer more than ones?
I'll been trying it but cannot solve it
Here is my function
It's a timer that runs when the INPUT RUN high is.
For so long INPUT PULS not get high the timer keeps running.
If the time is passed the OUTPUT STAT will be high ,otherwiss
the timer will be resetted.
It's a routine to check a moving elevator belt.
I'll have to check about 20 elevators and want to use 1 timer.
Thanks for all the help that you can give me
Is it possible to make a function to use a timer more than ones?
I'll been trying it but cannot solve it
Here is my function
It's a timer that runs when the INPUT RUN high is.
For so long INPUT PULS not get high the timer keeps running.
If the time is passed the OUTPUT STAT will be high ,otherwiss
the timer will be resetted.
It's a routine to check a moving elevator belt.
I'll have to check about 20 elevators and want to use 1 timer.
Thanks for all the help that you can give me
FUNCTION_BLOCK FB_CHECKTURN_ELEVATOR
(*###############################################################################*)
(* // CHECK STATUS TOERENWACHTER ELEVATOR
FB_CHECKTURN_ELEVATOR.DB_CHECKTURN_ELEVATOR(TI := timer,
PV := preset value,
PVOLD_I := oude waarde timer(in),
PULS := puls cycle_motor,
RUN := run motor,
STAT := alarm status,
PVOLD_O := oude waarde timer(uit));
*)
(*###############################################################################*)
VAR_INPUT
TI : TIMER;
PV : WORD;
PVOLD_I : WORD;
PULS : BOOL;
RUN : BOOL;
END_VAR
VAR_OUTPUT
STAT : BOOL;
PVOLD_O : WORD;
END_VAR
VAR
TTIME : INT;
TTIME2 : S5TIME;
CVOUT : S5TIME;
END_VAR
BEGIN
IF (RUN = FALSE OR PULS = TRUE) THEN
//TTIME := WORD_TO_INT(PV);
//PVOLD_O := PV;
;
ELSE
TTIME := WORD_TO_INT(PVOLD_I);
END_IF;
TTIME2:=TIM_S5TI(IN:=DINT_TO_TIME(INT_TO_DINT(TTIME)));
// motor run delay
CVOUT := S_ODT (T_NO:= TI,S:= RUN,TV:= TTIME2,R:= PULS OR NOT RUN,BI:= PVOLD_O,Q:= STAT);
IF PULS = TRUE OR RUN = FALSE THEN TTIME := WORD_TO_INT(PV); PVOLD_O := PV; END_IF;
END_FUNCTION_BLOCK
(*###############################################################################*)
DATA_BLOCK DB_CHECKTURN_ELEVATOR FB_CHECKTURN_ELEVATOR
(*###############################################################################*)
BEGIN
END_DATA_BLOCK
(*###############################################################################*)