Programming Examples
B.5 Example: Integer Math Instructions
Solving a Math Problem
The sample program shows you how to use three integer math instructions to
produce the same result as the following equation:
MD4 = ((IW0 + DBW3) x 15) / MW2
Statement List
STL Explanation
L EW0 //Load the value from input word IW0 into accumulator 1.
L DB5.DBW3 //Load the value from shared data word DBW3 of DB5 into accumulator 1.
The old contents of accumulator 1 are shifted to accumulator 2.
+I I 0.1 //Add the contents of the low words of accumulators 1 and 2. The result
is stored in the low word of accumulator 1. The contents of accumulator
2 and the high word of accumulator 1 remain unchanged.
L +15 //Load the constant value +15 into accumulator 1. The old contents of
accumulator 1 are shifted to accumulator 2.
*I //Multiply the contents of the low word of accumulator 2 by the contents
of the low word of accumulator 1. The result is stored in accumulator
1. The contents of accumulator 2 remain unchanged.
L MW2 //Load the value from memory word MW2 into accumulator 1. The old
contents of accumulator 1 are shifted to accumulator 2.
/I //Divide the contents of the low word of accumulator 2 by the contents
of the low word of accumulator 1. The result is stored in accumulator
1. The contents of accumulator 2 remain unchanged.
T MD4 //Transfer the final result to memory double word MD4. The contents of
both accumulators remain unchanged.
Statement List (STL) for S7-300 and S7-400 Programming
B-12
A5E00706960-01
Comments to this Manuals