chauvinhloi
Member
Hello everybody ^^ I'm programming a FESTO MPS with PLC S7-300 (315-2DP) using the SCL and I have a problem here. When I'm using the loop structure like REPEAT, WHILE... the PLC has fault and STOP. But If I change that loop structure... by IF statement (different structure but it has the same meaning), everything is OK and the PLC has no fault. Here is the code:
//----USING REPEAT STRUCTURE-----
FUNCTION reset_all: VOID
REPEAT
arm_release:=TRUE;
UNTIL release_pos=TRUE
END_REPEAT;
END_FUNCTION
//-----------------------------------
//----USING IF STATEMENT----------
FUNCTION reset_all: VOID
IF release_pos=FALSE THEN
arm_release:=TRUE;
ELSE
arm_release:=FALSE;
END_IF;
END_FUNCTION
//-----------------------------------
In the first one, I used the REPEAT structure and the PLC had fault. In the second one, I used IF statement and it has no fault at all.
I think it cause the PLC scan the program by cycle and when the scanning "meet" the loop structure, it's catch by the loop (like catch in the cyclone when moving on the river). The scanning can not move forward although the loop will end when its condition is satisfied so the PLC has fault.
I tried to insert the OB 80, OB 85, OB 121 to the block but it can not fix the problem
Does anyone have the solution for it or help me find out the reason for this fault?
//----USING REPEAT STRUCTURE-----
FUNCTION reset_all: VOID
REPEAT
arm_release:=TRUE;
UNTIL release_pos=TRUE
END_REPEAT;
END_FUNCTION
//-----------------------------------
//----USING IF STATEMENT----------
FUNCTION reset_all: VOID
IF release_pos=FALSE THEN
arm_release:=TRUE;
ELSE
arm_release:=FALSE;
END_IF;
END_FUNCTION
//-----------------------------------
In the first one, I used the REPEAT structure and the PLC had fault. In the second one, I used IF statement and it has no fault at all.
I think it cause the PLC scan the program by cycle and when the scanning "meet" the loop structure, it's catch by the loop (like catch in the cyclone when moving on the river). The scanning can not move forward although the loop will end when its condition is satisfied so the PLC has fault.
I tried to insert the OB 80, OB 85, OB 121 to the block but it can not fix the problem
Does anyone have the solution for it or help me find out the reason for this fault?