Module 04 · PLC foundations

IEC 61131-3 & your practice PLC

One standard defines the languages almost every PLC uses. Meet them side by side, then build the Logivyx Soft-PLC trainer project you will use for every lab in this course: push buttons, switches and lamps on a screen, driven by your own logic.

≈ 35 min5 lessons1 hands-on labQuiz · pass 80 %Free

By the end of this module you can

  • Name the IEC 61131-3 languages and say when each one fits
  • Read the same logic in ladder, function block diagram, Structured Text and instruction list
  • Explain programs, function blocks and functions
  • Set up a Logivyx Soft-PLC project with a trainer screen, a ladder routine and a Main routine

IEC 61131-3 (first published 1993, third edition 2013) standardises PLC programming languages and the building blocks around them. Here is one piece of logic, "run the motor while START or the seal-in is on and STOP is not pressed", in each language:

Graphical, modelled on relay circuits. Best for discrete on/off logic, interlocks and for maintenance staff who troubleshoot online.

 Start_PB     Stop_PB          Motor
--| |----+----|/|-------------( )--
         |
 Motor   |
--| |----+

Graphical blocks wired together like a circuit diagram. Popular for process control, analog signals and PID loops.

Start_PB ─┐
          │ ≥1 ├──┐
Motor ────┘       │  &  ├── Motor
Stop_PB ───────o──┘

A high-level text language similar to Pascal. Best for calculations, data handling, loops, strings and complex decisions.

Motor := (Start_PB OR Motor) AND NOT Stop_PB;

A low-level, assembler-like list. Deprecated in the third edition of the standard; you will still meet its relatives in Siemens STL and Mitsubishi instruction lists on older machines.

LD   Start_PB
OR   Motor
ANDN Stop_PB
ST   Motor

Not a language for single conditions but a way to structure a sequence: steps (what the machine is doing) and transitions (when to move on). Each step's actions are written in one of the other languages. Levels 4 and 7 cover it.

  ┌──────┐
  ║ Idle ║        (initial step)
  └──┬───┘
     ┼  Start_PB AND Door_Closed
  ┌──┴───┐
  │ Run  │ N  Motor
  └──┬───┘
     ┼  Stop_PB
BrandLadderFBDSTIL-likeSFC
IEC / CODESYSLDFBD / CFCSTILSFC
Siemens TIA PortalLADFBDSCLSTLGRAPH
Rockwell Studio 5000LadderFBDST–SFC
Mitsubishi GX Works3LadderFBD/LDST(list view of ladder)SFC
LogivyxLadder Designer–Logic Editor (ST)–Sequence Designer
POUHas memory?Example
ProgramYesThe machine's main logic, called by a task (Logivyx: a routine called from Main)
Function block (FB)Yes, one copy per instanceA timer TON, a counter, your own Motor block. Each motor gets its own instance.
FunctionNo: same inputs always give the same resultSQRT, LIMIT, SCALE, your own Celsius_To_F

The idea of an instance is important from module 07 onwards: a timer remembers how long it has been running, so every timer you use needs its own name (T_Delay, T_Horn…).

The labs run on the Logivyx Soft-PLC: the Logivyx logic engine acts as the controller, so you need no PLC hardware. What you will use:

Ladder Designer

Tools → Ladder Designer… Contacts (XIC, XIO, rising/falling edge), compare, branches, coils (OTE, OTL, OTU), timers (TON/TOF/TP), counters (CTU/CTD). Each ladder routine is translated into a Structured Text routine automatically.

Logic Editor

Tools → Logic Editor… Turns the engine on, sets the scan rate, and holds every routine. Main runs every scan and calls the others with CALL Name;.

Sequence Designer

Steps and transitions for machine sequences, generated as ST. Used from Level 4.

Screens

Push buttons, toggle switches and lamps on a screen stand in for real field devices. 🧮 Logic Diag shows the ladder live in Run mode.

Two habits that differ from a hardware PLC:

  • Your "inputs" come from screen widgets in the labs. On a real machine they come from remote I/O through Data Exchange (Logivyx course, module 11).
  • Every new routine must be called from Main, or it never runs.

This project is your trainer for the whole course. Later labs add one ladder routine each and call it from Main.

Lab

PLC_Trainer project

  1. Create the folder D:\Projects\PLC_Trainer. In the Development Tool, File → New, pick your screen size, then File → Save As… D:\Projects\PLC_Trainer\PLC_Trainer.hmi.
  2. Tools → Connect…, open the Soft-PLC tab and click Save Connection. The Soft-PLC is now the project's controller.
  3. In the Tag Browser click + Add Tag and create these BOOL tags, PLC Address blank: PB1–PB4 (push buttons), SW1–SW4 (switches), Q1–Q6 (outputs). Then two DINT tags N1 and N2.
  4. On the first screen add four Push Buttons in Momentary mode, bound to PB1–PB4, four Toggle Switches bound to SW1–SW4, six Indicators bound to Q1–Q6, and two Numeric Displays bound to N1 and N2. Label each widget with its tag name.
  5. Tools → Logic Editor…: tick Enable Logic Engine and set the scan rate to 50 ms. If there is no Main routine, click + Add Routine, name it Main and tick Main routine (runs every scan).
  6. Tools → Ladder Designer… → + Add Ladder Routine named L04_Test. Click + Add Rung, drag a Contact — Normally Open onto it with tag SW1, and a Coil — Output Energize with tag Q1. Close the editor.
  7. Open Main in the Logic Editor and add the line CALL L04_Test;. Click Validate, then Save & Close. Save the project.
  8. Press F5 for Run mode (Run mode connects the Soft-PLC by itself). Flip SW1: Q1 follows. Click 🧮 Logic Diag → View Ladder… and watch the rung energise. Esc returns to Edit mode.
TipIn the Ladder Designer, View Generated ST… shows the Structured Text Logivyx made from your rungs. Compare it with the "Show as Structured Text" button in the simulators of this course.