Basic instructions
7.5 Math functions
7.5.9
Exponent, logarithm, and trigonometry instructions
You use the floating point instructions to program mathematical operations using a Real or
LReal data type:
● SQR: Form square (IN
● SQRT: Form square root (√IN = OUT)
● LN: Form natural logarithm (LN(IN) = OUT)
● EXP: Form exponential value (e
● EXPT: exponentiate (IN1
EXPT parameters IN1 and OUT are always the same data type, for which you must
select Real or LReal. You can select the data type for the exponent parameter IN2 from
among many data types.
● FRAC: Return fraction (fractional part of floating point number IN = OUT)
● SIN: Form sine value (sin(IN radians) = OUT)
● ASIN: Form arcsine value (arcsine(IN) = OUT radians), where the sin(OUT radians) = IN
● COS: Form cosine (cos(IN radians) = OUT)
● ACOS: Form arccosine value (arccos(IN) = OUT radians), where the cos(OUT radians) =
IN
● TAN: Form tangent value (tan(IN radians) = OUT)
● ATAN: Form arctangent value (arctan(IN) = OUT radians), where the tan(OUT radians) =
IN
Table 7- 59
Examples of floating-point math instructions
LAD / FBD
SCL
out := SQR(in);
or
out := in * in;
out := in1 ** in2;
For LAD and FBD: Click the "???" (by the instruction name) and select a data type from the drop-down menu.
1
For SCL: You can also use the basic SCL math operators to create the mathematical expressions.
2
236
= OUT)
2
=OUT), where base e = 2.71828182845904523536
IN
= OUT)
IN2
Description
Square: IN
= OUT
2
For example: If IN = 9, then OUT = 81.
General exponential: IN1
For example: If IN1 = 3 and IN2 = 2, then OUT = 9.
= OUT
IN2
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG