1. What a PLC is and the scan cycle

A PLC (programmable logic controller) is an industrial computer built to control machines. It receives signals from push buttons, sensors and contacts (the inputs), runs a program and switches contactors, lamps and valves (the outputs).

The PLC works in a continuous loop called the scan cycle:

  1. Read all inputs and store a "snapshot" of them in memory.
  2. Run the program from top to bottom, rung by rung, using that snapshot.
  3. Update all outputs at once with the result.

A scan usually takes 1 to 20 ms. That is why the program seems to run "all at once", but rung order matters: a lower rung sees what the rungs above it have already calculated in the same scan.

2. From relay logic to Ladder

Ladder (contact diagram, IEC 61131-3) imitates a relay control schematic. The name comes from its shape:

SymbolNameConducts when…
--| |--NO contact (normally open)the variable bit is 1
--|/|--NC contact (normally closed)the variable bit is 0
--( )--Coilwrites 1 to the variable while the rung conducts
--(S)-- / --(R)--SET / RESET coilturns on and holds / turns off and holds
ℹ️
A Ladder contact is not a physical contact. An NO or NC contact in the program only tests a bit in memory. It does not know whether the button on the panel is NO or NC. This difference causes the most common beginner mistake (see section 5).

3. Inputs, outputs and addresses

Each PLC terminal has an address. The format changes from one manufacturer to another:

TypeIEC 61131-3 / CODESYSSiemens S7Typical use
Digital input%IX0.0I0.0push button, sensor, overload contact
Digital output%QX0.0Q0.0contactor coil, lamp, valve
Internal memory%MX0.0M0.0auxiliary bit, interlock

Always give each address a name (tag), such as B1_START or K1_MOTOR. The program becomes readable and maintenance is much easier.

4. First program: direct-on-line start with seal-in

The classic automation exercise is starting a motor with a momentary button and keeping it running after the button is released. PLC wiring:

B1B0_OKF1_OKK1 K1
Direct-on-line start: B1 starts, the K1 contact in parallel seals in, B0_OK and F1_OK stop.

How the rung works:

  1. With B0 and F1 at rest, inputs B0_OK and F1_OK are 1, and their NO contacts conduct.
  2. Pressing B1 makes the rung conduct and K1 turns on.
  3. The K1 contact in parallel with B1 keeps the rung conducting after B1 is released. This is the seal-in (latch).
  4. Pressing B0, or the overload tripping, takes the input to 0, the rung opens and K1 turns off.

5. The NC stop button trap

In the relay schematic the stop button is NC. The temptation is to draw an NC contact in Ladder too. With the NC button wired to the input, this goes wrong:

The rule of thumb: a program contact must conduct when the machine is in a condition to run. An NC stop button and an NC overload contact go into Ladder as an NO contact testing the "OK" input.

⚠️
Why is the stop button NC in the field? If the push-button wire breaks, the input goes to 0 and the machine stops. With an NO button, a broken wire would leave the machine without a stop and nobody would notice. This is the fail-safe principle.

6. TON, TOF and TP timers

IEC 61131-3 timers have an input IN, a preset time PT and an output Q:

BlockNameBehaviourTypical use
TONOn-delayQ turns on when IN has been on for PTstar → delta changeover, sequential start
TOFOff-delayQ turns on with IN and only turns off PT after IN turns offventilation after stopping, post-lubrication
TPPulseQ produces a pulse of length PT on the rising edge of INalarm pulse, fixed-length command

In a star-delta start, for example, a 5 to 10 s TON started with the star contactor drops the star and enables the delta. An NC contact of each contactor in the other one (interlock) prevents both from closing at the same time.

7. Counters, SET/RESET and edges

8. From the electrical schematic to Ladder

If you can already read a control schematic, you are halfway there. The translation follows a few steps:

  1. Identify each branch of the control circuit: what lies between the phase and each contactor coil.
  2. Each push button, sensor or overload contact becomes a PLC input.
  3. Each contactor coil becomes an output; its auxiliary contacts become contacts of that output in the program.
  4. Contacts in series stay in series; parallel branches stay in parallel.
  5. Review the field NC contacts as described in section 5.

In the CamposLH Electrical Schematic Editor you can draw the control circuit, or open a CADe SIMU file, and send it to PLC Studio with the ⇄ Send to PLC Studio button. PLC Studio analyses the paths, generates Ladder and FBD and shows warnings about what needs checking.

9. Safety: what the PLC must not do alone

🚨
The emergency stop does not depend on the program. The emergency stop must cut power to the actuators in hardware, through a safety relay or a safety PLC of the right category (ISO 13849, IEC 60204-1). The input it creates on a standard PLC is for indication and logic, never the only protection.

10. Next steps

The best way to learn Ladder is to practise. Build the direct-on-line start, then reversing with interlock and finally star-delta with a timer. Simulate each case by pressing the virtual buttons and watch the rung conduct. When you feel confident, move the program to the manufacturer's tool (TIA Portal, CODESYS, GX Works, ISPSoft…) and run the I/O test on the real panel.