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
Parameter description
| Interface variable | Declaration | Data type | Description |
|---|---|---|---|
| IN1 | Var_Input | ANY_BIT | Operand |
| IN2 | Var_Input | ANY_BIT | Operand |
| OUT | Var_Output | ANY_BIT | Output 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
| Operand | Value |
|---|---|
| IN1 | 0001 0010 |
| IN2 | 0000 1110 |
| OUT | 0000 0010 |
