Siemens 200PLC instruction detailed explanation - comparison instruction

1. Comparison instruction

As shown in the figure below, comparison instructions include numerical comparison instructions and string comparison instructions.

Among them, numerical comparison includes byte comparison, int comparison, double word comparison, and real number comparison instructions .

For the value comparison instruction, it is like this. The value above the comparison instruction is compared with the value below the instruction . When the condition is met, the contact is turned on, otherwise the contact is closed.

For example, if EM0_Err is equal to 10, the contact will be connected, otherwise it will always be closed.

One point needs to be emphasized: the types of the two operands input by the comparison instruction must be consistent .

In addition, from the comparison type, comparison instructions can be divided into: equal, not equal, greater than or equal to, less than or equal to, greater than, less than

Valid operands for comparison instructions are as follows: 

Note the fatal error as follows 

2. Comparison instruction case 

The comparison instruction example program is as follows

 3. String comparison instructions

The string comparison instruction actually compares the ASCII code characters of the two strings. If all the ASCII codes of the two strings are the same, the two strings are equal , otherwise the strings are not equal .

Note: The length of the string to compare cannot exceed 254 characters

String equality comparison instruction: if the two strings are equal, the contact will be connected, otherwise it will be disconnected

String unequal comparison instruction: if the two strings are not equal, the contact will be connected, otherwise it will be disconnected

The following table lists the valid operands for string comparison instructions:

Guess you like

Origin blog.csdn.net/xipengbozai/article/details/125650719