Run TwinCAT 3 Projects Without a PLC

This guide shows how to compile a Beckhoff TwinCAT 3 project and execute its logic in the IronPLC virtual machine — on any computer, with no TwinCAT runtime, no license, and no PLC hardware. This is useful for testing control logic on a laptop or in a CI/CD pipeline.

Note

This guide assumes you have installed the IronPLC Compiler. See Installation if you have not already installed it.

Compile the Solution

Compile your solution into a bytecode container: point ironplcc at the directory that holds your .sln file and select the twincat dialect:

ironplcc compile --dialect twincat path/to/my-solution --output main.iplc

IronPLC reads the .sln, follows it through the .tsproj files to each .plcproj project, and takes the sources from there. It activates any referenced Beckhoff libraries (see Use Beckhoff Libraries), and on success creates main.iplc — the compiled bytecode that the IronPLC virtual machine executes.

Run the Compiled Program

Run the container in the IronPLC virtual machine:

ironplcvm run main.iplc --scans 1 --dump-vars

The --scans 1 flag runs one scan cycle, and --dump-vars prints the value of every variable after execution. For a program that converts a commanded speed from degrees to radians, the output looks like:

commandedDegPerSec: 15
commandedRadPerSec: 0.2617993877991494

Your MAIN program runs exactly as it would in each PLC cycle. To observe state that evolves over time — timers, counters, edge triggers — increase --scans.

Run in a CI/CD Pipeline

Both tools return a non-zero exit code on failure, so the same commands work as a pipeline gate. Run them from the directory that holds your .sln file:

ironplcc check --dialect twincat . || exit 1
ironplcc compile --dialect twincat . --output main.iplc || exit 1
ironplcvm run main.iplc --scans 10 || exit 1

This catches problems on every commit — before the code ever reaches a test rig.

See Also