Question
What instruction can I use to reverse the status of specific bits?
Answer
Use the EXCLUSIVE OR instruction (XORW) to reverse the status of specific bits in a specific word.
EXCLUSIVE OR Instruction (XORW) Specifications
1.An EXCLUSIVE OR of the corresponding bits in input 1 and input 2 are taken and the results are output to the result word, R.
2.As can be seen in the truth table on the right, when the EXCLUSIVE OR is executed, the bits with different status in inputs S1 and S2 will be 1 in the result word, while the bits with the same status will be 0.
Program and Operation
By using this basic specification of the EXCLUSIVE OR instruction (XORW), specific bits in a specific word can be inverted.
1. Ladder Programming
Figure1
2. Operation
Figure2