![ABB AC500-S Safety User Manual Download Page 218](http://html.mh-extra.com/html/abb/ac500-s/ac500-s_safety-user-manual_2916218.webp)
size: REAL;
diameter: REAL;
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:
n
For each instruction only one assignment is permitted. The expression assignments possible in CoDeSys
must not be used for safety-oriented applications.
Bad:
Res1 := Res2 := FunCall(1, C := D, 3);
Good:
C := D;
Res2 := FunCall(1, C, 3);
Res1 := Res2;
n
The implicit conversion between unsigned, signed and bit string types realised 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 parenthesis is highly recommended
except in very familiar cases (multiplication/division before addition/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-oriented 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
Configuration and programming
CoDeSys Safety programming guidelines > Language-specific programming guidelines
30.03.2017
AC500-S
218