Know Python? Learn Ladder Logic.
A guided introduction to PLC programming for Python developers, using pyrung.
You know Python. You've never touched a PLC. This guide teaches you ladder logic, the dominant programming language of industrial automation, using tools you already have: Python, VS Code, and pytest. No hardware required.
pyrung won't let you cheat — if you try to write a for loop where a scan cycle belongs, it'll tell you. That's the point. You're learning a different way of thinking about programs, and the guardrails are there to keep you honest.
What you're building
Every lesson adds a feature to the same project: a conveyor sorting station. Boxes arrive on a belt, get measured, and a diverter gate routes them to the correct bin. By the end, you'll have a system with start/stop/e-stop, auto and manual modes, a state-driven sorting sequence, structured tags for the equipment, a full test suite, and a path to real hardware.
Each lesson follows the same arc: start with the Python you'd instinctively reach for, see why it doesn't work for a machine that controls physical things, then learn the ladder logic way. Every lesson ends with an exercise you can run and test.
Prerequisites: Python 3.11+, basic pytest knowledge, a text editor. Code samples use PLC-style TitleCase for tag names -- more on that in Lesson 2.
Lessons
- The Scan Cycle -- A button runs the conveyor motor.
- Tags -- Speed setpoint and an over-speed alarm.
- Latch and Reset -- Start, stop, and emergency stop.
- Assignment -- Record box sizes and keep a running total.
- Timers -- Hold the diverter gate open for 2 seconds.
- Counters -- Count boxes into each bin.
- State Machines -- The full sorting sequence.
- Branches and OR Logic -- Auto and manual modes.
- Structured Tags and Blocks -- A Bin UDT and a sort log.
- Testing -- A pytest suite for the whole system.
- From Simulation to Hardware -- Map your project to a real Click PLC or P1AM-200.
Built with pyrung. Write ladder logic in Python, simulate it, test it, deploy it.