FP_DATA_MIN_POS

Search minimum value in data table

This FP instruction determines the minimum value and its position in a data table.

Parameters

Input

s1_Start (INT, DINT, UINT, UDINT, REAL, LREAL)

Beginning of data table

s2_End (INT, DINT, UINT, UDINT, REAL, LREAL)

End of data table

Output

d1_Min (INT, DINT, UINT, UDINT, REAL, LREAL)

Minimum value

d2_Pos (DINT)

Position of minimum value

Remarks

  • Input s1_Start specifies the beginning of the data table, and s2_End specifies the end. The minimum value is returned at output d1_Min and its position at output d2_Pos.

  • The position d2_Pos is the position of the first occurrence of the minimum value relative to the beginning of the data table.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the area specified using the index modifier exceeds the limit.

  • if s1_Start > s2_End

  • if s1_Start and s2_End belong to different data areas.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the area specified using the index modifier exceeds the limit.

  • if s1_Start > s2_End

  • if s1_Start and s2_End belong to different data areas.

Related topics:

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
		bStart: BOOL:=FALSE;
			(*activates the function*)
		adiDataField: ARRAY [0..4] OF DINT:=[2,3,222222,-333333,1];
		diOutputMin: DINT:=0;
			(*the maximum value of 
data_array; here: -333333*)
		diOutputPos: DINT:=0;
			(*the position of the
maximum value; here: 3*)
	END_VAR

POU body

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

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_CONTACT,,bStart,5,2,7,4,);
B(B_VARIN,,adiDataField[0],10,3,12,5,);
B(B_VARIN,,adiDataField[4],10,4,12,6,);
B(B_VAROUT,,diOutputMin,22,3,24,5,);
B(B_VAROUT,,diOutputPos,22,4,24,6,);
B(B_F,FP_DATA_MIN_POS!,,12,1,22,6,,?DEN?Ds1_Start?Ds2_End?AENO?Cd1_Min?Cd2_Pos);
L(1,3,5,3);
L(7,3,12,3);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF bStart then
    FP_DATA_MIN_POS(s1_Start := adiDataField[0], 
                    s2_End := adiDataField[4], 
                    d1_Max => diOutputMin, 
                    d2_Pos => diOutputPos);
END_IF;

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