ABB AC500-S Safety User Manual page 178

Hide thumbs Also See for AC500-S:
Table of Contents

Advertisement

Configuration and programming
CODESYS Safety programming guidelines > Language-specific programming guidelines
END_VAR
size:= diameter * PI;
Also good:
VAR
size: REAL;
diameter: REAL;
END_VAR
size:= diameter * REAL#3.14;
4.4.3.9.3
Assignments
If assignments are used, the following programming guidelines should be followed:
For each instruction only one assignment is permitted. The expression assignments pos-
sible in CODESYS must not be used for safety applications.
Bad:
Res1 := Res2 := FunCall(1, C := D, 3);
Good:
C := D;
Res2 := FunCall(1, C, 3);
Res1 := Res2;
The implicit conversion between unsigned, signed and bit string types realized in CODESYS
and the extension of smaller types to larger types during assignment should not be used.
Explicit conversion should be used instead.
4.4.3.9.4
Parentheses
Through definition of priorities for operators each expression is uniquely defined even without
parentheses. However, in order to avoid mistakes and improve readability the use of paren-
thesis is highly recommended except in very familiar cases (multiplication/division before addi-
tion/subtraction).
Bad:
X := A < B AND NOT A > C + D OR E;
Good:
X := (A < B) AND NOT(A > (C + D)) OR E;
4.4.3.9.5
Bit access
Bit access (<variable>.<bit number>) is approved for creating safety applications and should
also be used instead of the regularly used multiple address allocation.
Bad:
VAR_GLOBAL
Flags AT %QW12: WORD;
Enable AT %QX12.0: BOOL;
END_VAR
Flags := 0;
Enable := TRUE;
Good:
178
3ADR025091M0208, 12, en_US
2020/06/19

Advertisement

Table of Contents
loading

Table of Contents