STD-FB - Mathematische Funktionen - CPU922 - 928 - 946-947 - (E) - OCR

Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

SIEMENS

Mathematical Functions
Standard Function Blocks
CPU 922, 928, 9461947
Description C79000-B8576-C667-01
Mathematical Functions Contents

Contents

1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1.1
2 Function Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2.1

3 Interrupt Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3.1

4 Technical Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1.


5 Description of Individual Function Blocks . . . . . . . . . . . . . . . . . . . . . .5.1
5.1 Trigonometric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1
5.2 Arc Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.6
5.3 Logarithmic Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10
5.4 Exponential Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-13

O Siemens AG C79000-B8576-C667701
List of Tables Mathematical Functions

List of Tables

Table 1.1 Summary of function blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1


Table 1.2 File designations and library numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1
Table 2.1 Flag modifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2
Table 4.1 Technical data for CPU 922 and CPU 928 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1
Table 4.2 Technical data for CPU 9461947 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2

O Siemens AG C79000-B8576-C667-01
Mathematical Functions Introduction

1 Introduction

These Programming Instructions describe the function blocks


"Mathematicalfunctions" for the S5-135U and S5-155U
programmable controllers. The function blocks of the
mathematicalfunctions are divided into:

Table 1. l Summary of function blocks

The function blocks of the mathematical functions are available


in two versions: one version can be executed on the CPU 922
and CPU 928 (S5-135U), the other on the CPU 9461947
(S5-155U).

Table 1.2 File designations and library numbers

3 Siemens AG C79000-B8576-C667-01
C
Mathematical Functions Function Description

2 Function Description

General

The standard function blocks for the mathematical functions are


handled like a corresponding STEP 5 statement. When these
blocks are called:
- the contents of accumulator 1 are modified according to the
executed function (without changing the contents of the
other accumulators or the base address register BR) or
the contents of accumulators 1 and 2 are linked together
according to the executed function where the contents of
accumulator 3 are shifted into accumulator 2 and the
contents of accumulator 4 shifted into accumulator 3 (as with
a STEP 5 calculation function). The contents of the BR
register remain unchanged.

Example of conversion of the accumulator contents:

:LDD 120 Load floating-point number Z1 into


accumulator
:L DD 142 Load floating-point number Z2 into
accumulator
:JU FB 101 and generate the sine from these
NAME :SINUS
xG Multiply Z1 by sine (22)
:T DD 122 and store in the data double word DD 122

Example of linking of accumulators 1 and 2:

:L DD 150 Load number Z1 into accumulator


:L DD 160 Load base (a)
:ENT Load Z1 into accumulator 3
:L DD 162 Load power (n)
:JU FB 114 Generate power (ato power n)
NAME :A2 "A1
:+G Divide Z1 by (a to power n)
:T DD 170 and store in the data double word DD 170

All standard function blocks for mathematical functions process


32-bit floating-point numbers.
Function Description Mathematical Functions

The standard function blocks use certain data words in the


system transfer data area RI (from RI 230 to RI 255) as an
intermediate memory, partly for the scratchpad flags used in the
remaining program. A function block of the mathematical
functions operates with its "own" scratchpad flags. Before the
function block is left, the "user- specific" assignment of the
scratchpad flags is reestablished. In this manner the
assignment of the scratchpad flags appears to the user to be
unchanged during processing of a mathematical function.

Error handling

If the calculation in the function block is terminated correctly,


the result of the logic operation is set to a signal status "0".

The calculation is aborted (without changing the accumulator


contents) and the result of the logic operation is set to "1" if the
input value for the function is not within the permissible limits or
if the permissible number range is violated during the
calculation in the function block.

The function blocks of the mathematical functions change the


flags as follows:

Table 2.1 Flag modifications

1) The latching overflow bit is reset when a block is changed.

Q Siemens AG C79000-B6576-C667-01
Mathematical Functions Function Description

The flags are evaluated using jump functions.


Example:

:L FD 160 Load input value


:JU FB 101 Execute mathematicalfunction
NAME :SINUS
:T FD 180 Store result

:JO =OVER Jumpwith error message (can also be a


conditional jump JC)
:JZ =NULL Jump if the result is zero
:JP =POS Jump if the result is positive
:JM =NEG Jump if the result is negative

l&bit mantissa with floating-point calculation

The CPU 922 always uses a 16-bit mantissa for calculations


where (if the output values have a 24-bit mantissa) the bits 0 to
7 are set to zero. With the CPU 928, it is possible to adjust in
data block DXO whether the processor is to calculate with a
16-bit or 24-bit rnantissa.

The standard function blocks are matched to the calculation


with a 16-bit mantissa.

O SiemensAG C79000-89576-C667-01
Mathematical Functions Interrupt Response

3 lnterrupt Response

The function blocks of the mathematical functions do not have


an interrupt disable function. They can be interrupted by an
interrupt event following each statement so that a fast reaction
is possible to an interrupt (alarm or time interrupt). Since they
have an own buffer area (the system transfer data RI), these
blocks cannot be interrupted by themselves (and also not by
other blocks of the mathematical functions).

If function blocks of the mathematicalfunctions are called in the


cyclic program as well as in the interrupt-controlled program,
appropriate preparations must be made to enable fault-free
processing of the function blocks. There are two possibilities:
interrupt disable in the cyclic program or save buffer area in
interrupt-controlledprogram.

With an interrupt disable in the cyclic program all interrupts are


disabled prior to calling a function block of the mathematical
functions and enabled again after this is called. Program
example (cyclic program):

Program for CPU 922 and CPU 928:

:L KB2
:L KB5
AU OB 120 Disable interrupts

dU FB 101 Call mathematicalfunctions


NAME :SINUS

:L KB3
:L KB5
U OB 120 Enable interrupts

C3 Siemens AG C79000-B8576-C667701
Interrupt Response Mathematical Functions

Program for CPU 9461947:

:L KB1
;IU OB 122 Disable intermpts

;IU FB 101 Call mathematicalfunctions


NAME :SINUS

:L KB2
:JU OB 122 Enable interrupts

When saving the buffer area, the system data used are saved
at the beginning of the interrupt-controlled program into a data
block (similar to the scratchpad flags) and loaded again at the
end of the interrupt-controlled program.

Program example (in interrupt-controlledprogram):

:C DB n Data block as buffer memory


;IU FB 36 Save system data area
NAME :RI +DB

U FB 101 Mathematicalfunctions
NAME :SINUS

:C DB n Callbuffermemory
;IU FB37 Loadsystem data area
NAME :DB +RI

The data block used as a buffer memory must be called before


calling the respective function block for saving or loading. It
must be sufficiently long (initialized up to and including data
word DW 25).

Q Siemens AG C790M)-B8576-C667-01
Mathematical Functions Interrupt Response

Program example for CPU 922 and CPU 928:

FB 36 FB 37

NAME :RI+ DB NAME :DB+ RI


:L KH E8E5 :L KH E8E5
:TIR 6 :TIR 6
ADD BN +26 ADD BN +26
:L RI 229 :L RI 229
ADD BN +25 ADD BN +25
:TNW 26 :TAK
:BE :TNW 26
:BE

Program example for CPU 9461947:

FB 36 FB 37

NAME :RI + DB NAME :DB+ RI


:L DH OOOE F4E5 :L DH OOOE F4E5

:TIR 6 :TIR 6
ADD BN +26 ADD BN +26
:L RI 229 :L RI 229
:SLD 4 :SLD 4
ADD DH 0000 0019 ADD DH 0000 0019

:TNW 26 :TAK
:BE :lNW 26
:BE

The function blocks FB 36 and FB 37 use the system transfer


data word RI 229 as a buffer memory for the initial address of
the data block. These function blocks are supplied together with
the standard function blocks of the mathematical functions.

O Siemens AG C79000-58576-C667-01
Mathematical Functions Technical Data

4 Technical Data

CPU 922 and CPU 928

Block Lib. No.: Block Runtime (ms) Scratchpadflag System data Lib. No.
No. Name P71200-S.. lengtt CPU CPU assignment assignment (L1MT23
922 928 ST.S5D)

FB 101 SINUS -9101-D-01 242 3.8 2.4 FY 246 - FY 255 R1243 - R1255 906
FB 102 COSINUS -9102-D-01 238 3.8 2.4 FY 246 - P/ 255 R1243 - R1255 906
FB 103 TAN- -9103-D-01 318 4.0 2.5 FY 246 - FY 255 R1243 - R1 255 906
FB 104 GENS- -9104-D-01 321 4.0 2.5 FY 246- FY 255 R1243- R1255 906
COTANG

FB 105 ASCSIN -9105-D-01 218 3.5 2.2 P/ 246- P/ 255 R1243 - R1255 907
FB 106 ARCCOS -9106-D-01 253 3.7 2.3 FY 246- FY 255 R1243 - R1255 910
FB 107 ARCTAN -9107-D-01 268 4.2 2.6 FY 246- FY 255 R1243 - R1255 913
FB 108 ARCCOT -9108-D-01 269 4.3 2.7 FY 246 - FY255 R1243 - R1255 913

FB 109 LNX -9109-D-01 222 4.3 2.9 FY 244 - FY 255 R1242 - R1 255 906
FBI10 LGX -91 10-D-01 222 4.3 2.9 FY244- W 2 5 5 R1242- R1 255 906
FB 111 B LOG X -91 11-D-01 274 7.6 5.1 FY 236 - FY 255 R1236 - R1 255 906

FBI12 EAX -9112-D-01 253 4.5 3.0 FY 246 - FY 255 R1243 - R1255 913
FB 113 ZEHNAX -9113-D-01 260 4.6 3.1 FY 246 - FY 255 R1243 - R1 255 906
FB 114 A2"Al -9114-D-01 418 7.4 4.9 FY 244 - FY 255 R1242 - R1255 906

Table 4.1 Technical data for CPU 922 and CPU 928

O Siemens AG C790MTB8576-C667-01
Technical Data Mathematical Functions

CPU 9461947

FB 105 ASCSIN -6105-D-01 203 0.35 FY 246 - FY 255 RI 243 - R1 255 910
FB 106 ARCCOS -6106-D-01 238 0.35 FY 246 - FY 255 R1 243 - R1 255 910
FB 107 ARCTAN -6107-D-01 260 0.45 FY246-FY255 R1243-R1255 913
FB 108 ARCCOT -6108-D-01 265 0.45 FY 246 - FY 255 R1 243 - R1 255 913

FBI09 L N X -6109-D-01 206 0.50 FY 244 - FY 255 R1 242 - R1 255 829


FBI10 L G X -6110-D-01 210 0.50 FY 244 - FY 255 R1 242 - R1 255 829
FB 111 B LOG X -61 11-D-01 254 0.95 FY 236 - FY 255 R1 236 - R1 255 906

FBI12 EAX -6112-D-01 236 0.50 FY 246 - FY 255 R1 243 - R1 255 913
FB 113 ZEHNAX -6113-D-01 243 0.50 FY 246 - FY 255 R1 243 - R1 255 830
FB 114 A2"Al -6114-D-01 391 0.90 FY 244 - FY 255 R1 242 - R1 255 906

Table 4.2 Technical data for CPU 9461947

8 Siemens AG C79000-08576-'2667-01
Mathematical Functions Description of Individual Function Blocks

5 Description of Individual Function Blocks

5.1 Trigonometric Functions

Calling of function block FB 101 (SINUS)

Sine (X)
:L KG (X) Input value
:JU FB 101 Sine (X)
NAME :SINUS
:= Fx.y Errorflag l )
:T xx Result present in accumulator 1

Accumulator assignments

The function block expects the input value in accumulator 1 as


a 24132-bit floating-point number. The input value must be
within the range from zero (KG = +0000000 +00) to 2 sc (KG =
+6283185 +01). The function block also stores the result in
accumulator 1 as a 24132-bit floating-point number.

The input value OH = 0000 0000 is handled like a floating-point


value of zero (KG = +0000000 +00 corresponding to DH = 8000
0000).

If the calculation is carried out correctly, the result of the logic


operation following calling of the function block is "0".

In the event of an error, the function block sets the result of the
logic operation to a signal state "1" (if the input value is not
within the range from 0 to 2 X ) . The contents of accumulator 1
then remain unchanged.

The assignments of the other registers and of the scratchpad


flags are not changed.

The flags are set in the same manner as in the general function
description (see above).

1) Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.

8 Siemens AG C79000-08576-C667-01
Description of Individual Function Blocks Mathematical Functions

Calling of function block FB 102 (COSINUS)

Cosine (X)
:L KG (X) Input value
:JU FB 102 Cosine (X)
NAME :COSINUS
:= Fx.y Error flag l )
:T xx Resutt present in accumulator 1

Accumulator assignments

The function block expects the input value in accumulator 1 as


a 24132-bit floating-point number. The input value must be
within the range from zero (KG = +0000000 +00) to 2 . K (KG =
+6283185 +01). The function block also stores the result in
accumulator 1 as a 24132-bit floating-point number.

The input value DH = 0000 0000 is handled like a floating-point


value of zero (KG = +0000000 +00 corresponding to DH = 8000
0000).

If the calculation is carried out correctly, the result of the logic


operation following calling of the function block is "0".

In the event of an error, the function block sets the result of the
logic operation to a signal state "1" (if the input value is not
within the range from 0 to 2 K ) . The contents of accumulator 1
then remain unchanged.

The assignments of the other registers and of the scratchpad


flags are not changed.

The flags are set in the same manner as in the general function
description (see above).

1) Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.

O Siemens AG C79000-B8576-(2667-01
Mathematical Functions Description of Individual Function Blocks

Calling of function block FB 103 (TANGENS)

Tangent (X)
:L KG (X) Input value
:JU FB 103 Tangent (X)
NAME :TANGENS
:= Fx.y Error flag l )
:T xx Result present in accumulator 1

Accumulator assignments

The function block expects the input value in accumulator 1 as


a 24132-bit floating-point number. The input value must be
within the range from zero (KG = +0000000 +00) to 2 . n: (KG =
+6283185 +01). The function block also stores the result in
accumulator 1 as a 24132-bit floating-point number.

The input value DH = 0000 0000 is handled like a floating-point


value of zero (KG = +0000000 +00 corresponding to DH = 8000
0000).

If the calculation is carried out correctly, the result of the logic


operation following calling of the function block is "0".

In the event of an error, the function block sets the result of the
logic operation to a signal state "1". The contents of
accumulator 1 then remain unchanged. One of the following
errors is present:
The input value is not within the range from 0 to 2 . 7 ~ .
The number range was exceeded during calculation of the
function.
The input value is d 2 (KG = +l570796 +01) or 3 . x 12 (KG
= +4712389 +01). The f~nction~value is then infinite and the
function block signals an error. )

The assignments of the other registers and of the scratchpad


flags are not changed.

The flags are set in the same manner as in the general function
description (see above).

1) Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.
2) The numbers specified apply to a calculation with a 24-bit mantissa. With a
16-bit mantissa, an error is signalled in the ranges KG = +l570740 +01 to
+l570801 +01 and KG = +4712158 +01 to +4712402 +01.

O Siemens AG C79000-68576-C667-01
Description of Individual Function Blocks Mathematical Functions

Calling of function block FB 104 (COTANG)

Cotangent (X)
:L KG (X) Input value
:JU FB 104 Cotangent (X)
NAME :COTANG
:= Fx.y Error flag l )
:T xx Result present in accumulator 1

Accumulator assignments

The function block expects the input value in accumulator 1 as


a 24132-bit floating-point number. The input value must be
within the range from KG = +2938734 -34 to (almost) 2 . x (KG
= +6283184 +01). The function block also stores the result in
accumulator 1 as a 24132-bit floating-point number.

The input value DH = 0000 0000 is handled like a floating-point


value of zero (KG = +0000000 +00 corresponding to DH = 8000
0000).

If the calculation is carried out correctly, the result of the logic


operation following calling of the function block is "0".

In the event of an error, the function block sets the result of the
logic operation to a signal state "1".The contents of
accumulator 1 then remain unchanged. One of the following
errors is present:
The input value is not within the range from KG = +2938734
-34 to KG = +6283184 +01.2)
The number range was exceeded during calculation of the
function.
The input value is 0, .rc (KG = +3141593 +01) or 2 x (KG
= +6283185 +01). The function value is then infinite and the
function block signals an error.3)

1) Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.
2) All central processors calculate the function value within the defined limits.
The range can be expanded slightly depending on the CPU used or on
whether the calculation is carried out with a l b b i t or 24-bit mantissa.
3) The numbers specified apply to a calculation with a 24-bit mantissa. With a
16-bit mantissa, an error is signalled in the range KG = +3141479 +01 to
+3141602 +01.

Q Siemens AG C79000-58576-C667-01
Mathematical Functions Description of Individual Function Blocks

The assignments of the other registers and of the scratchpad


flags are not changed.

The flags are set in the same manner as in the general function
description (see above).

O Siemens AG C79000-68576-C667-01
Description of Individual Function Blocks Mathematical Functions

5.2 Arc Functions

Calling of function block FB 105 (ARCSIN)

Arc sine (X)


:L KG(x) Inputvalue
:JU FB 105 Arc sine (X)
NAME :ARCSIN
:= Fx.y Errorflag l )
:T xx Result present in accumulator 1

Accumulator assignments

The function block expects the input value in accumulator 1 as


a 24132-bit floating-point number. The input value must be
within the range from -1 (KG = -1000000 +01) to +l (KG =
+l000000 +01). The function block also stores the result in
accumulator 1 as a 24132-bit floating-point number.

The input value DH = 0000 0000 is handled like a floating-point


value of zero (KG = +0000000 +00 corresponding to DH = 8000
0000).

If the calculation is carried out correctly, the result of the logic


operation following calling of the function block is "0".

In the event of an error, the function block sets the result of the
logic operation to a signal state "1" (if the input value is not
within the range from -1 to +l). The contents of accumulator 1
then remain unchanged.

The assignments of the other registers and of the scratchpad


flags are not changed.

The flags are set in the same manner as in the general function
description (see above).

1) Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.

O Siemens AG C79000-B8576-C667-01
Mathematical Functions Description of Individual Function Blocks

Calling of function block FB 106 (ARCCOS)

Arc cosine (X)


:L KG (X) Input value
:JU F B I 0 6 Arccosine(x)
NAME :ARCCOS
:= F x.y Error flag l)
:T xx Result present in accumulator 1

Accumulator assignments

The function block expects the input value in accumulator 1 as


a 24132-bit floating-point number. The input value must be
within the range from -1 (KG = -1000000 +01) to +l (KG =
+l000000 +01). The function block also stores the result in
accumulator 1 as a 24132-bit floating-point number.

The input value DH = 0000 0000 is handled like a floating-point


value of zero (KG = +0000000 +00 corresponding to DH = 8000
0000).

If the calculation is carried out correctly, the result of the logic


operation following calling of the function block is "0".

In the event of an error, the function block sets the result of the
logic operation to a signal state "1" (if the input value is not
within the range from -1 to +l). The contents of accumulator 1
then remain unchanged.

The assignments of the other registers and of the scratchpad


flags are not changed.

The flags are set in the same manner as in the general function
description (see above).

1 ) Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.

O Siemens AG C79000-B8576-C667-01
Description of Individual Function Blocks Mathematical Functions

Calling of function block FB 107 (ARCTAN)

Arc tangent (X)


:L KG (X) Input value
:JU FB 107 Arc tangent (X)
NAME :ARCTAN
:= F x.y Error flag l )
:T xx Result present in accumulator 1

Accumulator assignments

The function block expects the input value in accumulator 1 as


a 24132-bit floating-point number. The function block also stores
the result in accumulator 1 as a 24/32-bit floating-point number.

The input value DH = 0000 0000 is handled like a floating-point


value of zero (KG = +0000000 +00 corresponding to DH = 8000
0000).

A result of +d2 (KG = +l570796 +01) is output with an input


value greater than KG = +l209486 +07, a result of -IT 12 (KG =
-1570796 +01) is output with an input value less than KG =
-5773456 +07.

The result of the logic operation is set to a signal state of "0"

The assignments of the other registers and of the scratchpad


flags are not changed.

The flags are set in the same manner as in the general function
description (see above).

1) Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.

C
2 Siemens AG C79000-B8576-C667-01
Mathematical Functions Description of Individual Function Blocks

Calling of function block FB 108 (ARCCOT)

Arc cotangent (X)


:L KG (X) Input value
:JU FB 108 Arc cotangent (X)
NAME :ARCCOT
:= Fx.y Errorflag l )
:T xx Result present in accumulator 1

Accumulator assignments

The function block expects the input value in accumulator 1 as


a 24132-bit floating-point number. The function block also stores
the result in accumulator 1 as a 24132-bit floating-point number.

The input value DH = 0000 0000 is handled like a floating-point


value of zero (KG = +0000000 +00 corresponding to DH = 8000
0000).

A result of 0 (KG = +0000000 +00) is output with an input value


greater than KG = +l 209486 +07, a result of x (KG =
+3141593 +O1) is output with an input value less than KG =
-5773456 +07.

The result of the logic operation is set to a signal state of "0".

The assignments of the other registers and of the scratchpad


flags are not changed.

The flags are set in the same manner as in the general function
description (see above).

1) Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.

Q Siemens AG C79000-88576-C667-01
Description of Individual Function Blocks Mathematical Functions

5.3 Logarithmic Functions

Calling of function block FB 109 (LN X)

Napierian logarithm
loge (X)
:L KG (X) Input value
:JU FB 109 Napierian logarithm loge (X)
NAME :LN X
:= Fx.y Error flag l )
:T xx Resutt present in accumulator 1

Accumulator assignments

The function block expects the input value in accumulator 1 as


a 24132-bit floating-point number. The input value must be
greater than zero. The function block also stores the result in
accumulator 1 as a 24132-bit floating-point number.

If the calculation is carried out correctly, the result of the logic


operation following calling of the function block is "0".

In the event of an error, the function block sets the result of the
logic operation to a signal state "1" (if the input value is less
than or equal to 0). The contents of accumulator 1 then remain
unchanged.

The assignments of the other registers and of the scratchpad


flags are not changed.

The flags are set in the same manner as in the general function
description (see above).

1) Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.

C3 Siemens AG C790M)-B8576-C667-01
Mathematical Functions Description of Individual Function Blocks

Calling of function block FB 110 (LG X)

Decimal logarithm
log10 (X)
:L KG (X) Input value
:JU FB 110 Decimal logarithm log10 (X)
NAME :LG X
:= Fx.y Errorflag
:T xx Result present in accumulator 1

Accumulator assignments

The function block expects the input value in accumulator 1 as


a 24132-bit floating-point number. The input value must be
greater than zero. The function block also stores the result in
accumulator 1 as a 24132-bit floating-point number.

If the calculation is carried out correctly, the result of the logic


operation following calling of the function block is "0".

In the event of an error, the function block sets the result of the
logic operation to a signal state "1" (if the input value is less
than or equal to 0). The contents of accumulator 1 then remain
unchanged.

The assignments of the other registers and of the scratchpad


flags are not changed.

The flags are set in the same manner as in the general function
description (see above).

1) Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.
Description of Individual Function Blocks Mathematical Functions

Calling of function block FB 111 (B LOG X)

General logarithm
log (X) to base b
:L KG (b) lnput value (base)
:L KG (X) Input value (number)
:JU FB 111 General logariihm log (X)to base b
NAME :B LOG X
:= F x.y Error flag l)
:T xx Result present in accumulator 1

Accumulator assignments

The function block expects the input value for the base (b) in
accumulator 2 and the input value for the number (X) in
accumulator 1, both as 24132-bit floating-point numbers. Both
input values must be greater than zero; in addition, the base
must not have a value of +l. The function block also stores the
result in accumulator 1 as a 24132-bit floating-point number.

If the calculation is carried out correctly, the result of the logic


operation following calling of the function block is "0".

In the event of an error, the function block sets the result of the
logic operation to a signal state "1" (ifthe input value is less
than or equal to 0 or if the base has a value of +l). The
contents of the accumulators then remain unchanged.

If the calculation is carried out correctly, the result is present in


accumulator 1, the previous contents of accumulator 3 are
present in accumulator 2, and the previous contents of
accumulator 4 are present in accumulator 3. The contents of
accumulator 4 are not changed.

The assignments of the scratchpad flags are not changed.

The flags are set in the same manner as in the general function
description (see above).

l)Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.

Q Siemens AG C79000-58576-C667-01
Mathematical Functions Description of Individual Function Blocks

5.4 Exponential Functions

Calling of function block FB 112 (E A N)

e to power n
:L KG (X) Input value
:JU FBI12 etopowern
NAME :EAN
:= Fx.y Errorflag l)
:T xx Result present in accumulator 1

Accumulator assignments

The function block expects the input value in accumulator 1 as


a 24132-bit floating-point number. The function block also stores
the result in accumulator 1 as a 24132-bit floating-point number.

The input value DH = 0000 0000 is handled like a floating-point


value of zero (KG = +0000000 +00 corresponding to DH = 8000
0000).

If the calculation is carried out correctly, the result of the logic


operation following calling of the function block is "0".

In the event of an error, the function block sets the result of the
logic operation to a signal state "1" (if the input value is not
within the range from KG = -8802962 +02 to KG = +8802966
+02; the function value would then be outside the numeric
range). The ntents of accumulator 1 then remain
unchanged. f?
The assignments of the other registers and of the scratchpad
flags are not changed.

The flags are set in the same manner as in the general function
description (see above).

1) Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.
2) All central processors calculate the function value within the defined limits.
The range can be expanded slightly depending on the CPU used or on
whether the calculation is carried out with a 16-bit or 24-bit mantissa.

O Siemens AG C79000-58576-C667-01
Description of Individual Function Blocks Mathematical Functions

Calling of function block FB 113 (ZEHN A N)

10 to power n
:L KG (n) Input value
:JU FBI13 10topowern
NAME :ZEHNAN
:= Fx.y Errorflag
:T xx Resutt present in accumulator 1

Accumulator assignments

The function block expects the input value in accumulator 1 as


a 24132-bit floating-point number. The function block also stores
the result in accumulator 1 as a 24132-bit floating-point number.

The input value DH = 0000 0000 is handled like a floating-point


value of zero (KG = +0000000 +00 corresponding to DH = 8000
0000).

If the calculation is carried out correctly, the result of the logic


operation following calling of the function block is "0".

In the event of an error, the function block sets the result of the
logic operation to a signal state "1" (if the input value is not
within the range from KG = -3823079 +02 to KG = +3823080
+02; the function value would then be outside the numeric
range). The ontents of accumulator 1 then remain
unchanged.27

The assignments of the other registers and of the scratchpad


flags are not changed.

The flags are set in the same manner as in the general function
description (see above).

1) Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.
2) All central processors calculate the function value within the defined limits.
The range can be expanded slightly depending on the CPU used or on
whether the calculation is carried out with a 16-bit or 24-bit mantissa.

O Siemens AG C79000-68576-C667-01
Mathematical Functions Description of Individual Function Blocks

Calling of function block FB 114 (A2 A A I )

Accumulator 2 to power
accumulator l
:L KG (a2) Input value (base)
:L KG (al) Input value (exponent)
:JU F6 114 Accumulator 2 to power accumulator 1
NAME :A2AA1
:= Fx.y Errorflag l )
:T xx Result present in accumulator 1

Accumulator assignments

The function block expects the input value for the base in
accumulator 2 and the input value for the exponent in
accumulator 1, both as 24132-bit floating-point numbers. The
input value for the base must be positive. The function block
also stores the result in accumulator 1 as a 24132-bit
floating-point number.

The input value DH = 0000 0000 is handled like a floating-point


value of zero (KG = +0000000 +00 corresponding to DH = 8000
0000).

A result of zero is output for zero to power zero.

If the calculation is carried out correctly, the result of the logic


operation following calling of the function block is "0".One of
the following errors is present if the result of the logic operation
is "1":
The input value for the base is less than zero.
The number range was exceeded during calculation of the
function.

The contents of accumulators 1 and 2 remain unchanged in the


event of an error.

If the calculation is carried out correctly, the result is present in


accumulator 1, the previous contents of accumulator 3 are
present in accumulator 2, and the previous contents of
accumulator 4 are present in accumulator 3. The contents of
accumulator 4 are not changed.

The assignments of the other registers and of the scratchpad


flags are not changed.

1) Error analysis is also possible using the result of the logic operation with a
conditional jump JC or using the overflow bit Ov with a jump with overflow
JO.

C
B Siemens AG C79000-68576-C667-01
Description of Individual Function Blocks Mathematical Functions

The flags are set in the same manner as in the general function
description (see above).

O Siemens AG C79000-68576-C667-01

You might also like