6.1.3.4.3 SUB
Function
Subtract (-), subtract the value of input IN2 from the value of input IN1, and then output OUT (OUT:=IN1-IN2)
LD Graphics
Parameter description
| Interface variable | Declaration | Data type | Description |
|---|---|---|---|
| IN1 | Var_Input | ANY_MAGNITUDE | Minuand |
| IN2 | Var_Input | ANY_MAGNITUDE | Subtrahend |
| OUT | Var_Output | ANY_MAGNITUDE | OUT:=IN1-IN2 |
Example
Through the SUB instruction, the value of variable a is subtracted from the value of variable b and the result is given to variable c, as shown in the figure below: Three INT type variables are defined, and the SUB instruction is executed by compiling, downloading, and achieving the effect of c:=a-b
