Skip to main content

6.1.3.6.2 CMP

Function

Compare IN and VAL and output the result at OUT

LD Graphics

alt text

Parameter description

Interface variableDeclarationData typeDescription
ONVar_InputBOOLFunction input
INVar_InputANY_ELEMENTARYComparison value 1
VALVar_InputANY_ELEMENTARYComparison value 2
Return valueFunction valueBOOLResult output
warning
  • Function function can be changed by clicking on the equal sign (=) position in the graph:
    • Equal to: When the ON input is 1, if IN is equal to VAL, then OUT outputs 1; otherwise, it outputs 0
    • Greater than or equal to: When the ON input is 1, if IN is greater than or equal to VAL, then OUT outputs 1; otherwise, it outputs 0
    • Greater than: When the ON input is 1, if IN is greater than VAL, OUT outputs 1; otherwise, it outputs 0
    • Less than or equal to: When the ON input is 1, if IN is less than or equal to VAL, then OUT outputs 1; otherwise, it outputs 0
    • Less than: When the ON input is 1, if IN is less than VAL, OUT outputs 1; otherwise, it outputs 0
    • Not equal to: When the ON input is 1, if IN is not equal to VAL, OUT outputs 1; otherwise, it outputs 0
  • ANY_ELEMENTARY contains all basic data types (bit strings, integers, floating point numbers, characters and strings, times and dates)
  • ST language relational expression:
OUT := ON & (IN=VAL);//equal to
OUT := ON & (IN>=VAL);//Greater than or equal to
OUT := ON & (IN>VAL);//Greater than
OUT := ON & (IN<=VAL);//Less than or equal to
OUT := ON & (IN<VAL);//Less than
OUT := ON & (IN<>VAL);//not equal to

Example

  • LD sample animation is as follows:

alt text

  • ST sample animation is as follows:

alt text