The leader in industrial automation and control solutions

Instruction Parameters

Supported PLC Series

PLC-AESPLC-FBPLC-ES

Supported Data Registers

MXYKLFTCSZRQD@DConstant
S
D
n

Supported Flags

FlagBitSupport
ErrorF11.0
ZeroF11.1
CarryF11.2

Number of Steps

Steps
4

Operands

OperandDescription
SThe first operand.
Entries are only DWORD data registers.
This is the starting register to find the largest possible number.

The signed value range is -2,147,483,648 ~ 2,147,483,647 (232).
The unsigned value range is 0 ~ 4,294,967,295 (232-1).
The Hexadecimal value range is H00000000 ~ HFFFFFFFF.
DThe second operand.
Entries are only DWORD data registers.
This is where the maximum value found and its data register are saved.
This requires 1 DWORD (D~D+1) and 2 WORD (D+2 & D+3) data registers.
nThe third operand.
Entries are WORD data registers or constants.
This is the amount of data registers to search through starting at D.

The value range is 1 ~ 32,767 (215-1).

Notice

Error Flag (F11.0) Notice

The error flag, F11.0, will be ON for one scan when the address of the data register assigned by @D exceeds the range of the data register, D. The range of the data register, D, is dependent on the CPU type. F11.0 turns ON when the value of the data for n exceeds the value range 1 ~ 32,767 (215-1).

Instruction Behavior

The DMAX and DMAXP instructions behave as follows:

  • Both instructions require 4 data registers starting at the data register, D.
    • D and D+1 save the maximum number found in the search range.
    • D+2 saves the first occurrence index of the maximum number found in the search range.
    • D+3 saves the amount of times the maximum number was found in the search range.
  • If n is less than 1 or greater than 32,767, neither instruction will execute.

Ladder Diagram Examples

DMAX

The DMAX instruction searches n number of DWORD data registers, starting at S, for the maximum possible value. The result of the search is saved in 4

The DMAX instruction searches n number of DWORD data registers, starting at S, for the maximum possible value. The result of the search is saved in 4 assigned data registers starting at D.

When the contact, M0.2 is ON (1), the instruction finds the maximum DWORD value of 4 data registers, D10, D12, D14, and D16.

When the contact, M0.2 is ON (1), the instruction finds the maximum DWORD value of 4 data registers, D10, D12, D14, and D16. The largest value found is saved in D19. The position in which the data register was found is saved in D21. The total amount of times the number is found is saved in D22.

Ladder Diagram Example for MapleLogic DMAX/DMAXP instruction.

Result

Result for MapleLogic DMAX/DMAXP instruction.

DMAXP

The DMAXP one-shot instruction searches n number of DWORD data registers, starting at S, for the maximum possible value. The result of the search is s

The DMAXP one-shot instruction searches n number of DWORD data registers, starting at S, for the maximum possible value. The result of the search is saved in 4 assigned WORD data registers starting at D. Every time this instruction executes, it energizes the output only once.

When the contact, M0.3 is ON (1), the instruction finds the maximum DWORD value of 3 data registers, D20, D22, and D24.

When the contact, M0.3 is ON (1), the instruction finds the maximum DWORD value of 3 data registers, D20, D22, and D24. The largest value found is saved in D27. The position in which the data register was found is saved in D29. The total amount of times the number is found is saved in D30.

Ladder Diagram Example for MapleLogic DMAX/DMAXP instruction.

Result

Result for MapleLogic DMAX/DMAXP instruction.