PLC ladder logic examples for robot cells

Learn ladder logic through worked examples: start-stop seal-in, latches, timers, counters, a robot handshake and the mistakes behind intermittent faults.

Reference
RE-995
Published
Read
6 min

About the author · Sources, testing and AI policy

Open PLC control cabinet with DIN rail modules and tidy wiring

Ladder logic is still how most factory floors are programmed. It survives because an electrician can read a rung without knowing a programming language.

This guide explains the scan cycle, the instructions you use every day, and five worked examples that cover start/stop, latching, timers, counters and a robot handshake. It ends with the mistakes that cause intermittent faults no one can reproduce.

How a PLC runs a ladder program

A PLC repeats a cycle: read the inputs into memory, solve the logic from top to bottom, write the outputs, then handle communication and housekeeping. That whole cycle usually takes a few milliseconds.

  • Input scan: copy the physical input states into the input image.
  • Program scan: evaluate each rung using the image, not the live input.
  • Output scan: write the output image to the physical outputs.
  • Housekeeping: diagnostics, communication, watchdogs.

Because the program sees a frozen input image, a pulse shorter than the scan time can be missed entirely. That single fact explains many “the sensor works but the PLC does not see it” problems.

The instructions you actually use

ElementSymbol in textBehaviour
Normally open contact—| |—Passes power when the tag is true
Normally closed contact—|/|—Passes power when the tag is false
Output coil—( )—Follows the rung condition
Set coil—(S)—Latches on until reset
Reset coil—(R)—Unlatches a set coil
Timer on delayTONOutput true after the preset time
Timer off delayTOFOutput stays true for the preset time after input drops
Counter upCTUCounts rising edges to a preset

Example 1: start, stop and seal-in

The standard motor start circuit uses a normally open start button, a normally closed stop button, and a contact from the output in parallel with the start button. That parallel contact keeps the rung true after the button is released.

   Start        Stop                 Motor
---| |----+----|/|------------------( )---
          |
   Motor  |
---| |----+

Tag names:
  Start  = I0.0  (momentary NO push button)
  Stop   = I0.1  (momentary NC push button)
  Motor  = Q0.0

Note the stop button is wired normally closed. A broken wire then stops the machine instead of preventing the stop, which is the safe failure direction. This is why “the stop button reads true when not pressed” is correct, not a wiring error.

Example 2: latch with set and reset

Set and reset coils are common in sequence logic. They are easy to read and easy to abuse: if two rungs set and reset the same tag, the last one in scan order wins, and the result depends on rung position.

   PartPresent   Reset                 Gripped
---| |----------|/|----------------------(S)---

   ReleaseCmd                            Gripped
---| |----------------------------------(R)---

Keep one owner for each latch. If a tag is set in one place, reset it in one place, and document the sequence. Latches that survive a power cycle are useful for fault memory and dangerous for machine state.

Example 3: conveyor jam detection

A photo-eye at the end of a conveyor should see a gap between parts. If the sensor stays blocked longer than the longest legitimate part takes to pass, the conveyor is jammed.

   SensorBlocked                  TON_1
---| |-----------------------------[TON 5 s]---

   TON_1.DN        Reset           JamFault
---| |-----------|/|----------------( )---

   JamFault                        Conveyor
---|/|-------------------------------( )---

Five seconds is a number you derive from the line speed and the longest part, not a guess. Add a short on-delay to the sensor input as well if parts vibrate and flicker the beam.

Example 4: counting parts

A counter counts rising edges. If the sensor stays on while several parts pass, the counter sees one part. Use a one-shot or a short off-delay to create a clean edge for each part, and reset the counter at the start of each batch.

   SensorEdge                     CTU_1
---| |-----------------------------[CTU 100]---

   CTU_1.DN        BatchReset      BatchDone
---| |-----------|/|----------------( )---

Counters are retentive on many platforms. After a power cycle the count may resume from the old value, which is either exactly what you want for a batch total or exactly what you do not want for a per-shift count.

Example 5: robot handshake

A robot cell needs a simple, explicit handshake. Every signal must have an owner, a default state and a timeout. The pattern below is the minimum: the PLC requests, the robot acknowledges, the robot finishes, the PLC releases.

PLC to robot:
  PartReady       PLC has a part in position
  CycleRequest    PLC asks the robot to start
  FaultReset      PLC clears a robot fault

Robot to PLC:
  RobotReady      Robot is powered, homed and in auto
  CycleActive     Robot has accepted the cycle
  CycleComplete   Robot finished and is clear
  RobotFault      Robot has a fault

Interlock:
  CycleRequest may only be true when PartReady,
  RobotReady, not RobotFault and guard closed.

Add a timeout to each wait: if CycleActive does not follow CycleRequest within a few seconds, raise a fault rather than waiting forever. Most “robot and PLC out of sync” problems are a missing timeout and a signal that was missed during a scan.

Safety is not a ladder rung

Emergency stops, guard interlocks and light curtains belong in a safety circuit or a safety-rated controller, hardwired or on a safety PLC with the right category. A standard PLC rung can inform the robot that the guard is closed, but it must not be the only thing that stops hazardous motion.

  • E-stop in the safety circuit, not only in software.
  • Guard switches wired to a safety relay or safety input.
  • Standard PLC reads status for sequencing and diagnostics.
  • Safety functions tested and recorded, not assumed.
  • Any bypass is temporary, logged and removed before production.

Ladder versus structured text

Ladder is best for interlocking and discrete sequences that maintenance staff will read. Structured text is better for calculations, loops, recipe handling and string work. Most modern PLCs allow both in one project, and mixing them is normal: ladder for the machine sequence, structured text for scaling and data handling.

Choose by who will troubleshoot it at 2 a.m. If a technician with a laptop needs to find why a conveyor stopped, ladder wins. If the logic is a 200-line calculation, ladder becomes unreadable and structured text is safer.

Common mistakes

MistakeEffectFix
Same coil in two rungsLast rung wins, output flickersOne coil per tag
Relying on rung orderLogic breaks when rungs moveUse intermediate tags
No debounceCounts and faults multiplyAdd a timer filter
Short pulsesMissed between scansLatch in hardware or use interrupts
Retentive bits left onMachine restarts mid-sequenceInitialise state on first scan
No timeoutsSequence hangs silentlyTimer per wait step

Related: PLC programming for beginners, PLC vs robot controller, robot integration checklist, machine tending, robot safety standards.

What is ladder logic in a PLC?

A graphical programming language that looks like relay circuits. Contacts and coils are arranged in rungs, and the PLC solves them top to bottom every scan cycle.

What is a seal-in circuit?

A contact from the output placed in parallel with the start button, so the output stays on after the button is released. It is the standard start-stop latching pattern.

Why does my PLC miss short sensor pulses?

The program reads a frozen input image once per scan. A pulse shorter than the scan time can be missed. Use a faster task, an interrupt input, or latch the signal in hardware.

Should emergency stops be programmed in ladder logic?

No. E-stops and guard interlocks belong in a safety-rated circuit or safety PLC. Standard ladder can read their status for sequencing, but must not be the only stop.

How do I synchronise a PLC and a robot?

Use an explicit handshake with request, acknowledge, complete and fault signals, each with a defined owner and a timeout. Never rely on a single bit changing at the right moment.

The network layer under those examples is explained in industrial Ethernet for robots.

Interviewers test reasoning more than syntax, and this career guide lists the questions worth preparing.

Cycle counts and downtime reasons are already in the PLC, and the IIoT pilot guide explains how to read them out without replacing it.

Handshake logic needs timeouts, which the PLC to robot handshake section explains with a signal list.

Sources and further reading

Pass it onWhatsAppLinkedIn

Keep reading

Continue learning

The Build Note

One short email when something is worth your bench time.

A new build sheet, a part price that moved, or a mistake worth avoiding. No daily drip, no recycled news.

One short email when a build or a price is worth your time. Unsubscribe in one click.