100BBasic instructions
7.5 Math
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
187
Note
You also must create an input for any constants in your function. The constant value would
then be entered in the associated input for the CALCULATE instruction.
By entering constants as inputs, you can copy the CALCULATE instruction to other locations
in your user program without having to change the function. You then can change the values
or tags of the inputs for the instruction without modifying the function.
When CALCULATE is executed and all the individual operations in the calculation complete
successfully, then the ENO = 1. Otherwise, ENO = 0.
7.5.2
Add, subtract, multiply and divide instructions
Table 7- 38 Add, subtract, multiply and divide instructions
LAD / FBD
SCL
Description
out := in1 + in2;
out := in1 - in2;
out := in1 * in2;
out := in1 / in2;
ADD: Addition (IN1 + IN2 = OUT)
SUB: Subtraction (IN1 - IN2 = OUT)
MUL: Multiplication (IN1 * IN2 = OUT)
DIV: Division (IN1 / IN2 = OUT)
An Integer division operation truncates the fractional part of the quotient
to produce an integer output.
1
For LAD and FBD: Click the "???" and select a data type from the drop-down menu.
Table 7- 39 Data types for the parameters (LAD and FBD)
Parameter
Data type
1
Description
IN1, IN2
SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal, Constant
Math operation inputs
OUT
SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal
Math operation output
1
Parameters IN1, IN2, and OUTmust be the same data type.
To add an ADD or MUL input, click the "Create" icon or right-click on an input
stub for one of the existing IN parameters and select the "Insert input" command.
To remove an input, right-click on an input stub for one of the existing IN parameters (when
there are more than the original two inputs) and select the "Delete" command.
When enabled (EN = 1), the math instruction performs the specified operation on the input
values (IN1 and IN2) and stores the result in the memory address specified by the output
parameter (OUT). After the successful completion of the operation, the instruction sets ENO
= 1.