Invalid Range for the Result
A1
A0
OV
OS
Underflow (addition)
16 bits: result = -65536
32 bits: result = -4 294 967 296
0
0
1
1
Underflow (multiplication)
16 bits: result < -32 768 (negative number)
32 bits: result < -2 147 483 648 (negative number)
0
1
1
1
Overflow (addition, subtraction)
16 bits: result > 32 767 (positive number)
32 bits: result > 2 147 483 647 (positive number)
0
1
1
1
Overflow (multiplication, division)
16 bits: result > 32 767 (positive number)
32 bits: result > 2 147 483 647 (positive number)
1
0
1
1
Underflow (addition, subtraction)
16 bits: result < -32. 768 (negative number)
32 bits: result < -2 147 483 648 (negative number)
1
0
1
1
Division by 0
1
1
1
1
Operation
A1
A0
OV
OS
+D: result = -4 294 967 296
0
0
1
1
/D or MOD: division by 0
1
1
1
1
Integer Math Instructions
7.3 ADD_I Add Integer
Ladder Logic (LAD) for S7-300 and S7-400 Programming
Reference Manual, 04/2017, A5E41524738-AA
77
7.3
ADD_I Add Integer
Symbol
ADD_I
EN
OUT
IN2
ENO
IN1
Parameter
Data Type
Memory Area
Description
EN
BOOL
I, Q, M, L, D
Enable input
ENO
BOOL
I, Q, M, L, D
Enable output
IN1
INT
I, Q, M, L, D
or constant
First value for addition
IN2
INT
I, Q, M, L, D
or constant
Second value for addition
OUT
INT
I, Q, M, L, D
Result of addition
Description
ADD_I (Add Integer) is activated by a logic "1" at the Enable (EN) Input. IN1 and IN2 are added
and the result can be scanned at OUT. If the result is outside the permissible range for an integer
(16-bit), the OV bit and OS bit will be "1" and ENO is logic "0", so that other functions after this
math box which are connected by the ENO (cascade arrangement) are not executed.
See also Evaluating the Bits of the Status Word with Integer Math Instructions.
Status word
BR
CC 1
CC 0
OV
OS
OR
STA
RLO
/FC
writes:
x
x
x
x
x
0
x
x
1
Example
ADD_I
IN2
IN1
EN
MW0
Q 4.0
I 0.0
MW2
ENO
MW10
OUT
S
NOT
The ADD_I box is activated if I0.0 = "1". The result of the addition MW0 + MW2 is output to MW10.
If the result was outside the permissible range for an integer, the output Q4.0 is set.
Integer Math Instructions
7.4 SUB_I Subtract Integer
Ladder Logic (LAD) for S7-300 and S7-400 Programming
78
Reference Manual, 04/2017, A5E41524738-AA
7.4
SUB_I Subtract Integer
Symbol
SUB_I
EN
OUT
IN2
ENO
IN1
Parameter
Data Type
Memory Area
Description
EN
BOOL
I, Q, M, L, D
Enable input
ENO
BOOL
I, Q, M, L, D
Enable output
IN1
INT
I, Q, M, L, D
or constant
First value for subtraction
IN2
INT
I, Q, M, L, D
or constant
Value to subtract
OUT
INT
I, Q, M, L, D
Result of subtraction
Description
SUB_I (Subtract Integer) is activated by a logic "1" at the Enable (EN) Input. IN2 is subtracted from
IN1 and the result can be scanned at OUT. If the result is outside the permissible range for an
integer (16-bit), the OV bit and OS bit will be "1" and ENO is logic "0", so that other functions after
this math box which are connected by the ENO (cascade arrangement) are not executed.
See also Evaluating the Bits of the Status Word with Integer Math Instructions.
Status word
BR
CC 1
CC 0
OV
OS
OR
STA
RLO
/FC
writes:
x
x
x
x
x
0
x
x
1
Example
SUB_I
IN2
IN1
EN
MW0
Q 4.0
I 0.0
MW2
ENO
MW10
OUT
S
NOT
The SUB_I box is activated if I0.0 = "1". The result of the subtraction MW0 - MW2 is output to
MW10. If the result was outside the permissible range for an integer or the signal state of I0.0 = 0,
the output Q4.0 is set.
Integer Math Instructions
7.5 MUL_I Multiply Integer
Ladder Logic (LAD) for S7-300 and S7-400 Programming
Reference Manual, 04/2017, A5E41524738-AA
79
7.5
MUL_I Multiply Integer
Symbol
MUL_I
EN
OUT
IN2
ENO
IN1
Parameter
Data Type
Memory Area
Description
EN
BOOL
I, Q, M, L, D
Enable input
ENO
BOOL
I, Q, M, L, D
Enable output
IN1
INT
I, Q, M, L, D
or constant
First value for multiplication
IN2
INT
I, Q, M, L, D
or constant
Second value for multiplication
OUT
INT
I, Q, M, L, D
Result of multiplication
Description
MUL_I (Multiply Integer) is activated by a logic "1" at the Enable (EN) Input. IN1 and IN2 are
multiplied and the result can be scanned at OUT. If the result is outside the permissible range for
an integer (16-bit), the OV bit and OS bit will be "1" and ENO is logic "0", so that other functions
after this math box which are connected by the ENO (cascade arrangement) are not executed.
See also Evaluating the Bits of the Status Word with Integer Math Instructions.
Status word
BR
CC 1
CC 0
OV
OS
OR
STA
RLO
/FC
writes:
x
x
x
x
x
0
x
x
1
Example
MUL_I
IN2
IN1
EN
MW0
Q 4.0
I 0.0
MW2
ENO
MW10
OUT
S
NOT
The MUL_I box is activated if I0.0 = "1". The result of the multiplication MW0 x MW2 is output to
MD10. If the result was outside the permissible range for an integer, the output Q4.0 is set.
Integer Math Instructions
7.6 DIV_I Divide Integer
Ladder Logic (LAD) for S7-300 and S7-400 Programming
80
Reference Manual, 04/2017, A5E41524738-AA
7.6
DIV_I Divide Integer
Symbol
DIV_I
EN
OUT
IN2
ENO
IN1
Parameter
Data Type
Memory Area
Description
EN
BOOL
I, Q, M, L, D
Enable input
ENO
BOOL
I, Q, M, L, D
Enable output
IN1
INT
I, Q, M, L, D
or constant
Dividend
IN2
INT
I, Q, M, L, D
or constant
Divisor
OUT
INT
I, Q, M, L, D
Result of division
Description
DIV_I
(Divide Integer) is activated by a logic "1" at the Enable (EN) Input. IN1 is divided by IN2 and
the result can be scanned at OUT. If the result is outside the permissible range for an integer (16-
bit), the OV bit and OS bit is "1" and ENO is logic "0", so that other functions after this math box
which are connected by ENO (cascade arrangement) are not executed.
See also Evaluating the Bits of the Status Word with Integer Math Instructions.
Status word
BR
CC 1
CC 0
OV
OS
OR
STA
RLO
/FC
writes:
x
x
x
x
x
0
x
x
1
Example
DIV_I
IN2
IN1
EN
MW0
Q 4.0
I 0.0
MW2
ENO
MW10
OUT
S
NOT
The DIV_I box is activated if I0.0 = "1". The result of the division MW0 by MW2 is output to MW10.
If the result was outside the permissible range for an integer, the output Q4.0 is set.
Integer Math Instructions
7.7 ADD_DI Add Double Integer
Ladder Logic (LAD) for S7-300 and S7-400 Programming
Reference Manual, 04/2017, A5E41524738-AA
81
7.7
ADD_DI Add Double Integer
Symbol
ADD_DI
EN
OUT
IN2
ENO
IN1
Parameter
Data Type
Memory Area
Description
EN
BOOL
I, Q, M, L, D
Enable input
ENO
BOOL
I, Q, M, L, D
Enable output
IN1
DINT
I, Q, M, L, D
or constant
First value for addition
IN2
DINT
I, Q, M, L, D
or constant
Second value for addition
OUT
DINT
I, Q, M, L, D
Result of addition
Description
ADD_DI (Add Double Integer) is activated by a logic "1" at the Enable (EN) Input. IN1 and IN2 are
added and the result can be scanned at OUT. If the result is outside the permissible range for a
double integer (32-bit), the OV bit and OS bit will be "1" and ENO is logic "0", so that other
functions after this math box which are connected by the ENO (cascade arrangement) are not
executed.
See also Evaluating the Bits of the Status Word with Integer Math Instructions.
Status word
BR
CC 1
CC 0
OV
OS
OR
STA
RLO
/FC
writes:
x
x
x
x
x
0
x
x
1
Example
ADD_DI
IN2
IN1
EN
MD0
Q 4.0
I 0.0
MD4
ENO
MD10
OUT
S
NOT
The ADD_DI box is activated if I0.0 = "1". The result of the addition MD0 + MD4 is output to MD10.
If the result was outside the permissible range for a double integer, the output Q4.0 is set.
Integer Math Instructions
7.8 SUB_DI Subtract Double Integer
Ladder Logic (LAD) for S7-300 and S7-400 Programming
82
Reference Manual, 04/2017, A5E41524738-AA
7.8
SUB_DI Subtract Double Integer
Symbol
SUB_DI
EN
OUT
IN2
ENO
IN1
Parameter
Data Type
Memory Area
Description
EN
BOOL
I, Q, M, L, D
Enable input
ENO
BOOL
I, Q, M, L, D
Enable output
IN1
DINT
I, Q, M, L, D
or constant
First value for subtraction
IN2
DINT
I, Q, M, L, D
or constant
Value to subtract
OUT
DINT
I, Q, M, L, D
Result of subtraction
Description
SUB_DI (Subtract Double Integer) is activated by a logic "1" at the Enable (EN) Input. IN2 is
subtracted from IN1 and the result can be scanned at OUT. If the result is outside the permissible
range for a double integer (32-bit), the OV bit and OS bit will be "1" and ENO is logic "0", so that
other functions after this math box which are connected by the ENO (cascade arrangement) are
not executed.
See also Evaluating the Bits of the Status Word with Integer Math Instructions.
Status word
BR
CC 1
CC 0
OV
OS
OR
STA
RLO
/FC
writes:
x
x
x
x
x
0
x
x
1
Example
SUB_DI
IN2
IN1
EN
MD0
Q 4.0
I 0.0
MD4
ENO
MD10
OUT
S
NOT
The SUB_DI box is activated if I0.0 = "1". The result of the subtraction MD0 - MD4 is output to
MD10. If the result was outside the permissible range for a double integer, the output Q4.0 is set.
Integer Math Instructions
7.9 MUL_DI Multiply Double Integer
Ladder Logic (LAD) for S7-300 and S7-400 Programming
Reference Manual, 04/2017, A5E41524738-AA
83
7.9
MUL_DI Multiply Double Integer
Symbol
MUL_DI
EN
OUT
IN2
ENO
IN1
Parameter
Data Type
Memory Area
Description
EN
BOOL
I, Q, M, L, D
Enable input
ENO
BOOL
I, Q, M, L, D
Enable output
IN1
DINT
I, Q, M, L, D
or constant
First value for multiplication
IN2
DINT
I, Q, M, L, D
or constant
Second value for multiplication
OUT
DINT
I, Q, M, L, D
Result of multiplication
Description
MUL_DI (Multiply Double Integer) is activated by a logic "1" at the Enable (EN) Input. IN1 and IN2
are multiplied and the result can be scanned at OUT. If the result is outside the permissible range
for a double integer (32-bit), the OV bit and OS bit will be "1" and ENO is logic "0", so that other
functions after this math box which are connected by the ENO (cascade arrangement) are not
executed.
See also Evaluating the Bits of the Status Word with Integer Math Instructions.
Status word
BR
CC 1
CC 0
OV
OS
OR
STA
RLO
/FC
writes:
x
x
x
x
x
0
x
x
1
Example
MUL_DI
IN2
IN1
EN
MD0
Q 4.0
I 0.0
MD4
ENO
MD10
OUT
S
NOT
The MUL_DI box is activated if I0.0 = "1". The result of the multiplication MD0 x MD4 is output to
MD10. If the result was outside the permissible range for a double integer, the output Q4.0 is set.
Integer Math Instructions
7.10 DIV_DI Divide Double Integer
Ladder Logic (LAD) for S7-300 and S7-400 Programming
84
Reference Manual, 04/2017, A5E41524738-AA
7.10
DIV_DI Divide Double Integer
Symbol
DIV_DI
EN
OUT
IN2
ENO
IN1
Parameter
Data Type
Memory Area
Description
EN
BOOL
I, Q, M, L, D
Enable input
ENO
BOOL
I, Q, M, L, D
Enable output
IN1
DINT
I, Q, M, L, D
or constant
Dividend
IN2
DINT
I, Q, M, L, D
or constant
Divisor
OUT
DINT
I, Q, M, L, D
Whole-number result of division
Description
DIV_DI (Divide Double Integer) is activated by a logic "1" at the Enable (EN) Input. IN1 is divided
by IN2 and the result can be scanned at OUT. The Divide Double Integer element does not
produce a remainder. If the result is outside the permissible range for a double integer (32-bit), the
OV bit and OS bit is "1" and ENO is logic "0", so that other functions after this math box which are
connected by the ENO (cascade arrangement) are not executed.
See also Evaluating the Bits of the Status Word with Integer Math Instructions.
Status word
BR
CC 1
CC 0
OV
OS
OR
STA
RLO
/FC
writes:
x
x
x
x
x
0
x
x
1
Example
DIV_DI
IN2
IN1
EN
MD0
Q 4.0
I 0.0
MD4
ENO
MD10
OUT
S
NOT
The DIV_DI box is activated if I0.0 = "1". The result of the division MD0 : MD4 is output to MD10. If
the result was outside the permissible range for a double integer, the output Q4.0 is set.
Integer Math Instructions
7.11 MOD_DI Return Fraction Double Integer
Ladder Logic (LAD) for S7-300 and S7-400 Programming
Reference Manual, 04/2017, A5E41524738-AA
85
7.11
MOD_DI Return Fraction Double Integer
Symbol
MOD_DI
EN
OUT
IN2
ENO
IN1
Parameter
Data Type
Memory Area
Description
EN
BOOL
I, Q, M, L, D
Enable input
ENO
BOOL
I, Q, M, L, D
Enable output
IN1
DINT
I, Q, M, L, D
or constant
Dividend
IN2
DINT
I, Q, M, L, D
or constant
Divisor
OUT
DINT
I, Q, M, L, D
Remainder of division
Description
MOD_DI (Return Fraction Double Integer) is activated by a logic "1" at the Enable (EN) Input. IN1
is divided by IN2 and the fraction can be scanned at OUT. If the result is outside the permissible
range for a double integer (32-bit), the OV bit and OS bit is "1" and ENO is logic "0", so that other
functions after this math box which are connected by the ENO (cascade arrangement) are not
executed.
See also Evaluating the Bits of the Status Word with Integer Math Instructions.
Status word
BR
CC 1
CC 0
OV
OS
OR
STA
RLO
/FC
writes:
x
x
x
x
x
0
x
x
1
Example
MOD_DI
IN2
IN1
EN
MD0
Q 4.0
I 0.0
MD4
ENO
MD10
OUT
S
NOT
The DIV_DI box is activated if I0.0 = "1". The remainder of the division MD0:MD4 is output to
MD10. If the remainder was outside the permissible range for a double integer, the output Q4.0 is
set.
Integer Math Instructions
7.11 MOD_DI Return Fraction Double Integer
Ladder Logic (LAD) for S7-300 and S7-400 Programming
86
Reference Manual, 04/2017, A5E41524738-AA
Ladder Logic (LAD) for S7-300 and S7-400 Programming
Reference Manual, 04/2017, A5E41524738-AA
87
8
Floating Point Math Instructions
8.1
Overview of Floating-Point Math Instruction
Description
The IEEE 32-bit floating-point numbers belong to the data type called REAL. You can use the
floating-point math instructions to perform the following math instructions using
two 32-bit IEEE
floating-point numbers:
•
ADD_R Add Real
•
SUB_R Subtract Real
•
MUL_R Multiply Real
•
DIV_R Divide Real
Using floating-point math, you can carry out the following operations with
one 32-bit IEEE floating-
point number:
•
Establish the Absolute Value (ABS)
•
Establish the Square (SQR) and the Square Root (SQRT)
•
Establish the Natural Logarithm (LN)
•
Establish the Exponential Value (EXP) to base e (= 2,71828)
•
Establish the following trigonometrical functions of an angle represented as a 32-bit IEEE
floating-point number
- Sine (SIN) and Arc Sine (ASIN)
- Cosine (COS) and Arc Cosine (ACOS)
- Tangent (TAN) and Arc Tangent (ATAN)
See also Evaluating the Bits of the Status Word.
Floating Point Math Instructions
8.2 Evaluating the Bits of the Status Word with Floating-Point Math Instructions
Ladder Logic (LAD) for S7-300 and S7-400 Programming
88
Reference Manual, 04/2017, A5E41524738-AA
8.2
Evaluating the Bits of the Status Word with Floating-Point Math
Instructions
Description
Floating–point instructions affect the following bits in the status word: CC 1 and CC 0, OV and
OS.
The following tables show the signal state of the bits in the status word for the results of
instructions with floating-point numbers (32 bits):
Valid Area for a Result
CC 1 CC 0 OV
OS
+0, -0 (zero)
0
0
0
*
-3.402823E+38 < result < -1.175494E-38 (negative number)
0
1
0
*
+1.175494E-38 < result < 3.402824E+38 (positive number)
1
0
0
*
* The OS bit is not affected by the result of the instruction.
Invalid Area for a Result
CC 1 CC 0 OV
OS
Underflow
-1.175494E-38 < result < - 1.401298E-45 (negative number)
0
0
1
1
Underflow
+1.401298E-45 < result < +1.175494E-38 (positive number)
0
0
1
1
Overflow
Result < -3.402823E+38 (negative number)
0
1
1
1
Overflow
Result > 3.402823E+38 (positive number)
1
0
1
1
Not a valid floating-point number or illegal instruction
(input value outside the valid range)
1
1
1
1
Floating Point Math Instructions
8.3 Basic Instructions
Ladder Logic (LAD) for S7-300 and S7-400 Programming
Reference Manual, 04/2017, A5E41524738-AA
89
Dostları ilə paylaş: |