IMC: Compare input bits with the bits of a mask (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
IMC: Compare input bits with the bits of a mask

Description

You can use the "Compare input bits with the bits of a mask" instruction to compare the signal state of up to 16 programmed input bits (IN_BIT0 to IN_BIT15) with the corresponding bits of a mask. Up to 16 steps with masks can be programmed. The value of the IN_BIT0 parameter is compared with the value of the mask CMP_VAL[x,0], with "x" indicating the step number. In the CMP_STEP parameter, you specify the step number of the mask that is used for the comparison. All programmed values are compared in the same manner. Unprogrammed input bits or unprogrammed bits of the mask have the default signal state FALSE.

If a match is found in the comparison, the signal state of the OUT parameter is set to "1". Otherwise the OUT parameter is set to "0".

If the value of the CMP_STEP parameter is greater than 15, the instruction is not executed. An error message is output at the ERR_CODE parameter.

Parameters

The following table shows the parameters of the "Compare input bits with the bits of a mask" 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.

CMP_STEP

Input

BYTE

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

The step number of the mask used for the comparison.

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

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

000A

The value at the CMP_STEP 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".