Jump to content
  • Sign in to follow this  

    Comparison Instructions in PLC Programming

       (0 reviews)

    xiangjinjiao

    Comparison instructions in PLC are used to test pairs of values to condition the logical continuity of a rung.

    Thus, comparison instructions would seldom, if ever, be the last instruction on a rung.

    Types of Comparison Instructions

    4-1.jpg

    As an example, suppose a LES instruction is presented with two values. If the first value is less than the second, then the comparison instruction is true.

    Equal (EQU) Instruction

    4-2.jpg

    Use the EQU instruction to test whether two values are equal. If source A and source B are equal, the instruction is logically true. If these values are not equal, the instruction is logically false.

    Source A must be an address.

    Source B can be either a program constant or an address.

    Values are stored in two’s complementary form.

    Not Equal (NEQ) Instruction

    4-3.jpg

    Use the NEQ instruction to test whether two values are not equal.

    If source A and source B are not equal, the instruction is logically true.

    Source A must be an address.

    Source B can be either a program constant or an address.

    Values are stored in two’s complementary form.

    Less Than (LES) Instruction

    4-4.jpg

    Use the LES instruction to test whether one value (source A) is less than another (source B).

    If source A is less than the value at source B, the instruction is logically true.

    Source A must be an address.

    Source B can be either a program constant or an address.

    Values are stored in two’s complementary form.

    Less Than or Equal (LEQ) Instruction

    4-5.jpg

    Use the LEQ instruction to test whether one value (source A) is less than or equal to another (source B).

    If the value at source A is less than or equal to the value at source B, the instruction is logically true.

    Source A must be an address.

    Source B can be either a program constant or an address.

    Values are stored in two’s complementary form.

    Greater Than (GRT) Instruction

    4-6.jpg

    Use the GRT instruction to test whether one value (source A) is greater than another (source B).

    If the value at source A is greater than the value at source B, the instruction is logically true.

    Greater Than Or Equal (GEQ) Instruction

    4-7.jpg

    Use the GEQ instruction to test whether one value (source A) is greater than or equal to another (source B).

    If the value at source A is greater than or equal to the value at source B, the instruction is logically true.

    Masked Comparison for Equal (MEQ)

    4-8.jpg

    Use the MEQ instruction to compare data at a source address with data at a compare address.

    The Use of this instruction allows portions of the data to be masked by a separate word.

    Source is the address of the value you want to compare.

    Mask is the address of the mask through which the instruction moves data.

    The mask can be a hexadecimal value.

    Compare is an integer value or the address of the reference.

    If the 16 bits of data at the source address are equal to the 16 bits of data at the compare address (less masked bits), the instruction is true.

    The instruction becomes false as soon as it detects a mismatch.

    Limit Test (LIM) Instruction

    4-9.jpg

    Use the LIM instruction to test for values within or outside a specified range, depending on how you set the limits.

    The Low Limit, Test, and High Limit values can be word addresses or constants, restricted to the following combinations:

    • If the Test parameter is a program constant, both the Low Limit and High Limit parameters must be word addresses.
    • If the Test parameter is a word address, the Low Limit and High Limit parameters can be either a program constant or a word address.

    True/False Status of the LIM Instruction

    If the Low Limit has a value equal to or less than the High Limit, the instruction is true when the Test value is between the limits or is equal to either limit.

    4-10.jpg

    If the Low Limit has a value greater than the High Limit, the instruction is false when the Test value is between the limits.

    4-11.jpg

    Sign in to follow this  


    User Feedback

    Create an account or sign in to leave a review

    You need to be a member in order to leave a review

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    There are no reviews to display.


×
×
  • Create New...