[LGRTM] Logarithm functions

Function block LGRTM calculates the logarithm from an input value to a configured base.

LGRTM calculates the logarithm (natural, binary, decimal, any) based on the configured calculation mode.

Functioning

The calculation mode [CalcMod] determines the type of logarithm. Input [Base] is configured as the base for calculating in calculation mode 4. The result is provided at the output [Out].

Calculation mode

Logarithm

Function

Condition

1

Natural, to base

e (Euler's number)

Out = Loge(In)

In > 0.000

e = 2.718

2

Binary, to base 2

Out = Log2(In)

In > 0.000

3

Decimal, to base 10

Out = Log10(In)

In > 0.000

4

Any, to base X

Out = LogBase(In)

In > 0.000

Base > 0.000

Base <> 1.000

Pins

Input

Description

Data type

Default value
Value range

In

Input

Real

1.0

Base

Base

Real

10.0

CalcMod

Calculation mode

Determines the type of logarithm.

Integer

1: Natural

1…4

1: Natural - Natural logarithm
2: Base 2 - Binary logarithm
3: Base 10 - Decimal logarithm
4: Base X - Any logarithm

 

Output

Description

Data type

Default value
Value range

Out

Output

Real

0.0

Troubleshooting

The output [Out] is set to the smallest permissible Real value (-3.4 E38) whenever a faulty value is set at one of the inputs [CalcMod], [Base] or [In]. The input [Base] for the "any" base ([CalcMod] = 4) cannot be 1.0, 0.0 or negative. If the minimum or maximum permissible real values are mathematically exceeded, the value is set on the output per the minimum or maximum permissible value.

Error

Cause of fault

Correcting the fault

The result on output is:

[Out] = 3.4 E38

[Out] = -3.4 E38

The result on output is mathematically outside the permissible value range:

[Out] > 3.4 E38

[Out] < -3.4 E38

Select input values that are not outside the range of -3.4 E38 to 3.4 E38.

The minimum permissible value -3.4 E38 is set on the output:

[Out] = -3.4 E38

Impermissible input values:
[CalcMod] < 1

[CalcMod] > 4

For [CalcMod] = 4, [Base] <= 0.0 or [Base] = 1.0

Set permissible input values:

[CalcMod] = 1…4

For [CalcMod] = 4, [Base]  > 0.0 and [Base]  <> 1.0