PLCSim — Simulator
Documentation Terms of Use
| |

PLCSim

Simulate PLC programs in Structured Text (IEC 61131-3) directly in VS Code — no hardware needed.

Write and run complete Structured Text programs directly in VS Code. No hardware, no compilation, no deployment. Free forever for learning and prototyping.


Get started

VS Code 1.85 or later. No additional software required for Free features. MQTT broker required for MQTT connectivity (Pro).

Install PLCSim Search "PLCSim" in the VS Code Extensions panel and click Install.
Open the PLCSim panel Click the PLCSim icon in the Activity Bar. Load one of the built-in examples or open your own .st file.
Run the simulator Interact in real time — toggle inputs, change values and watch outputs react. No compilation, no deployment.

Full IEC 61131-3 Syntax & Simulator FREE

Language

Scalar types BOOL · SINT INT DINT LINT · USINT UINT UDINT ULINT · REAL LREAL · TIME DATE TIME_OF_DAY DATE_AND_TIME · STRING WSTRING · BYTE WORD DWORD LWORD
User-defined types STRUCT, ENUM, ARRAY (1D and 2D), typed literals (WORD#16#FF, DINT#-100)
Variables & scope VAR, VAR_INPUT, VAR_OUTPUT, VAR_IN_OUT, VAR_TEMP, VAR_GLOBAL, PERSISTENT, RETAIN
Control flow IF / ELSIF / ELSE, FOR, WHILE, REPEAT, CASE, RETURN, EXIT, CONTINUE
Logic & arithmetic AND, OR, NOT, XOR, comparators, + * / MOD **
Bitwise operators AND, OR, XOR, NOT (on WORD/INT)
Shift & rotate SHL, SHR, ROL, ROR
Timers TON, TOF, TP, TONR
Counters CTU, CTD, CTUD
Bistables & edges RS, SR, R_TRIG, F_TRIG
Standard functions 30+ functions: String (LEN, CONCAT, REPLACE, LEFT, RIGHT, MID), Math (ABS, SQRT, SIN, COS, ROUND, FLOOR, CEIL, TRUNC), Type conversions, Time/Date, Array bounds
Syntax highlighting Full .st language support
Examples 18 ready-to-run programs included

Simulator

Interactive panel Toggle BOOL inputs, set INT/REAL values and watch outputs update instantly.
Scan cycle control Configurable from 10 ms to 5000 ms with drift compensation
Trend charts Oscilloscope view for every variable — 30 s of history, auto-scrolling
PLCSim — Simulator RUNNING (SCAN: 142)
NAME TYPE VALUE DIR
bsensorentry BOOL IN
bsensorexit BOOL IN
itarget INT 100+ IN
bmotor BOOL TRUE OUT
icounter INT 47 OUT
blotdone BOOL FALSE OUT
Trends — ILEN Logic Over Time

Unit Testing Framework PRO

Write YAML test plans and run them from the VS Code Testing tab.

# .plcsim.yaml test plan file
test_plan: "String Support Verification"
steps:
  - set: { sordercode: "ORD-ABC-042" }
  - wait_cycles: 10
  - assert: { ilen: 11, bready: true }

Pro — Debugging & Test PRO

Native Debugger (DAP) Set breakpoints in .st files, step over (F10), step into function blocks (F11), inspect variables in the Variables panel and on hover
Watch Window Live variable list with filter, sort, pinned variables and change history
Single Scan / Step Pause the simulator and execute one scan cycle at a time
Snapshots Capture and restore simulator state — ideal for reproducing bugs
Unit Testing Write YAML test plans and run them from the VS Code Testing tab.

Editor Intelligence (LSP) FREE

Real-time diagnostics Syntax and type errors underlined as you type — no need to run the simulator
Code completion IntelliSense for variables, function blocks, standard functions and keywords
Hover documentation Type information and signatures on hover
Go to Definition F12 to jump to any variable or function block declaration
Find All References See every usage of a symbol across your project
Rename Symbol F2 to safely rename a symbol and all its references in one step
Cross-file support All LSP features work across multiple .st files in the same workspace

Pro — Project Structure PRO

Custom Function Blocks FUNCTION_BLOCK definitions, nested instances
Multi-File Projects Multi-file projects (types/, globals/, blocks/)
# PLCSim: New Project ← generates this layout
workspace/
├── types/   ← TYPE … END_TYPE (structs, enums)
├── globals/ ← VAR_GLOBAL blocks
├── blocks/  ← FUNCTION_BLOCK definitions
└── Main.st  ← main program logic

FB Instances PRO

fbstation : station
bstart [input] false
ballrunning [output] true
banyfault [output] false
fbmotor1 : motor
bstart [input] true
brunning [output] true
iruncount [output] 0

PLCSim — WATCH PANEL PRO RUNNING (SCAN: 0)
NAME TYPE VALUE DIR
sprefix STRING "ORD" OUT
sproduct STRING "ABC" OUT
sstatus STRING "Order: ORD-ABC-042" OUT
sordercode STRING "ORD-ABC-042" IN
smachinestate STRING "RUNNING" IN
ilen INT 11 OUT
idashpos INT 4 OUT
bready BOOL TRUE OUT

Pro — Export & Dialects PRO

TIA Portal export Export programs as .scl files ready to import in Siemens TIA Portal
Siemens SCL dialect Native SCL syntax support
Beckhoff TwinCAT TwinCAT ST syntax support
Schneider Unity Unity Pro ST syntax support

Pro — Industrial Communications PRO

OPC-UA server Exposes all variables as OPC-UA nodes — connect any SCADA or HMI
Modbus TCP server Map variables to coils and holding registers
EtherNet/IP server Map variables to CIP tags
MQTT connector Publish variables to Node-RED, Home Assistant or MQTT brokers
// protocols.config.json
{
  "protocols": [
    { "modbusTCP":  { "enabled": true, "port": 5020 } },
    { "ethernetIP": { "enabled": true, "port": 44818 } },
    { "opcua":     { "enabled": true, "port": 4840,
                   "nodeIdFormat": "generic" } },
    { "mqtt":      { "enabled": true,
                   "brokerUrl": "mqtt://localhost:1883" } }
  ]
}

Pro — Object-Oriented Programming PRO

Modern IEC 61131-3 Edition 3 with classes, inheritance and interfaces.

Classes CLASS blocks with methods, properties, and internal state
Inheritance EXTENDS for single-parent inheritance; SUPER to call parent methods
Interfaces INTERFACE contracts; IMPLEMENTS for conformance
Properties Computed attributes with GET and SET accessors
Methods Callable procedures with parameters and return values
THIS Reference to current instance inside methods and properties

Pro — Documentation PRO

ST Documentation Generator Generate Markdown documentation from (** ... *) doc comments — @description, @param, @returns, @author and @version tags for FUNCTION_BLOCK, FUNCTION and PROGRAM