Functionality of the XOR Instruction?

Lets say you had a bank of inputs (say push buttons) if you one-shot each input into a XOR the bit you punch inverts it's status.

Nick
 
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.
 
I cant take credit for this but its very nice

S7 Flip Flop in STL

Code:
A #PushButton
FP #AuxPB 
X #PBStatus
= #PBStatus

It doesn't convert to S7 ladder, but it converts to S7 FBD.
 
xor(a(xor(b(xor(a,b))) will swap the values in word a and b without using any additional memory locations.

The instrucitons AND OR NOT and XOR are at the very heart of solving a ladder diagram. The processor works with 16 bit or 32 bit words, it does not work with individual bits. So what seems to be a simple bit instruction such as XIC -] [- or OTE -( )- requires that your processor execute some binary gymnastics to determine what the state of a single bit in a word is or to set/clear just one bit in a word without changing any of the other bits. So whether you realize it or not, everytime you use a bit insturction, the program actually compiles to a series of AND, OR, NOT, and XOR instructions. AND, OR, NOT, and XOR do much of the behind the scenes work of almost all of other instructions.
 
Xor

Another use; compare two numbers that change at a certain point in time. A trimsaw with ten saws with prox movement detection and a timing "window" on an Encoder of 2344 to 2420 can be monitored and an error message sent to the operator if you can see a problem. You xor the valve output word with the prox input word. If they are not the same or xored to equal zero at that point in time, you have a problem. We monitor gates, saws and operator buttons in this fashion. Any I/O word can be compared in this way.
 
Some examples above are artificial since they may be solved more naturally with CMP (Bruce99), AND (GeoffC).
The main feature of XOR is inverting bit by XORing with 1.
This is very important operation within microprocessor, since inverting word bits is step 1 of creating a binary complement (used for negative value representation).
In user-level program it also may be used for inverting bits.
Actually, XORing a bit with 1 is the simplest way to alter this bit.
Example: a pulse of a single button may alter On/Off or Run/Stop status of a device.
 
Cmp?

Not all PLCs have a CMP instruction. The poster was asking the applications of XOR in programming, not what is natural or artificial in programming.
 
Component error

I've used it with safety related components that have two contacts that should be closed at the same time. It is simple way to detect if one contact is broken. You also need Off delay timer to filter short differances between the contacts.
 
Does anyone find it discouraging/irritating that randy741985 has not deigned to reply to this thread?
 

Similar Topics

Hey All, I am sorry to ask this, but i still gotta do it. What happens if I close RS linx? Will it cause network interruption and PLCs will lose...
Replies
5
Views
146
I am wondering if anyone has seen an input IO block that has a built in AND function for the inputs and the output of the block is a normal M12 5...
Replies
13
Views
869
Hello all, I've been working on a siemens PLC system using an S7-1200 and a KTP400 Basic HMI. Essentially this system takes in some setup...
Replies
3
Views
1,376
Insufficient resources exist on SOME_CLX_PLC to support Alarm & Event functionality. Hi All AB question. Please help me sort out this error in FT...
Replies
4
Views
2,224
Hi All, Im used to using DCS software where you can perform active step changes to move logic from the current active SFC step to any other step...
Replies
1
Views
1,208
Back
Top Bottom