MAX_2D_ARRAY block

Short summary

Name

MAX_2D_ARRAY_LINT, MAX_2D_ARRAY_ULINT, MAX_2D_ARRAY_LREAL

→POU type

→function

Category

Standard (non-safe), NumericEnh, block with internal error diagnostic

Conform to →IEC-standard

(plus) not defined in IEC-standard

Graphical interface

, ,

Available since

version 1.45.0 (for Neuron Power Engineer) – initial variant

version 2.0.9 (for library Standard) – graphical interface with in-out variable

version 3.8.0 (for library Standard (non-safe)): block moved in this library

Functionality

The block returns the largest of all values of an array with 2 dimensions entered at input A. Only the first M rows and N columns are considered. The array must contain at least M rows and N columns.

Inputs, return value

MAX_2D_ARRAY_LINT

Identifier

→Data type

Description

In-outs
(VAR_IN_OUT):

A

ARRAY [*,*] OF SINT, INT, DINT or LINT
(corresponds to →generic data type ANY_SIGNED)  

variable-length array

Inputs:

M

UINT

number of rows to consider

N

UINT

number of columns to consider

Return value:

LINT

  • maximum value

  • 0 in case of an error or if M or N = 0

 

MAX_2D_ARRAY_ULINT

Identifier

→Data type

Description

In-outs
(VAR_IN_OUT):

A

ARRAY [*,*] OF USINT, UINT, UDINT or ULINT
(corresponds to →generic data type ANY_SIGNED)  

variable-length array

Inputs:

M

UINT

number of rows to consider

N

UINT

number of columns to consider

Return value:

ULINT

  • maximum value

  • 0 in case of an error or if M or N = 0

 

MAX_2D_ARRAY_LREAL

Identifier

→Data type

Description

In-outs
(VAR_IN_OUT):

A

ARRAY [*,*] OF REAL, LEAL
(corresponds to →generic data type ANY_REAL)  

variable-length array

Inputs:

M

UINT

number of rows to consider

N

UINT

number of columns to consider

Return value:

LREAL

  • maximum value

  • 0.0 in case of an error or if M or N = 0

Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

See:

Internal error diagnostic for block

The block checks whether the size of the array for A contains at least M rows and N columns. If this is not the case, the output ENO of the block is set to value FALSE (or an equivalent).

Example for usage within ST-editor

FUNCTION_BLOCK ExampleMax2DArray
    VAR
        inputArray : ARRAY [1..2, -1..1] OF LINT := [2( [1, 2, 3])];
        result1, result2 : LINT;
        enoCheck1, enoCheck2 : BOOL;
    END_VAR
    
    result1 := MAX_2D_ARRAY_LINT(A := inputArray, M := 2, N := 3, ENO => enoCheck1);
    // 'result1' evaluates to value '3'. 'enoCheck1' evaluates to 'TRUE'.
    ENO := AND(result1 = 3, enoCheck1);
    
    result2 := MAX_2D_ARRAY_LINT(A := inputArray, M := 3, N := 2, ENO => enoCheck2);
    // 'enoCheck2' evaluates to 'FALSE' because 'inputArray' has only 2 rows.
    // 'result2' evaluates to '0'.      
    ENO := AND(ENO, result2 = 0, NOT(enoCheck2));
    
END_FUNCTION_BLOCK

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.