You are here: Core Reference > Coding > Logic > XOR

XOR

Function Name

XOR

Description

Outputs a True value when its inputs are not the same, that is, when it has True and False inputs.

Arguments

Input 1 to Input n {ANY_BIT}

For more information on the data types for the inputs and outputs, see Data Type Hierarchy.

Returns

Output {BOOL}

The output is True if it has different inputs. It is only False if its inputs are all True or all False.

Example:

Function Block Diagram - XOR:

An XOR function has 2 inputs - Input 1 is from a flow sensor and is named 'FlowPresent' and Input 2 is from a Pump control and is named 'StopPump'. When the function receives a True input from 'FlowPresent' and a False input from 'StopPump' it outputs a True value (as it has different input values). Similarly, when it receives a False value from 'FlowPresent' and a True value from 'StopPump' it outputs a True value.

If the 'FlowPresent' value is True and the 'StopPump' value is True, the output is False as the XOR function does not have different inputs. Similarly, if both of the input values are False, the output is False. The output is only True when the XOR function has both True and False inputs.

ST Program - XOR:

The XOR function is used to provide a Boolean value that is True only when the function has True and False inputs. If the inputs are the same (all True or all False), the output is False. The syntax for an XOR function in an ST Program is:

  • Output := XOR (Input 1, Input n);

Where Output, Input 1 and Input n are defined as variables earlier in the ST program. Each input is separated by a comma and is a Boolean. The Output value is also a Boolean.

Alternatively, you can use this syntax:

  • Output := Input 1 XOR Input 2;


ClearSCADA 2015 R2