Question about AC800M code execute sequence
As I know with in a code block the code execute from top to bottom and among code blocks the code will be execute from left to right according to Tab position.
Can somebody explain me what is the difference between the following code arrangement? The code is same except that the last line was in one page or another page.
A:
<CodeBlock>
R_Trig_1( Clk := vl_Trig_1 );
RS_1( Set := R_Trig_1.Q, R1 := vl_Reset );
vl_RS_Q1 := RS_1.Q1;
vl_Trig_1 := false;
</CodeBlock>
B:
<CodeBlockLeft>
R_Trig_1( Clk := vl_Trig_1 );
RS_1( Set := R_Trig_1.Q, R1 := vl_Reset );
vl_RS_Q1 := RS_1.Q1;
</CodeBlockLeft>
<CodeBlockRight>
vl_Trig_1 := false; </CodeBlockRight>
Can somebody explain me what is the difference between the following code arrangement? The code is same except that the last line was in one page or another page.
A:
<CodeBlock>
R_Trig_1( Clk := vl_Trig_1 );
RS_1( Set := R_Trig_1.Q, R1 := vl_Reset );
vl_RS_Q1 := RS_1.Q1;
vl_Trig_1 := false;
</CodeBlock>
B:
<CodeBlockLeft>
R_Trig_1( Clk := vl_Trig_1 );
RS_1( Set := R_Trig_1.Q, R1 := vl_Reset );
vl_RS_Q1 := RS_1.Q1;
</CodeBlockLeft>
<CodeBlockRight>
vl_Trig_1 := false; </CodeBlockRight>
Voted best answer
> " among code blocks the code will be execute from left to right according to Tab position."
This is NOT CORRECT for Control Modules. Code execution order is determined by the compiler !!!! This is known as code sorting. The compiler is attempting to optimize the execution order of the program. If there are code loop errors, then the execution order of Code blocks is random and CAN CHANGE when the code is re-compiled. It is not possible to determine the execution order of Code blocks when using Control Modules.
Do not split execution and reading of time sensitive function blocks across different Code Blocks when you are programming in Control Modules. Errors can occur when you compile the code and do not properly resolve Code Loops and Code sorting errors. Note, that adding "NOSORT" to variable declarations can cause the same effects. The execution order of code blocks cannot be guaranteed.
> " among code blocks the code will be execute from left to right according to Tab position. "
This is only true for POU programs. In this case, code sorting is not used by the compiler and the execution order of code is always known. It is still bad practice to reference the same Function Block in multiple Code Blocks. Always set inputs to time sensitive function blocks at a single place in the program code.
https://forum-controlsystems.abb.com/...
https://forum-controlsystems.abb.com/...
This is NOT CORRECT for Control Modules. Code execution order is determined by the compiler !!!! This is known as code sorting. The compiler is attempting to optimize the execution order of the program. If there are code loop errors, then the execution order of Code blocks is random and CAN CHANGE when the code is re-compiled. It is not possible to determine the execution order of Code blocks when using Control Modules.
Do not split execution and reading of time sensitive function blocks across different Code Blocks when you are programming in Control Modules. Errors can occur when you compile the code and do not properly resolve Code Loops and Code sorting errors. Note, that adding "NOSORT" to variable declarations can cause the same effects. The execution order of code blocks cannot be guaranteed.
> " among code blocks the code will be execute from left to right according to Tab position. "
This is only true for POU programs. In this case, code sorting is not used by the compiler and the execution order of code is always known. It is still bad practice to reference the same Function Block in multiple Code Blocks. Always set inputs to time sensitive function blocks at a single place in the program code.
https://forum-controlsystems.abb.com/...
https://forum-controlsystems.abb.com/...
Add new comment