Attention
IronPLC can only run very simple programs. The steps described are accurate but many language features are not yet supported.
Compiling and Running¶
So far you have been writing code and letting the VS Code extension check it for correctness. In this chapter, you will use the command line to compile your program into a bytecode container and run it.
Note
This guide assumes you have installed the IronPLC Compiler. See Installation if you have not already installed it.
Warning
The compile command currently supports only trivial programs. Supported
features include: PROGRAM declarations, INT variable
declarations, assignment statements, integer literal constants, and
the + (add) operator. Programs using other features will produce a
code generation error.
Check the Program¶
Open a terminal in your helloworld directory and run:
ironplcc check main.st config.st
On success, the command produces no output. If there are errors, IronPLC prints diagnostics with the file name, line number, and a description of the problem.
Compile to Bytecode¶
To compile your source files into a bytecode container (.iplc file),
run:
ironplcc compile main.st --output main.iplc
You can also use the short form -o for the output flag:
ironplcc compile main.st -o main.iplc
On success, the command creates the .iplc file at the specified path.
Run the Program¶
Use the IronPLC virtual machine runtime to execute the compiled program:
ironplcvm run main.iplc
You can inspect variable values after execution by specifying a dump file:
ironplcvm run main.iplc --dump-vars output.txt
What You Have Learned¶
Over the course of this tutorial, you have:
Installed IronPLC and the VS Code extension.
Written a minimal IEC 61131-3 program.
Connected it to inputs and outputs with directly represented variables.
Configured the application with a task, resource, and configuration.
Organized the code across multiple files.
Compiled and run the program from the command line.
Where to Go from Here¶
Explanation — deepen your understanding of IEC 61131-3 concepts.
How-to guides — practical guides for specific tasks.
Compiler reference — full command and language reference.