Attention
IronPLC supports IEC 61131-3 Structured Text excluding I/O mapping.
Working with Multiple Files¶
As your IEC 61131-3 application grows, you will want to organize your code across multiple files. IronPLC combines all files into a single unit, so you can split your application however you like.
Split the Application¶
Right now, main.st contains both the program and the configuration.
Let’s separate them.
First, edit main.st so it contains only the program:
PROGRAM main
VAR
Button : BOOL;
Buzzer : BOOL;
PulseTimer : TON;
END_VAR
PulseTimer(IN := NOT Button, PT := T#500ms);
Buzzer := PulseTimer.Q;
END_PROGRAM
Next, create a new file for the configuration:
In the main menu, select .
In the New File… dialog, select the option.
Enter the following code:
config.st — Configuration only¶CONFIGURATION config RESOURCE res ON PLC TASK plc_task(INTERVAL := T#100ms, PRIORITY := 1); PROGRAM plc_task_instance WITH plc_task : main; END_RESOURCE END_CONFIGURATION
Save the file with the name
config.st.
The IronPLC extension checks all .st files in the workspace
together, so it will still validate that the configuration references a
valid program.
Run with Multiple Files¶
Open main.st in the editor and click Run Program above
the PROGRAM main line. The extension compiles all .st files in
the workspace together before running, so the configuration in
config.st is included automatically.
Verify the output in the IronPLC Run panel matches what you saw before, then click Stop to end execution.
Tip
When using the command line, you must pass all source files explicitly. See Check, Compile, and Run from the Command Line for details.
Why Split Files?¶
For a small example like this, splitting may seem unnecessary. But in real-world projects, separating programs from configuration has clear benefits:
Reuse — the same program can be referenced from different configurations (for example, testing vs. production).
Organization — each file has a single responsibility.
Collaboration — different team members can work on different files.
IronPLC does not impose any naming conventions on your files. Use whatever structure makes sense for your project.
Next Steps¶
You now have a complete, multi-file IEC 61131-3 application. In the final chapter, you will learn how to connect your program to physical hardware inputs and outputs.
Continue to Connecting to Hardware.