XOR

Exclusive OR operation

The content of the accumulator is connected with the operand defined in the operand field by a logical XOR operation. The result is transferred to the accumulator.

Parameters

Input

Unnamed input (BOOL, WORD, DWORD)

1st input: element 1 of logical XOR operation

Unnamed input (BOOL, WORD, DWORD)

2nd input: element compared to input 1

Output

Unnamed output (BOOL, WORD, DWORD)

Output as input: result

Remarks

  • All operands must be of the same data type.
  • This function can be expanded to a maximum of 28 input contacts, see also modifying elements.

Truth table:

Input 1

Input 2

Output

Signal

0

0

0

1

0

1

0

1

1

1

1

0

Example

POU header

All input and output variables used for programming this function have been declared in the POU header.The same POU header is used for all programming languages.
	VAR
		bvar_1: BOOL:=FALSE;
			(*Input 1*)
		bvar_2: BOOL:=FALSE;
			(*Input 2*)
		bvar_3: BOOL:=FALSE;
			(*Output*)
	END_VAR

POU body

The Boolean variables bvar_1 and bvar_2 are logically EXCLUSIVE-OR linked and the result is written in bvar_3.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_F,@XOR-2!,,10,1,15,4,,?D?D?C);
B(B_VARIN,,bvar_1,8,1,10,3,);
B(B_VARIN,,bvar_2,8,2,10,4,);
B(B_VAROUT,,bvar_3,15,1,17,3,);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

var_3:= var_1 XOR var_2;

IL body

LD

bvar_1

(* Load bvar_1 in accu *)

XOR

bvar_2

(* Perform an XOR of accu with bvar_2; store result in accu *)

ST

bvar_3

(* Store accu in bvar_3 *)

Modified on: 2019-01-24Feedback on this pagePanasonic hotline