A practical fieldbook for PLC programmers

From Machine to Program

A machine arrives as a messy request. Learn how to turn it into signals, decisions, a program, and evidence that it works.

Carton transfer conveyor with two photoeyes, a motor drive and an open PLC cabinet
ONE CARTON. TWO SENSORS. MORE DECISIONS THAN YOU THINK.Start with this machine. Follow every decision from the operator’s request to the last test.

Your route through the book

Each part leaves you with something you can make yourself. Use that as the check before moving on.

Three machines to learn on

The equipment changes. So do the questions you must ask.

Conceptual machine illustrations. The accompanying diagrams define the control assumptions.

Start with the output, not an instruction

Follow the belt command backwards: what permits it, what remembers it, what ends it, and what proves it worked?

  1. Find the output
  2. Write its rules
  3. Draw the states
  4. Write the three passes
  5. Try to break it

Work through the first job

Download the starting worksheet (.md)

Structured Text and Ladder, signals and hardware, timers, sequences, analog control, motion, communications, testing and four worked machine projects.

Understand the machine

  1. Start with the machine

    Turn a vague machine request into observable behaviour before opening the editor.

  2. Write the behaviour contract

    Specify priorities, operating limits and acceptance tests that remove guesswork.

  3. Map signals and hardware

    Connect physical events to meaningful inputs, outputs and feedback.

  4. Follow one scan

    Trace input sampling, logic execution and output updates one phase at a time.

  5. Think in conditions

    Build clear Boolean decisions and check them with truth tables.

  6. Remember with intent

    Use latches and edges deliberately, with explicit reset and restart behaviour.

Make behaviour explicit

  1. Read and write Ladder

    Translate conditions into contacts, branches and coils without losing ownership.

  2. Write Structured Text

    Express decisions, sequences and bounded calculations in readable code.

  3. Measure time

    Distinguish elapsed time, delayed actions and missed conditions.

  4. Count events

    Count transitions rather than scans, and reason about bounce and missing pulses.

  5. Build a state model

    Describe what happens next, what allows it, and what must always remain true.

  6. Handle modes and restarts

    Design manual, automatic, stopping and recovery behaviour together.

Control real devices

  1. Functions and function blocks

    Separate calculations from stateful devices and define clear interfaces.

  2. Types, arrays and data

    Represent a machine with explicit units, bounds and data ownership.

  3. Analog signals and scaling

    Turn measurements into engineering units while preserving signal quality.

  4. Control a continuous process

    Understand feedback, response, saturation and integral action.

  5. Motors and drives

    Separate a run request from readiness, motion feedback and drive faults.

  6. Motion and position

    Reason about homing, limits, motion commands and completion.

Connect the whole system

  1. Connect machines

    Choose communication boundaries and detect stale or missing data.

  2. Design the operator interface

    Make status, commands and recovery clear to the person running the machine.

  3. Diagnose with alarms

    Capture useful fault evidence and separate acknowledgement from reset.

  4. Coordinate a cell

    Transfer work between machines with explicit ownership and handshakes.

  5. Build recipes and batches

    Validate production parameters and keep a running batch consistent.

  6. Structure a maintainable project

    Organize signal mapping, devices, coordination and diagnostics into clear layers.

Prove it works

  1. Safety and standards

    Distinguish programming conventions, electrical rules and functional safety responsibilities.

  2. Test before the machine

    Turn requirements into repeatable boundary, fault and recovery tests.

  3. Commission with evidence

    Prepare a controlled commissioning plan and record what was actually verified.

  4. Debug with a hypothesis

    Use traces and controlled experiments to find causes rather than guess at fixes.

  5. Maintain and secure

    Plan changes, access, backups and restoration for the life of the machine.

  6. Measure and improve

    Find bottlenecks with evidence before changing code or hardware.

Design complete machines

  1. Project: a transfer conveyor

    Work through a conveyor brief, state model, implementation and acceptance tests.

  2. Project: a batch tank

    Combine measurements, valves, recipes and fault handling into a batch design.

  3. Project: an inspection cell

    Track products and inspection decisions through a complete reject sequence.

  4. Project: a two-station line

    Design buffers, ownership and recovery across concurrent stations.

  5. The professional review

    Review a flawed design, explain the consequences, and justify a better one.

  6. Your next machine

    Apply the method independently and hand over a program another person can maintain.

Independent reading

An original TryPLC teaching text. Hugh Jack’s book is further reading, not the source of this manuscript. Consult current manufacturer documentation for your target.

Hugh Jack — Automating Manufacturing Systems with PLCs, version 4.7 (2005)

PLCopen — Software Construction Guidelines

IEC 61131-3:2025 — language scope and edition

Ordinary control examples are not safety functions. Real equipment requires its own risk assessment, hardware design and validation.