SMC: Compare scan matrix (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
SMC: Compare scan matrix

Description

You can use the "Compare scan matrix" instruction to compare the signal state of up to 16 programmed input bits (IN_BIT0 to IN_BIT15) with the corresponding bit of the comparison masks for each step. Processing starts at step 1 and is continued until the last programmed step (LAST) or until a match is found. The input bit of the IN_BIT0 parameter is compared with the value of the mask CMP_VAL[x,0], with "x" indicating the step number. All programmed values are compared in the same manner. If a match is found, the signal state of the OUT parameter is set to "1" and the step number with the matching mask is written to the OUT_STEP parameter. Unprogrammed input bits or unprogrammed bits of the mask have the default signal state FALSE. If more than one step has a matching mask, only the first one found is indicated in the OUT_STEP parameter. If no match is found, the signal state of the OUT parameter is set to "0". In this case the value at the OUT_STEP parameter is greater by "1" than the value at the LAST parameter.

Parameters

The following table shows the parameters of the "Compare scan matrix" instruction:

Parameter

Declaration

Data type

Memory area

Description

EN

Input

BOOL

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

Enable input

ENO

Output

BOOL

I, Q, M, D, L

Enable output

IN_BIT0

Input

BOOL

I, Q, M, D, L or constant

Input bit 0 is compared with bit 0 of the mask.

IN_BIT1

Input

BOOL

I, Q, M, D, L or constant

Input bit 1 is compared with bit 1 of the mask.

IN_BIT2

Input

BOOL

I, Q, M, D, L or constant

Input bit 2 is compared with bit 2 of the mask.

IN_BIT3

Input

BOOL

I, Q, M, D, L or constant

Input bit 3 is compared with bit 3 of the mask.

IN_BIT4

Input

BOOL

I, Q, M, D, L or constant

Input bit 4 is compared with bit 4 of the mask.

IN_BIT5

Input

BOOL

I, Q, M, D, L or constant

Input bit 5 is compared with bit 5 of the mask.

IN_BIT6

Input

BOOL

I, Q, M, D, L or constant

Input bit 6 is compared with bit 6 of the mask.

IN_BIT7

Input

BOOL

I, Q, M, D, L or constant

Input bit 7 is compared with bit 7 of the mask.

IN_BIT8

Input

BOOL

I, Q, M, D, L or constant

Input bit 8 is compared with bit 8 of the mask.

IN_BIT9

Input

BOOL

I, Q, M, D, L or constant

Input bit 9 is compared with bit 9 of the mask.

IN_BIT10

Input

BOOL

I, Q, M, D, L or constant

Input bit 10 is compared with bit 10 of the mask.

IN_BIT11

Input

BOOL

I, Q, M, D, L or constant

Input bit 11 is compared with bit 11 of the mask.

IN_BIT12

Input

BOOL

I, Q, M, D, L or constant

Input bit 12 is compared with bit 12 of the mask.

IN_BIT13

Input

BOOL

I, Q, M, D, L or constant

Input bit 13 is compared with bit 13 of the mask.

IN_BIT14

Input

BOOL

I, Q, M, D, L or constant

Input bit 14 is compared with bit 14 of the mask.

IN_BIT15

Input

BOOL

I, Q, M, D, L or constant

Input bit 15 is compared with bit 15 of the mask.

OUT

Output

BOOL

I, Q, M, D, L

The signal state "1" indicates that a match was found.

A signal state of "0" indicates that no match was found.

ERR_CODE

Output

WORD

I, Q, M, D, L, P

Error information

OUT_STEP

Output

BYTE

I, Q, M, D, L, P

Contains the step number with the matching mask, or the step number which is greater by "1" than the value at the LAST parameter, provided no match is found.

LAST

Static

BYTE

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

Specifies the step number of the last step to be scanned for a matching mask.

CMP_VAL

Static

ARRAY OF WORD

I, Q, M, D, L or constant

Comparison masks [0 to 15, 0 to 15]: The first number of the index is the step number and the second number is the bit number of the mask.

ERR_CODE parameter

The following table shows the meaning of the values of the ERR_CODE parameter:

Error code*
(W#16#...)

Explanation

0000

No error

000E

The value at the LAST parameter is greater than 15.

*The error codes can be displayed as integer or hexadecimal value in the program editor. You can find information on switching the display formats under "See also".