PLC Programming: What a Ladder Diagram Is and How a Scan Cycle Works
Learn what a PLC does, read a simple ladder rung, follow the scan cycle, and understand why the real danger is the machine, not the controller.
Table of contents
Almost every automated machine has a programmable logic controller (PLC) running it. A PLC is a rugged computer that reads signals from buttons and sensors, runs a program and turns motors, valves and lights on or off. People who can work with PLCs are valuable to any plant. The good news is that most PLC programs are written in a language built for electricians. This guide shows you the two ideas everything else rests on: the ladder diagram and the scan cycle.
What You Will Be Able to Do
- Describe what a PLC does and who works with one.
- Explain inputs, outputs and the program between them.
- Read a simple ladder rung.
- List the steps of the scan cycle.
- Say why the machine, not the PLC, is the real hazard.
What the Work Looks Like
Job titles include controls technician, automation technician, PLC programmer and controls engineer. Many maintenance electricians also work with PLCs daily. A normal task is more likely to be finding out why a machine stopped than writing a program from scratch. You connect a laptop, watch the program run, and see which condition is missing.
Common brands in North America include Allen-Bradley (Rockwell), Siemens, Mitsubishi and Omron. The names and software differ, but the ideas are the same.
PLCs replaced panels full of relays. Changing a machine's logic used to mean rewiring. Now it means editing a program.
Inputs, Program, Outputs
Every PLC does three things:
| Part | Examples |
|---|---|
| Inputs | Pushbuttons, limit switches, sensors |
| Program | The logic that decides what happens |
| Outputs | Motor starters, solenoid valves, lights, horns |
The PLC does not know what a button is. It only sees that a terminal has voltage or not. In memory, that is stored as a bit, which is a 1 or a 0.
Each input and output has an address, which is how the program refers to it. A name such as Start_PB is easier to read than an old-style address such as I:0/0.
What a Ladder Diagram Is
Ladder logic looks like a relay drawing, and that is on purpose. It was designed so that electricians could read it. Two rails run down the sides, and rungs run across. Conditions go on the left, and an output goes on the right.
--[ Start_PB ]----[ Guard_Closed ]----( Conveyor )--
Read it like a sentence: if Start_PB is on and Guard_Closed is on, then turn on Conveyor.
The two most common symbols are:
| Symbol | Name | Is true when |
|---|---|---|
| --[ ]-- | Normally open contact | The bit is on |
| --[/]-- | Normally closed contact | The bit is off |
These look like contacts, but they are not real contacts. They are questions about a bit in memory.
Contacts in a row mean AND. Contacts on parallel branches mean OR.
A Start-Stop Rung
--[ Stop_PB ]--[ OL_OK ]--+--[ Start_PB ]--+----( Motor )--
| |
+--[ Motor ]-----+
Pressing Start_PB turns on Motor. Motor is then used as a condition on its own rung, on the branch around the button, so that it stays on after you let go. This is the same as the seal-in on a hardwired starter. Stop_PB and OL_OK are read here as on when healthy, because the stop button and overload contact are wired normally closed.
How a Scan Cycle Works
A PLC does not watch everything at once. It works in a loop, and that loop is called the scan cycle.
- Read inputs. The PLC takes a snapshot of all its inputs.
- Run the program. It solves the rungs from top to bottom, using that snapshot.
- Write outputs. It sends the results to the real outputs.
- Housekeeping. It handles communication and checks itself.
Then it starts again. A full cycle often takes only a few milliseconds, and it can take longer in large programs.
Here is what this means in practice:
- The order of rungs can matter, because they are solved from the top down.
- Outputs change at the end of a scan, not in the middle of it.
- A very short signal can fall between scans and be missed.
What Will Hurt You
A 24-volt PLC input is unlikely to hurt you. What it controls can. A single output can start a conveyor, fire a press or close a contactor on a 480-volt motor.
Machines that start by themselves. A PLC can restart a machine that has been idle. A stopped machine may just be waiting for a sensor. Lock it out before you reach in.
Forcing and bypassing. Software lets you force an output on, or override an input. That skips all the logic, including conditions meant to protect people. Before anyone does this, they need to know what is downstream, and be certain nobody is in the machine's path. As a new worker, do not force anything on your own.
Online changes. A change to a running program takes effect at once. Treat it as seriously as moving a wire.
Safety circuits. Never jumper or defeat an E-stop or a guard switch. Those circuits are designed so that a fault stops the machine.
Panel voltage. PLC panels often contain 120 or 480 volts next to low-voltage wiring. Do not assume that a control panel is low-voltage only.
Tools of the Trade
- A laptop with the maker's programming software.
- The right cable, usually Ethernet or USB.
- A multimeter for checking I/O signals.
- The I/O list and electrical drawings, showing which wire goes to which input.
Your First Exercise
Write this start-stop rung on paper.
- Start_PB is a normally open button.
- Stop_PB is a normally closed button, so its bit is on until someone presses it.
- OL_OK is a normally closed overload contact.
- Motor is the output.
Now answer each question with 1 or 0 for every bit:
- Before anyone presses anything, is the rung true?
- While Start_PB is pressed?
- After Start_PB is released?
- While Stop_PB is pressed?
If you can explain the third answer, you understand why the seal-in works.
Common Mistakes
| Mistake | What it costs |
|---|---|
| Thinking a contact symbol is a real contact | Misreading the logic |
| Assuming a quiet machine is off | Serious injury if it starts |
| Forcing an output without checking | A machine that moves with someone in it |
| Editing without a backup | No way to get back to what worked |
Check Your Understanding
1. What are the three things every PLC does?
It reads inputs, runs a program and controls outputs.
2. In the rung with Start_PB and Guard_Closed in series, what happens if the guard is open?
The rung is false and Conveyor stays off, because both conditions have to be true.
3. What order does a PLC follow in each scan?
It reads inputs, runs the program, writes outputs and does housekeeping.
4. A coworker says PLC work is safe because it is only 24 volts. What is wrong with that?
The outputs control machines and high-voltage equipment, so the hazards are still there.
Key Takeaways
- A PLC reads inputs, runs logic and controls outputs.
- Ladder logic looks like a relay drawing, and is read left to right.
- Contacts are questions about bits, not real switches.
- The scan cycle repeats: read, solve, write, housekeeping.
- The dangerous part is what the PLC controls. Lock out before you reach in, and do not force outputs on your own.