F350_FMAX

Maximum value search in real number data table (floating point data)

The function searches for the maximum value and its position in a floating point data table.

Parameters

Input

s1_Start (REAL)

Beginning of data table

s2_End (REAL)

End of data table

Output

Max (REAL)

maximum value

Pos (INT)

position of maximum value

Remarks

  • Input s1_Start specifies the starting area of the data table, and s2_End specifies the end. The maximum value is returned at output Max and its position at output Pos.

  • The position Pos is relative to the position at the beginning of the data table to the first occurrence of the maximum value.

  • If more than one maximum value is found, the first one found beginning from the starting address specified at s1_Start is stored in Max.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the address of the variable at input s1_Start > s2_End.

  • if the address areas of s1_Start and s2_End are different.

  • if the floating point values exceed the processing range.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the address of the variable at input s1_Start > s2_End.

  • if the address areas of s1_Start and s2_End are different.

  • if the floating point values exceed the processing range.

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
		start: BOOL:=FALSE;
			(*activates the function*)
		data_array: ARRAY [0..4] OF REAL:=[4.0,7.0,-32.0,13.0,5.0];
		output_max: REAL:=0.0;
			(*the maximum value of 
data_array; here: -32.0*)
		output_pos: INT:=0;
			(*the position of the
maximum value; here: 2*)
	END_VAR

POU body

When the variable start is set to TRUE, the function is carried out.

It then searches the data_field for a maximum value and its position. The result here is: max_value = 5.44 and position = 3.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 6 ;
        NETWORK_BODY
B(B_VARIN,,output,8,1,10,3,);
B(B_VARIN,,data field[0],8,2,10,4,);
B(B_VARIN,,data field[4],8,3,10,5,);
B(B_VAROUT,,max_value,19,2,21,4,);
B(B_F,F350_FMAX,,10,0,19,5,,?DEN?D@'s1'?Ds2?AENO?Cmax?Cpos);
B(B_VAROUT,,position,19,3,21,5,);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF start then
    F350_FMAX( s1_Start:= data_field[0],
        s2_End:= data_field[4],
        Max=> max_value,
        Pos=> position);
END_IF;

IL body

Modified on: 2020-06-04Feedback on this pagePanasonic hotline