Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 37 ยท Getting Started

What Is a PLC?

Learn what a PLC is, why factories use it instead of a PC or relays, where PLCs are found, and how this course teaches PLC programming with runnable C stand-ins.

A PLC (programmable logic controller) is a small, rugged industrial computer that reads switches and sensors, runs a program you wrote, and turns motors, valves, lamps and other machinery on and off. It sits inside the control cabinet of a conveyor, a packaging machine, a water pump station, an elevator or a car-wash, and it does the same job every few milliseconds for years without a reboot.

Before PLCs, this logic was built from electromagnetic relays wired together with copper. Changing the behavior meant rewiring a panel. A PLC replaces that wiring with software: you change the program, not the wires. This lesson explains what a PLC is, why it exists, and how this course will teach you to program one.

How a PLC differs from a PC

A PLC is a computer, but it was designed for a different job than your laptop.

Property Typical PC PLC
Operating system General purpose (Windows, Linux) Small real-time firmware
Timing "Fast enough", can pause for updates Deterministic: the program repeats on a fixed schedule
Environment Office Heat, dust, vibration, electrical noise
Inputs and outputs USB, network Terminals for 24 V signals, relays and sensors
Uptime Reboot now and then Runs for years
Programming Text languages Ladder diagrams, function blocks, Structured Text and more

The key idea is determinism. A PLC checks every input, runs the whole program from top to bottom, writes every output, and starts again. The time this takes (the scan time) is short and predictable, so a safety guard or a conveyor stop reacts within a known number of milliseconds. You will study this loop in the scan cycle.

Where PLCs are used

Where PLCs work

Manufacturing Assembly lines and robots
Water Pumps, tanks, valves
Buildings Lifts, HVAC, lighting
Logistics Conveyors and sorters

Anything that repeats and must not fail

1 / 2

The three jobs of a PLC

Every PLC application, from a garage door to a refinery, does three things in a loop:

  1. Read inputs: is the start button pressed? Is the tank full? What is the temperature?
  2. Decide: apply the rules you programmed ("if the start button is pressed and the guard is closed, run the motor").
  3. Write outputs: switch the motor contactor, light the lamp, open the valve.
flowchart LR
    S["Sensors<br/>buttons, switches"] --> I["Input module"]
    I --> C["CPU runs program"]
    C --> O["Output module"]
    O --> A["Actuators<br/>motors, valves, lamps"]

Figure: the signal path through a PLC.

A relay circuit as a program

The classic first example is a start/stop motor circuit. A relay panel would wire a Start button, a Stop button and a holding contact. In a PLC the same thing is a handful of lines of logic. This course teaches the real PLC languages, but the site cannot run a PLC, so the runnable examples are C stand-ins: small programs on a normal computer that behave the same way as the logic you would write in the PLC.

The real PLC software (TIA Portal, Studio 5000, CODESYS and others) and real PLC hardware cannot run in your browser. When a lesson shows PLC code, it is read-only. Every runnable <TryIt> is a labelled C simulation of the same idea. Output is shown only for the simulations we ran.

C Stand-in: start/stop logic in C (not real PLC code)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

Notice that the motor stays on after Start is released. The program "remembers" its own output. This is called a seal-in or latch, and you will build it in ladder logic in latching and seal-in.

What a PLC program looks like

You will meet the standard languages in IEC 61131-3 languages. For now, here is the same start/stop rule in Structured Text, shown read-only:

TEXT
Motor := (Start OR Motor) AND NOT Stop;

And the equivalent idea in ladder logic is a rung drawn as contacts and a coil. Both read the inputs, compute, and write an output once per scan.

How this course is organized

  • Getting Started: hardware, scan cycle and languages.
  • Automation Basics: number systems, I/O, sensors and addressing.
  • Ladder Logic: the most common PLC language, with latches, edges and motor control.
  • Function Blocks and Structured Text: reusable, text-based programming and PID.
  • Later chapters add timers, counters, HMI, communication, safety and projects.
C Stand-in: count how many scans a press lasts

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

A human press is slow compared with a scan, so one press spans many scans. Remembering that detail will prevent a classic bug in edge detection.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the main advantage of a PLC over a hard-wired relay panel?

    A PLC replaces fixed wiring with a program, so behavior is changed by editing software.
  2. 2. What does deterministic mean for a PLC?

    A PLC runs its scan on a predictable schedule, so reaction times are known.
  3. 3. Which is the correct order of a PLC's basic loop?

    A PLC reads inputs first, executes the logic, then writes outputs.
  4. 4. Why are the runnable examples in this course written in C?

    The real PLC tools and hardware are not available on the site, so labelled C stand-ins show the same logic.

Summary

  • A PLC is a rugged, deterministic industrial computer that replaces relay wiring with software.
  • It repeats: read inputs, run the program, write outputs.
  • Common uses range from factories to water plants and buildings.
  • In this course real PLC code is read-only; runnable examples are labelled C stand-ins.

Next: PLC Hardware Components