Bitwise XOR XOR
Dest gets the bits that differ between A and B.
BITWISE_XOR
AGlobal.BitsNow12BGlobal.BitsLast10DestGlobal.BitsChanged6
| Tag | After two scans |
|---|---|
| BitsChanged | 6 |
| BitsLast | 10 |
| BitsNow | 12 |
How it works
While the rung is true, each bit of Dest is on where A and B differ. A false rung changes nothing.
How it's used
Use XOR to find which bits changed since the last scan.
BITWISE_XOR
AGlobal.InputsNow12BGlobal.InputsLast12DestGlobal.Changed6
Source12
Dest12
| Tag | Value |
|---|---|
| InputsNow | 12 |
| InputsLast | 12 |
| Changed | 6 |
Bits 1 and 2 changed, so Changed is 6. InputsLast already shows 12 because the MOV below ran in this scan.
Operands
| Operand | Data type | Read or write |
|---|---|---|
| A | DINT or a number | Reads |
| B | DINT or a number | Reads |
| Dest | DINT | Writes |
Common mistakes
- Expecting bits on in both to stay onXOR turns a bit on only where A and B differ.