Logarithm to the base 10
LOG calculates the logarithm of the input variable (value > 0.0) to the base 10 and writes the result into the output variable.
Input
Input value
Output
Output as input: logarithm of input value
if input variable does not have the data type REAL, LREAL or input variable is not > 0.0
if input variable does not have the data type REAL, LREAL or input variable is not > 0.0
if output variable is zero
if processing result overflows the output variable
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
This example uses variables. You can also use a constant for the input variable.
The logarithm of input_value is calculated to the base 10 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_VARIN,,input_value,7,0,9,2,);
B(B_VAROUT,,output_value,14,0,16,2,);
B(B_F,LOG!,Instance,9,0,14,2,,?D?C);
L(1,0,1,2);
END_NETWORK_BODY
END_NET_WORK
END_BODY
output_value:=LOG(input_value);
LD |
input_value |
LOG |
|
ST |
output_value |