This article explains how to control lamps using data comparison instructions in Siemens TIA Portal. The logic utilizes Increment and Decrement instructions to modify data values dynamically. Various comparison operators, including Equal To (=), Not Equal To (≠), Greater Than (>), Less Than (<), Greater Than or Equal To (≥), and Less Than or Equal To (≤) are used to evaluate conditions and trigger lamp outputs based on the specified logic.
Program Objective
This example demonstrates the implementation of data comparison instructions along with their operational logic:
- Equal To (=) → Both values are identical.
- Not Equal To (≠) → Values differ (either greater or smaller).
- Greater Than (>) → Left value exceeds the right value.
- Less Than (<) → Left value is below the right value.
- Greater Than or Equal To (≥) → Left value is greater than or matches the right value.
- Less Than or Equal To (≤) → Left value is smaller than or matches the right value.
Program Workflow:
- Trigger (+/-) increments/decrements the data value.
- Light 1 turns ON if data > 1.
- Light 2 activates if data < 1.
- Light 3 turns ON when data = 0.
- Light 4 turns ON if data ≥ 4.
- Light 5 turns ON when data meets the condition: 2 < data ≤ 4.
IO Mapping
| S.No. | Comment | Input (I) | Output (Q) | Memory Bit | Memory Word |
|---|---|---|---|---|---|
| 1 | START | I0.0 | |||
| 2 | STOP | I0.1 | |||
| 3 | (+)_TRIGGER | I0.2 | |||
| 4 | (-)_TRIGGER | I0.3 | |||
| 5 | LAMP_1 | Q0.0 | |||
| 6 | LAMP_2 | Q0.1 | |||
| 7 | LAMP_3 | Q0.2 | |||
| 8 | LAMP_4 | Q0.3 | |||
| 9 | LAMP_5 | Q0.5 | |||
| 10 | COUNTER_DATA | MW2 | |||
| 11 | SYSTEM_ON | M0.0 | |||
| 12 | TEMP_(+) | M0.1 | |||
| 13 | TEMP_(-) | M0.2 |
Lamps Control Using Compare Instructions

NETWORK 1 (SYSTEM_ON)
In this Network, the memory bit SYSTEM_ON (M0.0) will be in a HIGH state if the START (I0.0) button is pressed. the memory bit SYSTEM_ON (M0.0) will remain in a HIGH state even though the PB_START (I0.0) button has been released. Because it uses Latching.
If the STOP (I0.1) button is pressed, the memory bit SYSTEM_ON (M0.0) will return to a LOW state.
NETWORK 2 (COUNTER UP)
In this Network, the value in the memory word COUNTER_DATA (MW2) will increase (+1) when the NO contact of the memory bit SYSTEM_ON (M0.0) is in a HIGH state and the (+)_TRIGGER (I0.2) button is pressed.
The Increment / INC instruction will add (+1) to the memory word data when triggered.

NETWORK 3 (COUNTER DOWN)
In this Network, when the NO contact of the memory bit SYSTEM_ON (M0.0) is in a HIGH state and the
(-)_TRIGGER (I0.3) button is pressed, the value in the memory word COUNTER_DATA (MW2) will decrease by (-1).
The Decrement / DEC instruction will subtract (-1) from the memory word data when triggered.
NETWORK 4 (GREATER THAN)
In this Network, the output LAMP_1 (Q0.0) will be ON if the contact NO of the memory bit SYSTEM_ON (M0.0) is in the HIGH state and the value in the memory word COUNTER_DATA (MW2) is Greater Than “1”.

NETWORK 5 (LESS THAN)
In this Network, the output LAMP_2 (Q0.1) will be ON if the NO contact of the memory bit SYSTEM_ON (M0.0) is in the HIGH state and the value in the memory word COUNTER_DATA (MW2) is Less Than “1”.
NETWORK 6 (EQUAL)
In this Network, the output LAMP_3 (Q0.2) will be ON if the contact NO of the memory bit SYSTEM_ON (M0.0) is in the HIGH state and the value in the memory word COUNTER_DATA (MW2) is Equal To “0”.

NETWORK 7 (GREATER THAN OR EQUAL)
In this Network, the LAMP_4 (Q0.3) output will be ON if the NO contact of the memory bit SYSTEM_ON (M0.0) in the HIGH state and the value in the memory word COUNTER_DATA (MW2) is Greater Than or Equal To “4”.
NETWORK 8 (LESS THAN OR EQUAL)
In this Network, the LAMP_5 (Q0.5) output will be ON if the NO contact of the memory bit SYSTEM_ON (M0.0) is in HIGH state and the value of the memory word COUNTER_DATA (MW2) is Less Than or Equal To “4” and Greater Than “2”.
Read Next:
- Omron PLC Project Bottle Filling Conveyor System
- PLC-based Automated Product Delivery System
- PLC Project for Dam Gate Control with 5 Alarms
- PLC Heating Different Products in Conveyor Oven
- PLC Program for Product Sorting and Heating Process