Hello,
I have used this forum a few times already but this time the search function didnt give me what I needed.
this is my problem i made a FB (FB1) to process errors. this FB1 is called in a different multi-instance FB (FB2,DB2).
input variables:
now how do i check whether Delay is empty or not. If Delay is empty i do not need the timer. SCL does not support 'NULL' i have tried to generate a S5T#0ms time value to compare Delay with that but it would not compile. it seems i cant use S5T# values in an if statement or in a comparison.
when i call FB1 with S5T#0ms as Delay then it will call the FB and it will work but i think 10ms is minimum so it will use 10ms instead of 0ms? true?
full code
thanks in advance!
I have used this forum a few times already but this time the search function didnt give me what I needed.
this is my problem i made a FB (FB1) to process errors. this FB1 is called in a different multi-instance FB (FB2,DB2).
input variables:
Code:
VAR_INPUT //entrees
HFPos : BOOL; //position of sensor
Ack : BOOL; //acknowledge error
Delay : S5TIME; //optional delay of HFPos signal
T_NO : INT; //to identify timer
END_VAR
when i call FB1 with S5T#0ms as Delay then it will call the FB and it will work but i think 10ms is minimum so it will use 10ms instead of 0ms? true?
full code
Code:
FUNCTION_BLOCK FB_ERROR_GEN
TITLE = 'FB_ERROR_GEN'
//
// Analog Input
//
VERSION: '1.0'
AUTHOR: 'IVENS'
(*VARIABLES******************************)
VAR_INPUT //entrees
HFPos : BOOL;
Ack : BOOL;
Delay : S5TIME;
T_NO : INT;
END_VAR
VAR_OUTPUT //sorties
FAULT : BOOL;
END_VAR
VAR_TEMP
END_OF_TIMER :BOOL;
BCD_time_value :S5TIME;
END_VAR
VAR
Acknowledged: BOOL;
END_VAR
BEGIN
//
//start timer
//
BCD_time_value := S_ODT(
T_NO:=T_NO,
S:=HFPos,
TV:=Delay,
R:=FALSE,
Q:=END_OF_TIMER);
//
//If timer finished set FAULT bit
//
IF END_OF_TIMER = TRUE THEN
FAULT:=TRUE;
//
//If timer no longer being activated and Ack=true then set FAULT bit to 0
//
ELSIF END_OF_TIMER = FALSE AND Acknowledged = TRUE THEN
FAULT:=FALSE;
END_IF;
//
//
//
IF FAULT = TRUE AND Ack=true AND Acknowledged = FALSE THEN
Acknowledged := true;
ELSIF FAULT=FALSE AND Acknowledged = TRUE THEN
Acknowledged := FALSE;
END_IF;
END_FUNCTION_BLOCK
Last edited: