Operator ‘SEL’

This IEC operator is used for bitwise selection.

OUT := SEL(G, IN0, IN1) means:

OUT := IN0; if G = FALSE

OUT := IN1; if G = TRUE

Permitted data types:

IN0, …, INn, and OUT: Any identical data type. Make sure that variables of the identical type are used at all three positions, especially when using user-defined data types. The compiler checks for type identity and returns any compile errors. The assignment of function block instances to interface variables is specifically not supported.

G: BOOL

Attention

When G is TRUE, CODESYS does not compute an expression that precedes IN0. When G is FALSE, CODESYS does not compute an expression that precedes IN1.

Examples

ST:

Var1 := SEL(TRUE,3,4); (* Result: 4 *)

FBD:

../_images/35933e4ecbd426f2c0a8640e0103a5a4