XOR

The IEC operator is used for bitwise XOR operation of bit operands.

If only one of the two input bits returns the value 1, the output bit is set to 1. If both inputs are 1 or both are 0, the output becomes 0.

Permitted data types: BOOL, BYTE, WORD, DWORD, LWORD

XOR 1:

Note the following behavior of XOR function block in extended form, i.e. if there are more than 2 inputs: TwinCAT compares the inputs in pairs and then compares the respective results (this corresponds to the standard, but not necessarily the expectation).

Examples:

Result: nVar is 2#0001_1001.

ST:

nVar := 2#1001_0011 XOR 2#1000_1010 

FBD:

XOR 2: