Logic Gates in PLC Programming: AND, OR, NOT, NAND and XOR Explained (2026) (Updated August 2026)
The AURIC manufacturing corridor's ₹71,343 crore investment is adding 62,405 jobs in plants where PLC ladder logic runs every conveyor, robot, and safety circuit — and logic gates are the foundation of every rung in those programs. AND gates ensure a motor only starts when all safety conditions are met simultaneously; OR gates allow any one of several start signals to trigger an action; NOT gates implement safety stops that fail-safe when a wire breaks. Understanding how logic gates map to ladder diagram contacts is the first practical skill every PLC programmer must master. This guide covers all six standard logic gates with Siemens TIA Portal ladder examples and truth tables.
- AND gate in ladder logic = series NO contacts — output is ON only when ALL inputs are ON
- OR gate in ladder logic = parallel branches — output is ON when ANY one input is ON
- NOT gate in ladder logic = NC (Normally Closed) contact — output is ON when the input is OFF
- NAND = AND + NOT: output is ON unless ALL inputs are simultaneously ON
- XOR gate = output is ON when inputs are DIFFERENT — implemented using a combination of NO and NC contacts
What Are Logic Gates in PLC Programming?
Logic gates are the fundamental building blocks of digital logic — each gate takes one or more binary inputs (0 = OFF/FALSE, 1 = ON/TRUE) and produces a binary output based on a fixed logical rule. In PLC ladder logic, logic gates are not drawn as the triangular electronic symbols seen in digital electronics — instead, they are implemented using contact symbols arranged in series (AND) or parallel (OR) branches, with NC contacts providing NOT logic. Every ladder logic rung is a combination of these building blocks: a rung with two series contacts is an AND gate; a rung with contacts on parallel branches is an OR gate. Mastering gate-to-rung mapping is the starting point for all PLC programming.

AND Gate in PLC Ladder Logic — Series Contacts and Truth Table
The AND gate produces a HIGH output only when ALL of its inputs are simultaneously HIGH. In Siemens S7-300 TIA Portal ladder logic, AND gate = two or more NO contacts in series on the same rung. If I0.0 = 1 AND I0.1 = 1, then Q0.0 = 1. If either input is 0, the rung is broken and Q0.0 = 0. The PLC expression is: Q0.0 = I0.0 * I0.1. Practical use: start a motor only when the start button (I0.0) is pressed AND the guard door is closed (I0.1) AND the emergency stop is not pressed — three contacts in series on one rung. The output is energized only when all three conditions are simultaneously true.
| Logic Gate | Ladder Logic Implementation | Truth (2-input) | Typical PLC Use |
|---|---|---|---|
| AND | Series NO contacts | 1 only if A=1 AND B=1 | Multi-condition start enable |
| OR | Parallel branches (NO) | 1 if A=1 OR B=1 | Multiple start sources, any-fault alarm |
| NOT | Single NC contact | 1 if A=0 (inverted) | Stop button, E-stop, fault interlock |
| NAND | Series NC contacts | 0 only if A=1 AND B=1 | Safety disable — block when all conditions met |
| NOR | Parallel branches (NC) | 1 only if A=0 AND B=0 | Output when ALL faults clear |
| XOR | (A·B̄) parallel (Ā·B) | 1 if A≠B | Direction control, toggle logic |
OR Gate and NAND Gate in PLC Ladder Logic
The OR gate produces a HIGH output when ANY one or more of its inputs is HIGH. In ladder logic, OR gate = two or more contacts on parallel branches (open branches in TIA Portal). If I0.0 = 1 OR I0.1 = 1 (or both), Q0.0 = 1. Practical use: an alarm output triggered by any one of multiple fault sensors — temperature high sensor OR pressure high sensor OR level high sensor, all in parallel branches, driving one alarm output. The NAND gate is the complement of AND: output is HIGH in all states EXCEPT when ALL inputs are simultaneously HIGH. In ladder logic, NAND = NC contacts in series — the rung is FALSE only when all NC contacts are forced open (their referenced bits are ON simultaneously).

NOT Gate, NOR Gate, and XOR Gate in PLC Ladder Logic
The NOT gate inverts its input: output is HIGH when the input is LOW, and LOW when the input is HIGH. In ladder logic, NOT = one NC (Normally Closed) contact. If I0.0 = 0, the NC contact is closed and Q0.0 = 1. If I0.0 = 1, the NC contact opens and Q0.0 = 0. Practical use: a stop button — the NC contact means the rung is TRUE (motor runs) when the button is not pressed; pressing it opens the contact and stops the motor. This is the fail-safe wiring principle: a broken wire (input goes 0) safely stops the motor. The NOR gate is NOT + OR: output is HIGH only when ALL inputs are LOW (NO contacts all open). XOR gate = output HIGH when inputs are DIFFERENT — implemented in ladder as: (I0.0 NO in series with I0.1 NC) in parallel with (I0.0 NC in series with I0.1 NO).
How Logic Gates Combine in Real PLC Programs
Real PLC programs combine all these gate types in complex rungs. A motor start condition might require: (Start_button OR Remote_start) AND Guard_closed AND NOT Emergency_stop AND NOT Motor_fault. In ladder logic: I0.0 and I0.1 on parallel branches (OR) in series with I0.2 NO contact (AND Guard) in series with I0.3 NC contact (AND NOT E-stop) in series with I0.4 NC contact (AND NOT Fault). The PLC evaluates the complete rung left to right on every scan cycle (typically 1–10ms) and updates Q0.0 accordingly. Understanding this composition is the foundation for writing clean, readable, industry-standard ladder logic programs.
PLC SCADA Training at ABC Trainings — Logic Gate Programming Lab
ABC Trainings teaches logic gates and their ladder logic implementation as the opening module of its PLC programming curriculum, covering AND, OR, NOT, NAND, NOR, and XOR gates with hands-on TIA Portal programming on Siemens S7-300 and S7-1200 hardware. Students build each gate in software, download to the PLC, and verify truth tables by toggling physical inputs and monitoring outputs in real time. This foundation module is taught at Wagholi (Pune), Hadapsar (Pune), CIDCO (Chhatrapati Sambhajinagar), and Osmanpura centres. CMYKPY Maharashtra students receive ₹6,000–₹10,000/month stipend. Call 7039169629 or WhatsApp 7774002496 for the next batch schedule.
Get the PLC & SCADA Brochure + Fees + Batch Dates on WhatsApp
Free 1:1 counselling. Placement track record. CMYKPY/PMKVY eligibility check.
💬 Get Brochure on WhatsApp📞 Call 7039169629About the author: Sunil Wagh. 15 years of PLC, SCADA, and EPLAN training experience at ABC Trainings, ex-Siemens India. Has trained engineers for Bajaj Auto, Endurance Technologies, and Siemens automation projects across Maharashtra.
Visit Our Centers
- Wagholi (Pune): 1st Floor, Laxmi Datta Arcade, Pune-Ahilyanagar Highway. Call 7039169629
- Hadapsar (Pune HQ): 1st Floor, Shree Tower, opp. Vaibhav Theater, Magarpatta. Call 7039169629
- Cidco (Chh. Sambhajinagar): Kalpana Plaza, opp. Eiffel Tower, N-1 Cidco. Call 7039169629
- Osmanpura (Chh. Sambhajinagar): S.S.C Board to Peer Bazar Road, near Jama Masjid. Call 7039169629
- Sangli: Shubham Emphoria, 1st Floor, Above US Polo Assn., Sangli-Miraj Rd, Vishrambag. Weekend batches available. Call 7039169629
FAQs
How are AND, OR, and NOT gates implemented in PLC ladder logic?
In PLC ladder logic: AND gate = two or more NO contacts in series on the same rung (output ON only when all contacts are closed simultaneously). OR gate = contacts on parallel branches (output ON when any one branch is complete). NOT gate = NC (Normally Closed) contact (output ON when the referenced bit is 0, output OFF when bit is 1). All standard logic functions are built from these three building blocks, combined in any arrangement needed for the control logic.
What is the difference between AND and NAND gate in PLC programming?
AND gate output = 1 only when ALL inputs = 1 (series NO contacts in ladder). NAND gate output = 0 only when ALL inputs = 1 — it is the complement of AND. In ladder logic, NAND = series NC contacts: the rung is TRUE (output = 1) for all input combinations EXCEPT when all referenced bits are simultaneously ON, which opens all NC contacts and breaks the rung. NAND logic is used when you want to block an output only when all conditions are simultaneously present.
Why do PLC programs use NC contacts for stop buttons and emergency stops?
Stop buttons and emergency stops use NC (Normally Closed) contacts in PLC ladder logic because NC contacts implement fail-safe behaviour: the contact is CLOSED (circuit complete, output ON) when the wire is intact and the button is not pressed. If the wire breaks, the input bit goes to 0, the NC contact opens, and the output (motor) turns OFF — the same result as pressing the stop button. This means a broken wire safely stops the machine. Wiring a stop as NO (Normally Open) would cause a broken wire to go undetected and prevent the stop from working.
Does ABC Trainings teach logic gates with actual PLC hardware?
Yes — ABC Trainings teaches all six logic gates (AND, OR, NOT, NAND, NOR, XOR) with hands-on programming on Siemens S7-300 and S7-1200 PLCs in TIA Portal at Wagholi, Hadapsar, CIDCO, and Osmanpura centres. Students program each gate, verify the truth table by toggling physical inputs, and then combine gates into a multi-condition rung. Logic gates are taught as the first module before timers, counters, and more advanced programming.


