Skip to content
Home » Blog » MELSEC Tutorial 08 – Ladder Comparison Operations

MELSEC Tutorial 08 – Ladder Comparison Operations

MELSEC Tutorial 08 – Ladder Logic Programming: Comparison Operation

In industrial automation, MELSEC comparison operations play a vital role in decision-making processes within ladder logic programming. These operations enable your MELSEC PLC to evaluate conditions and execute specific actions based on the results. This tutorial focuses on using comparison instructions like >, <, =, and others in GX Works3, guiding you through their implementation, application, and testing.


YouTube player


What Are MELSEC Comparison Operations?

MELSEC comparison operations compare two values, such as constants, data registers, or variables. Based on the result, they trigger specific outputs or actions in the ladder logic program. Common comparison operators include:

  • >: Greater than
  • <: Less than
  • =: Equal to
  • >=: Greater than or equal to
  • <=: Less than or equal to
  • !=: Not equal to

Step 1: Setting Up Registers and Inputs

Before programming, prepare your GX Works3 project:

  1. Open your project and access the Device/Label Editor.
  2. Define data registers for comparison. For example:
    • Register D0: Input Value
    • Register D1: Threshold Value
  3. Assign test values to these registers for simulation.

Step 2: Implementing Basic Comparison

Example: Greater Than (>)

Scenario: Activate an output if the value in D0 is greater than 100.

  1. Insert a comparison instruction:
    • Use > to compare D0 with the constant 100.
  2. Link the comparison to a coil (output).

Ladder Logic Code:

D0 > K100 --] [-- Output --( )--

When D0 exceeds 100, the output coil activates.


Step 3: Using Multiple Conditions

Example: Between (>= and <=)

Scenario: Trigger an output if the value in D0 lies between 50 and 150.

  1. Create two conditions:
    • D0 >= K50
    • D0 <= K150
  2. Use an AND block to combine the conditions.

Ladder Logic Code:

D0 >= K50 --] [--+--] [-- D0 <= K150 --( )--

The output activates when both conditions are true.


Step 4: Comparison with Data Registers

Example: Not Equal (!=)

Scenario: Activate a warning if D0 and D1 contain different values.

  1. Insert a != instruction to compare D0 with D1.
  2. Link the result to a warning indicator coil.

Ladder Logic Code:

D0 != D1 --] [-- Warning --( )--

Step 5: Real-Time Monitoring

To verify comparison operations:

  1. Open the Device/Monitor tool in GX Works3.
  2. Add the registers (D0, D1, etc.) to the watchlist.
  3. Modify register values during simulation and observe how the program responds to changes.

Step 6: Advanced Application

Example: Greater Than and Output Assignment

Scenario: If D0 > D1, transfer D0 to D2.

  1. Use a comparison instruction (>).
  2. Link it to a MOV instruction to move the value of D0 to D2.

Ladder Logic Code:

D0 > D1 --] [-- MOV D0 D2 --( )--

When the condition is met, the program automatically transfers data.


Step 7: Combining Comparisons with Timers

Combine comparison operations with timer functions for enhanced functionality.

Scenario: Turn on an alarm if D0 < 50 for more than 5 seconds.

  1. Insert a < instruction to compare D0 and 50.
  2. Link the comparison result to a TON (Timer On-Delay).
  3. Connect the timer’s output to an alarm coil.

Ladder Logic Code:

D0 < K50 --] [-- TON T0 K500 --] [-- Alarm --( )--

Conclusion

Ladder logic diagram showing comparison operations with greater than and not equal instructions in MELSEC PLC programming.

MELSEC comparison operations are an essential part of ladder logic programming, enabling dynamic control and decision-making. Mastering these operations in GX Works3 allows you to build smarter, more responsive automation systems with your MELSEC PLC.

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock