A 'Useful example of an XYZ function in a common PLC application' would be any instance where a basic binary function is useful in achieving a goal.
There are a limited selection of binary functions (bitwise or wordwise); AND, OR, and XOR (disregarding the complement functions where they exist logically of NAND and NOR). Each is a valid construct depending on the situation.
Generalize the truth tables for each, and see what might apply in a given situation.
In pure binary terms, AND conditions requires that both input be true to achieve a true output... OR conditions require that either input term be true to achieve a true output... XOR conditions require that the input terms be opposite to achieve a true output.
So, if you require an output to be true based on A 'AND' B, then both must be true for the output to be true.
If you require an output to be true based on either A 'OR' B being true, then either can be true for the output to be true.
If you require an output to be true if and only if A 'XOR' B is true, than one must be true, and the other must be false for the output to be true.
XOR instructions are useful in almost as many Boolean logical operations as are AND and OR, and essentially combine a branch of: (A 'AND' NOT_B) OR (NOT_A 'AND' B)
Bitwise, the instruction is useful to detect mutually exclusive events as being faults, as perhaps with a valve...
Assume a two position valve has a status contact back to a PLC.
Command_Valve_Open 'XOR' Status_Valve_Open will be false, if the valve is operating properly, but if you give Command_Valve_Open, and the Status_Valve_Open input remains false, you have 1 XOR 0, which would indicate that the valve failed to open.
XOR is a common instruction, even if not provided as an actual instruction in the PLC instruction set, it is achieved often by using a branch of (AB Mneumonics here):
BST XIC Input_A XIO Input_B NXB XIO Input_A XIC Input_B BND OTE State_Mismatch
randy741985 said:
I would Like someone to give me a useful example of and XOR function in a common plc application.