Skip to main content

6.1.3.5.1 AND

NOTE
  • Bit logic operation instructions introduce their application in LD language
  • In ST language, this type of instructions still uses common operators

Function

Perform an "AND" operation on the value of IN1 and the value of IN2 in binary bits, and output the result at OUT

LD Graphics

alt text

Parameter description

Interface variableDeclarationData typeDescription
IN1Var_InputANY_BITOperand
IN2Var_InputANY_BITOperand
OUTVar_OutputANY_BITOutput result
warning
  • AND is an extensible function, and inputs can be added by clicking the "+" in the graph
  • IN1...INn data types need to be consistent and the same as OUT
  • ANY_BIT data types include BYTE, WORD, DWORD, and LWORD
  • ST language operator: AND or &
  • ST language example:
OUT := IN1 AND IN2 AND ... AND INn;
//or OUT := IN1 & IN2 & ... & INn;

Example

When this instruction is executed, bit 0 of the value of input IN1 and bit 0 of the value of input IN2 perform an "AND" operation. The result is stored in bit 0 of the output OUT. The same logical operation is performed on all other bits specified. As shown in the figure below, the result of "18 and" 14 is 2

OperandValue
IN10001 0010
IN20000 1110
OUT0000 0010

alt text