LGF_SearchMinMax (FC / V3.0.1)

Overview

Author: Siemens Digital Industries

Short description

This function searches, in an array of the data type DInt, for the maximum and minimum value and the respective index in the array.

The following data types of the array elements are supported:
Int, DInt, UInt, UDInt, USInt, SInt, and Real.

Block Interface

LGF_SearchMinMax (FC)
Variant  variableArray Ret_Val  Void
    
   minValue  Variant
    
   minValueIndex  DInt
    
   maxValue  Variant
    
   maxValueIndex  DInt
    
   error  Bool
    
   status  Word
    
   subfunctionStatus  Word
    
   

Input parameter

IdentifierData type Description
variableArrayVariant Array in whose fields the maximum and minimum are searched

Output parameter

IdentifierData type Description
Ret_ValVoid Void - Function has no return value
minValueVariant Minimum value found in the array
minValueIndexDInt Index of the minimum found value in the array.
The start index of the array plus `minValueIndex` results in the array index of the smallest value. The index starts with 0.
maxValueVariant Maximum value found in the array
maxValueIndexDInt Index of the maximum found value in the array.
The start index of the array plus `maxValueIndex` results in the array index of the smallest value. The index starts with 0.
errorBool FALSE: No error
TRUE: An error occurred during the execution of the FB
statusWord 16#0000-16#7FFF: Status of the FB
16#8000-16#FFFF: Error identification (see following Table)
subfunctionStatusWord Status or return value of called FB's, FC's and system blocks

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_NO_ERROR
Execution finished without errors
16#8200ERR_NO_ARRAY
Error: At input `variableArray` the actual parameter is not an array
16#8201ERR_WRONG_TYPE
Error: The data type of the elements in the array is not supported. Only the data types Int, UInt, DInt, UDInt, USInt, SInt and Real are supported.
16#8202ERR_NOT_EQUAL_TYPES
Error: The elements of the array do not have the same data type as the outputs `minValue` and `maxValue`
16#8203ERR_MOVE_BLK_VARIANT
Error: Subfunction `MOVE_BLK_VARIANT` executed with and error - check `subFunctionStatus` code

Functional description

NOTE
The status of called commands is output in subFunctionStatus. In this case, the output value in status indicates which command caused the error. In this case, refer to the TIA Portal Online Help section for information on the respective commands.

An array of any size is connected via the variableArray input. After a data type query in the block, the elements are copied one after the other into a variable of the appropriate type and compared. The smallest and largest values, as well as their corresponding index are output to the array.

Note
The following data types of the array elements are supported:
Int, DInt, UInt, UDInt, USInt, SInt, and Real.

Note
If there are several identical min. or max. values, the index of the first min. or max. value is output.

Change log

Version & DateChange description
01.00.00Siemens Industry Online Support
19.08.2015First released version
01.00.01Siemens Industry Online Support
02.01.2017Upgrade: TIA Portal V14 Update 1
01.00.02Siemens Industry Online Support
17.08.2018Upgrade: TIA V15 Update 2
01.00.03Siemens Industry Online Support
23.11.2018Upgrade: TIA V15.1
01.01.00Siemens Industry Presales Support
08.11.2019Code refactoring, regions and more comments added
03.00.00Siemens Industry Support
23.04.2020Set version to V3.0.0, harmonize the version of the whole library
03.00.01Simatic Systems Support
09.02.2021Rework constants and comments
Insert documentation