manmeetvirdi
Member
SCL fault log
Hi there
Same thing written in SCL, including creation of DB !
Same thing attached also.
Hi there
Same thing written in SCL, including creation of DB !
Code:
DATA_BLOCK DB23
//to log time of occuranc of fault.
STRUCT
fault_code: ARRAY[1..50] OF int;
iDate: ARRAY[1..50] OF DATE;
iTime: ARRAY[1..50] OF TOD;
END_STRUCT
BEGIN
END_DATA_BLOCK
FUNCTION FC23 : void
VAR_input
fault_code:INT;
fault_trigger:BOOL;
END_VAR
var_in_out
x1:BOOL;
index: INT;
END_VAR
VAR_TEMP
x2:INT;
x3:INT;
END_VAR
BEGIN
WHILE fault_trigger = 1 AND x1=0 DO
x1:=1;
x2:=100+index;
x3:=200+(index*2);
db23.dbw[index]:=INT_TO_WORD(fault_code);
db23.dbw[x2]:=DINT_TO_WORD((DATE_TO_DINT(mw200)));
db23.dbd[x3]:=DINT_TO_dWORD((tod_TO_DINT(md202)));
//increment the index at positive pulse of fault_trigger
index:=index+2;
END_WHILE;
IF x1=1 AND fault_trigger=0 THEN
x1:=0;
END_IF;
IF INDEX >= 100 THEN
INDEX:=0;
END_IF;
END_FUNCTION
Same thing attached also.