Numeric Functions Instructions - Siemens SIMATIC S7-200 System Manual

Programmable controller
Hide thumbs Also See for SIMATIC S7-200:
Table of Contents

Advertisement

Numeric Functions Instructions

Sine, Cosine, and Tangent
The Sine (SIN), Cosine (COS), and Tangent (TAN) instructions
evaluate the trigonometric function of the angle value IN and place the
result in OUT. The input angle value is in radians.
SIN (IN) = OUT
To convert an angle from degrees to radians: Use the MUL_R (*R)
instruction to multiply the angle in degrees by 1.745329E--2
(approximately by π/180).
Natural Logarithm and Natural Exponential
The Natural Logarithm instruction (LN) performs the natural logarithm
of the value in IN and places the result in OUT.
The Natural Exponential instruction (EXP) performs the exponential
operation of e raised to the power of the value in IN and places the
result in OUT.
LN (IN) = OUT
To obtain the base 10 logarithm from the natural logarithm: Divide the natural logarithm by 2.302585
(approximately the natural logarithm of 10).
To raise any real number to the power of another real number, including fractional exponents: Combine the
Natural Exponential instruction with the Natural Logarithm instruction. For example, to raise X to the Y
power, enter the following instruction: EXP (Y * LN (X)).
Square Root
The Square Root instruction (SQRT) takes the square root of a real number (IN) and produces a real
number result OUT.
SQRT (IN)= OUT
To obtain other roots:
SM Bits and ENO for the Numeric Functions Instructions
For all of the instructions that are described on this page, SM1.1 is used to indicate overflow errors and
illegal values. If SM1.1 is set, then the status of SM1.0 and SM1.2 is not valid and the original input
operands are not altered. If SM1.1 is not set, then the math operation has completed with a valid result and
SM1.0 and SM1.2 contain valid status.
Error conditions that set ENO = 0
H SM1.1 (overflow)
H 0006 (indirect address)
Table 6-41
Valid Operands for Numeric Functions
Inputs/Outputs
IN
OUT
Real (or floating-point) numbers are represented in the format described in the ANSI/IEEE 754- -1985 standard
(single-precision). Refer to that standard for more information.
COS (IN) = OUT
TAN (IN) = OUT
EXP (IN)= OUT
5 cubed = 5^3 = EXP(3*LN(5)) = 125
The cube root of 125 = 125^(1/3) = EXP((1/3)*LN(125))= 5
The square root of 5 cubed = 5^(3/2) = EXP(3/2*LN(5)) = 11.18034
Special Memory bits affected
H SM1.0 (zero)
H SM1.1 (overflow)
H SM1.2 (negative)
Data Types
Operands
REAL
ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC, Constant
REAL
ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC
S7-200 Instruction Set
Chapter 6
143

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents