MAX: Get maximum (S7-1200, S7-1500) - STEP 7

FBD (S7-1200, S7-1500)

ft:publication_title
FBD (S7-1200, S7-1500)
Product
STEP 7
Version
V20
Publication date
11/2024
Language
en-US
MAX: Get maximum

Description

The "Get maximum" instruction compares the values at the available inputs and writes the highest value to the OUT output. The number of inputs can be expanded at the instruction box by additional inputs. The inputs are numbered in ascending order in the box.

In its initial state the instruction contains at least two inputs (IN1 and IN2) and no more than 100 inputs.

The enable output ENO has the signal state "0" if one of the following conditions applies:

  • Enable input EN has the signal state "0".

  • The implicit conversion of the data types fails during execution of the instruction.

  • A floating-point number has an invalid value.

Parameters

The following table shows the parameters of the "Get maximum" instruction:

Parameters

Declaration

Data type

Memory area

Description

S7-1200

S7-1500

EN

Input

BOOL

I, Q, M, D, L or constant

I, Q, M, D, L, T, C or constant

Enable input

ENO

Output

BOOL

I, Q, M, D, L

I, Q, M, D, L

Enable output

IN1

Input

Integers, floating-point numbers, DTL, DT

I, Q, M, D, L, P or constant

I, Q, M, D, L, P or constant

First input value

IN2

Input

Integers, floating-point numbers, DTL, DT

I, Q, M, D, L, P or constant

I, Q, M, D, L, P or constant

Second input value

INn

Input

Integers, floating-point numbers, DTL, DT

I, Q, M, D, L, P or constant

I, Q, M, D, L, P or constant

Additionally inserted inputs whose values are to be compared.

OUT

Output

Integers, floating-point numbers, DTL, DT

I, Q, M, D, L, P

I, Q, M, D, L, P

Result

If the IEC check is not enabled, you can also use tags of the data type TIME, LTIME, TOD, LTOD, DATE and LDT by selecting a bit string of the same length as the data type. (e.g. instead of TIME => DINT, UDINT or DWORD = 32 bits)

You can select the data type of the instruction from the "???" drop-down list of the instruction box.

For additional information on valid data types, refer to "See also".

Example

The following example shows how the instruction works:

The following table shows how the instruction works using concrete operand values:

Parameters

Operand

Value

IN1

TagIn_Value1

12222

IN2

TagIn_Value2

14444

IN3

TagIn_Value3

13333

OUT

TagOut_Value

14444

If the operands "TagIn_1" and "TagIn_2" have signal state "1", the instruction is executed. The instruction compares the values of the specified operands and copies the highest value ("TagIn_Value2") to output "TagOut_Value". If the instruction is executed without errors, the "TagOut" output is set.