README

truST

IEC 61131-3 Structured Text in VS Code, compiled to native code

Write, run and debug PLC programs on Linux, macOS, Windows and microcontrollers.

Documentation VS Code Marketplace Release CI License: MIT or Apache-2.0

Documentation · Install · Examples · Changelog

Structured Text in VS Code: a hover and completion, Start compiles the program and runs it on the simulator, Live Values forces a level, and the debugger stops at a breakpoint and steps

truST is an open platform for IEC 61131-3 Structured Text. You write programs in VS Code with a complete language server. trust-runtime compiles each program ahead of time into native machine code for the computer or chip that runs it, and runs it in a scan cycle. The debugger, Live Values and the operator screens all work on the running program.

The aim is PLC programming as open and dependable as modern software: one plain-text project that you review, version and test like any other code.

Why truST

If you need truST gives you
A modern editor for Structured Text a language server in VS Code: diagnostics as you type, completion, hover, go to definition, references, rename across files and formatting
PLC programs on ordinary computers trust-runtime: native code on Linux and macOS, on x86-64 and AArch64, and on Windows x86-64
A small controller the ESP32-C6 firmware, a complete truST runtime that you install over USB
Code from another PLC vendor profiles for CODESYS and TwinCAT, Siemens SCL and Mitsubishi GX Works3, and PLCopen XML import and export
To see inside a running program breakpoints, stepping, the call stack and variables on the compiled program, and Live Values to read, write and force I/O
Operator screens the HMI Builder in VS Code; the runtime serves the screens at /hmi, with trends and alarms
Field devices Modbus TCP, MQTT with Sparkplug B, OPC UA, Beckhoff ADS, EtherCAT and GPIO
Process data in a database OpenOT records values, alarms and messages in SQLite, PostgreSQL, TimescaleDB, MySQL, MariaDB, SQL Server or InfluxDB 3
Tuned control loops Control.PID, simulated plants and Control Studio, which identifies, tunes, validates and applies
PLC code in CI a command line that builds, tests, deploys and rolls back, and Structured Text unit tests with JUnit output

Quick start

In VS Code

  1. Install the extension: code --install-extension trust-platform.trust-lsp, or search for truST in the Marketplace.
  2. Run truST: Create Project from the Command Palette, or open one of the examples.
  3. Press Start in the truST side panel. It compiles the program and runs it on the simulator; the first build installs the compiler toolchain that the extension carries.
  4. Open Live Values to watch and force the I/O, or press Debug, set a breakpoint and step through the scan.

From the command line

trust-runtime new --parent . --name my-plc   # create a project
trust-runtime build --project ./my-plc       # compile it to native code for this computer
trust-runtime play --project ./my-plc        # run it

A new project serves its web UI on http://127.0.0.1:8080: the browser IDE at /ide and the operator screens at /hmi. No Rust installation is needed: the extension and trust-runtime install the compiler toolchain on the first build, also without a network connection (trust-runtime toolchain install --from trust-toolchain-<platform>.tar.gz).

Features

Write Structured Text

IEC 61131-3 Structured Text, with classes, interfaces, methods and namespaces. The language server checks the program as you type and knows every symbol of the project and its libraries.

  • Completion, hover, go to definition, find references, rename across files and formatting.
  • Write in VS Code, in the browser IDE that a runtime serves at /ide, or in Neovim, Zed and other editors through the language server.
  • Visual editors for Ladder, SFC, Blockly and statecharts keep a Structured Text companion in the project.
  • Libraries: OSCAT, PLCopen Motion, and truST’s control, plant, alarm, HMI and communication libraries; share your own through a package registry.
Completion while Structured Text is typed in VS Code, with the problem count updated as you type

Program in VS Code · Editors · Libraries

Bring existing code

  • Vendor profiles read the Structured Text of CODESYS and TwinCAT, Siemens SCL and Mitsubishi GX Works3: their syntax, naming and formatting, with each vendor’s known limits written down.
  • PLCopen XML import and export, with a migration report of what was carried over and what was not.

Migrate · Vendor profiles

Run it anywhere

Structured Text is translated into Rust and compiled with a pinned rustc into native code for x86-64, AArch64 and RISC-V. Programs are not interpreted.

  • The simulator in VS Code, trust-runtime on a computer, or a truST runtime on a chip: the same program and the same project.
  • IEC configurations, resources and tasks with their intervals and priorities; RETAIN values that survive a restart and a power loss; a watchdog and defined fault handling.
  • The simulator runs the program against simulated I/O, scripted scenarios and injected faults.
  • The compiler toolchain ships inside the VS Code extension and is checked against its manifest; you never install Rust yourself.

Build, validate, test · Simulation · ESP32-C6 getting started

Debug and watch

The debugger works on the compiled program, on the simulator and on a runtime.

  • Breakpoints, stepping, the call stack and variables.
  • Live Values reads, writes and forces inputs, outputs and memory while the program runs.
The debugger stopped in the compiled tank program after a breakpoint, with its locals, call stack and breakpoints

Debugging in VS Code · Live Values

Operator screens

The HMI Builder designs operator screens in VS Code, stored as TOML pages that diff and review like code. The runtime serves them at /hmi: process pictures, faceplates, trends, and an alarm library after ISA-18.2 and EEMUA 191. The Plant library’s pumps, valves, instruments, loops and sequences come with their operator panels.

The HMI Builder in VS Code: components on the left, the tank's level picture with its setpoint and pump on the canvas, and the page's settings on the right, in Live mode on the simulator The process picture of the hmi_equipment example at /hmi: an operator logs in, opens the LIC-101 faceplate and raises the setpoint, and the level follows in the trend and in the tank

The hmi_equipment example live at /hmi: an operator raises LIC-101’s setpoint, and the level follows.

HMI Builder · Operator guide

Devices, data and fleets

  • Modbus TCP, MQTT with Sparkplug B, OPC UA, Beckhoff ADS, EtherCAT and GPIO.
  • Devices & Connections in VS Code finds, configures and wires the devices of a project.
  • OpenOT records values, alarms, messages and the audit trail in SQLite, PostgreSQL, TimescaleDB, MySQL, MariaDB, SQL Server or InfluxDB 3, over CA-verified TLS to a database server.
  • Prometheus metrics and historian files for monitoring.
  • Discovery and pairing between runtimes, data sharing over Zenoh, and fleet federation.

Protocol matrix · Add a device · Databases

Operate in production

  • Deploy to a runtime and roll back, and change a running program online.
  • Operators log in at /hmi with their roles, and an audit log, once switched on, records control actions, operator writes and deployments.
  • Roll a project out to a fleet of runtimes with per-site settings, back up and restore a runtime, and install without a network connection.

Deploy and roll back · Audit log · Fleet rollout

Control engineering

Control.PID is a documented PID function block, and simulated plants bring dynamics, actuator limits, delays, disturbances, noise and faults through ordinary PLC I/O. Control Studio identifies a plant from experiments, tunes and validates a controller against the model, applies it to a running loop with a bumpless transfer, and restores the previous settings when needed. A control course of 89 runnable lessons goes from feedback basics to state-space, predictive and adaptive control.

Control Studio on the PID commissioning example: Identify runs a step test and fits a model, Tune proposes a PI controller, the frequency response, Validate passes every requirement, and Apply transfers the settings to the running loop

Control Studio · Control course

Automation

  • A command line for creating, building, testing, deploying and rolling back projects, ready for CI.
  • Structured Text unit tests with human, JSON, TAP and JUnit output.
  • A JSON-RPC Agent API and editor AI tools that work on typed truST interfaces.

Automate with the command line · CI/CD

Examples by task

Task Examples
A first program conveyor: press Start and watch it run in Live Values; the tutorials, from the first lines of Structured Text to unit tests
Seeing inside a running program memory_marker_counter: Live Values, breakpoints and the scan cycle
Operator screens hmi_equipment, hmi_tank_level
A complete plant room_heating
Tuning a loop control-pid-commissioning, the control course
Field devices communication, raspberry-pi
Motion plcopen-motion-single-axis
Visual programs ladder, sfc, statecharts, blockly
Tests and CI unit tests, a CI pipeline
Coming from another PLC PLCopen XML, Siemens SCL, Mitsubishi GX Works3
Libraries OSCAT, PLCopen Motion, Control, Plant, Alarm and HMI, Comm; every library’s manual is under Libraries
Runtimes working together runtime_cloud

Every example is a runnable project; examples/README.md lists them all.

Platforms

You write, build and debug programs on a computer, and a computer or a microcontroller runs them. A microcontroller does not run the development tools: you program it from one of the computers.

Platform VS Code extension and command line Runs PLC programs
Linux x86-64 and AArch64 yes yes
macOS, Intel and Apple silicon yes yes
Windows x86-64 yes yes
ESP32-C6 programmed from a computer above yes: truST firmware, installed over USB, with Wi-Fi and firmware updates
STM32U5A9 programmed from a computer above not yet: the firmware builds; it has not run on hardware

A Raspberry Pi runs the Linux AArch64 build; a board model counts as qualified only after it has passed truST’s device-in-the-loop tests. Linux PREEMPT_RT is a supported deployment, not a deterministic-latency certification: latency depends on the kernel, the hardware and the workload. Hardware behaviour is proven on the target where it is tested; see Hardware and Supported chips.

Downloads

Every release is built for linux-x64, linux-arm64, darwin-x64, darwin-arm64 and win32-x64:

Asset Contents
VS Code extension (.vsix) the extension with the language server, runtime, debugger, Control Studio and the compiler toolchain for that platform
trust-runtime-<platform> trust-runtime (runtime and command line), trust-dev (tests, docs, agent workflows) and trust-bundle-gen, with install notes and a systemd unit
trust-lsp-<platform> the language server, for other editors
trust-toolchain-<platform>.tar.gz the compiler toolchain: rustc, rust-lld, the target libraries and the PLC program library, with a hashed manifest
SHA256SUMS the checksum of every asset, with the release’s provenance and conformance status

Documentation

Start here
Install truST the extension, the runtime and the toolchain
Program in VS Code the main engineering workflow
Build, validate, test the command line and CI
Protocol matrix choosing a communication path
HMI Builder designing operator screens
ESP32-C6 getting started from a bare board to a running program
Libraries OSCAT, PLCopen Motion and truST’s own libraries
Reference commands, configuration, diagnostics and APIs

Development

truST is written in Rust; PLC programs and libraries are written in Structured Text. Every runtime and debugger behaviour is written down in a product specification and checked by native executable tests (specifications); a claim that depends on hardware or on the environment says what it was proven on. Interpretations of IEC 61131-3 are recorded in IEC decisions, and deliberate deviations in IEC deviations. A release is tagged only after its exact commit has passed formatting, Clippy, the documentation build, the full test suite and the VS Code tests.

Contributing and support

License

Licensed under either of MIT or Apache-2.0, at your option.

评论

暂无评论