PLC Programming
Overview of IEC 61131-3 programming with Function Block Diagrams and Structured Text
What is IEC 61131-3?
IEC 61131-3 is the international standard that defines programming languages for programmable logic controllers (PLCs). It was created to unify the many proprietary PLC languages into a common set of well-defined languages that engineers can use across different hardware platforms. The standard specifies five languages in total, but Sim Assist focuses on the two most widely used: Function Block Diagram (FBD) and Structured Text (ST).
By following IEC 61131-3, programs you write in Sim Assist use the same syntax, data types, and function blocks you would encounter on real industrial controllers from vendors like Siemens, Beckhoff, or Allen-Bradley.
Supported Languages
Function Block Diagram (FBD)
FBD is a visual programming language where you build logic by placing graphical blocks on a canvas and connecting their inputs and outputs with wires. In Sim Assist, the FBD editor is built on top of Blockly, giving you a drag-and-drop workspace that feels intuitive even if you have never written PLC code before.
FBD is ideal when:
- You are new to PLC programming and prefer a visual approach.
- Your logic is primarily combinational (AND/OR gates, comparisons, selections).
- You want to quickly prototype control sequences using timers and counters.
- You need to present your program to stakeholders who may not read code.
Structured Text (ST)
Structured Text is a text-based language with syntax similar to Pascal. It provides full control over program flow with variables, loops, conditionals, and function calls. The Sim Assist code editor offers syntax highlighting, autocompletion, and inline error diagnostics to make writing ST efficient.
ST is ideal when:
- You need complex mathematical calculations or data manipulation.
- Your program involves nested conditional logic or state machines.
- You are comfortable with text-based programming and want maximum expressiveness.
- You need to implement algorithms that are difficult to represent visually.
Choosing Between FBD and ST
| Criteria | FBD | ST |
|---|---|---|
| Learning curve | Low | Medium |
| Complex math | Limited | Excellent |
| Readability for non-programmers | High | Low |
| State machines | Awkward | Natural |
| Quick prototyping | Fast | Moderate |
You can freely mix both languages within a single project. For example, you might build high-level sequencing in FBD while implementing a PID controller as a custom function block written in ST.
Connecting Programs to the Simulation
PLC programs interact with the 3D simulation through I/O binding. Every sensor and actuator in your scene exposes input and output signals. You map these signals to variables in your PLC program using the I/O Binding panel.
- Inputs — Signals read from the simulation (e.g., a proximity sensor detecting a part, a temperature reading, a limit switch state).
- Outputs — Signals written back to the simulation (e.g., turning on a motor, opening a valve, setting a conveyor speed).
Once bound, the PLC program executes in a continuous scan cycle: read inputs, execute logic, write outputs. This mirrors exactly how a real PLC operates on a factory floor, giving you a realistic environment to develop and test your control programs before deploying to hardware.
Scan Cycle
Each cycle follows three phases:
- Input scan — All bound sensor values are read from the simulation and copied into input variables.
- Program execution — Your FBD or ST program runs from top to bottom, evaluating all logic.
- Output scan — All output variables are written back to actuators in the simulation.
The cycle time is configurable in the project settings and defaults to 10 ms, which matches typical real-world PLC cycle times.