LN

Natural logarithm

LN calculates the logarithm of the input variable (value > 0.0) to the base e (Euler’s number = 2.7182818) and writes the result into the output variable. This function is the reversion of the EXP function.

Parameters

Input

Unnamed input (REAL, LREAL)

Input value

Output

Unnamed output (REAL, LREAL)

Output as input: natural logarithm of input value

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)

if input variable does not have the data type REAL, LREAL or input variable is not > 0.0

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)

if input variable does not have the data type REAL, LREAL or input variable is not > 0.0

sys_bIsEqual (turns to TRUE and remains TRUE)

if output variable is zero

sys_bIsCarry (turns to TRUE for one scan)

if processing result overflows the output variable

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		input_value: REAL:=0.0;
			(*number > 0.0*)
		output_value: REAL:=0.0;
			(*number unequal 0*)
	END_VAR
	VAR
		input_value: REAL:=0.0;
			(*number > 0.0*)
		output_value: REAL:=0.0;
			(*number unequal 0*)
	END_VAR

This example uses variables. You can also use a constant for the input variable.

LD body

The logarithm of input_value is calculated to the base e and written into output_value.

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 2 ;
        NETWORK_BODY
B(B_F,LN!,Instance,8,0,13,2,,?D?C);
B(B_VARIN,,input_value,6,0,8,2,);
B(B_VAROUT,,output_value,13,0,15,2,);
L(1,0,1,2);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

output_value:=LN(input_value);

IL body

LD

input_value

LN

ST

output_value

Modified on: 2022-08-23Feedback on this pagePanasonic hotline