Table of Contents
ToggleYour first ladder program in OpenPLC is one rung: a switch contact that drives a lamp coil. We build it in the editor, generate the file, run it on the runtime and watch the lamp turn ON in Monitoring.
Build a one rung ladder program in OpenPLC Editor, turn it into a .st file and run it on the OpenPLC runtime. Every screenshot comes from the project we built and tested for this lesson.

How do you make an OpenPLC Editor first program?
OpenPLC Editor first program is a single ladder rung where a normally open contact SWITCH at %IX0.0 drives a coil LAMP at %QX0.0. You create a project, declare both variables, draw the rung, generate a .st file and upload it to the runtime. In our test, switching %IX0.0 to TRUE turned LAMP TRUE in Monitoring within half a second.
- File, New: pick an empty folder, POU type program, language LD.
- Add SWITCH (BOOL, %IX0.0) and LAMP (BOOL, %QX0.0).
- Draw a contact for SWITCH and a coil for LAMP between the rails.
- Click Generate program for OpenPLC Runtime and save the .st file.
- Upload it on port 8080, start the PLC and open Monitoring.
What Is an OpenPLC Editor First Program?
An OpenPLC Editor first program is the smallest useful ladder program: one normally open contact that switches one output coil. It takes you through the full workflow, from an empty project to a running PLC, with no logic to get in the way.
- One rung: SWITCH at %IX0.0 drives LAMP at %QX0.0.
- The editor saves a .st file that the runtime compiles.
- Task interval T#20ms, so the rung runs 50 times a second.
- Monitoring refreshes every 500 ms by default.
PLC Tutorials series: this is lesson 2. In Lesson 1 we installed the OpenPLC runtime on Linux, and this lesson uses that same runtime on port 8080.
If ladder symbols are new to you, read ladder logic for beginners first. A quick look at what a PLC is also helps you picture where inputs and outputs come from.
What Do You Need Before You Start?
You need OpenPLC Editor on your PC and a running OpenPLC runtime that you can open in a browser. The editor is free for Windows, Linux and macOS, and it builds every lesson in this series.
| Item | What we used | Why |
|---|---|---|
| Editor | OpenPLC Editor on Linux | Draw and generate |
| Runtime | OpenPLC runtime, port 8080 | Compile and run |
| Login | openplc / openplc | Default account |
| Input | Python script as a switch | No input card |
| Browser | Any modern browser | Upload and Monitoring |
OpenPLC Editor is built on an open source IEC 61131 3 editor, so it also offers FBD, ST, IL and SFC. We use ladder (LD) here because most plant technicians read it first.
How to Create a New Project in OpenPLC Editor
Create the project with File, New, choose an empty folder, and the editor asks for the first POU. Name it FirstProgram, keep POU type as program and set the language to LD.
The project tree of the OpenPLC Editor first program then holds FirstProgram and a resource called Res0. Res0 holds the task that calls your program every T#20ms.

The Location column decides whether a variable is real I/O. %IX0.0 is input byte 0 bit 0 and %QX0.0 is output byte 0 bit 0, the same scheme explained in PLC memory addressing.
Leave Location empty for internal bits. Only located variables, the ones with a %I or %Q address, appear on the runtime Monitoring page.
How Does the One Rung Program Work?
The rung works like a wire through a switch: when SWITCH is TRUE the contact closes, power flows from the left rail to the coil, and LAMP becomes TRUE. When SWITCH is FALSE the contact opens and the coil drops in the same scan.

To draw it, place a contact from the ladder toolbar, double click it and pick SWITCH with the Normal modifier. Then place a coil, pick LAMP, and drag wires from the left rail to the contact, the contact to the coil, and the coil to the right rail.
| SWITCH %IX0.0 | Contact | LAMP %QX0.0 |
|---|---|---|
| FALSE | Open | FALSE |
| TRUE | Closed | TRUE |
A comment box above the rung, such as Rung 1: SWITCH ON turns LAMP ON, costs nothing and helps the next person who opens your OpenPLC Editor first program.
The coil in this rung is not a physical relay coil. It writes a bit in the output image, and the runtime copies that bit to the output at the end of the scan.
Why the Scan Cycle Matters Even for One Rung
The scan cycle matters because the lamp never follows the switch instantly: the runtime reads inputs, solves the rung, then writes outputs, once every task interval. A change that lands just after an input read waits for the next scan.
With T#20ms the program runs 50 times a second, which is fast enough for any push button. The full read, solve and write cycle is covered in how the PLC scan cycle works.
The calculator adds the input filter, one task interval and the output delay to give the worst case delay from switch to lamp. Our defaults assume a 3 ms input filter and a 10 ms relay output, typical figures for a DC input card and a relay output module.
= 3 + 20 + 10 = 33 ms
Best case = 3 + 10 = 13 ms
Scans per second = 1000 ÷ 20 = 50

With a transistor output the last term almost disappears. Compare both in PLC output module types.
How to Generate the Program and Upload It to the Runtime
Click the orange down arrow, Generate program for OpenPLC Runtime, and the editor compiles the ladder to IEC Structured Text and asks where to save the .st file. The console must end with OpenPLC program generated successfully before you upload anything.

Open the saved first_program.st in a text editor and the whole rung is one line: LAMP := SWITCH;. The file also holds the variable list and the CONFIGURATION block with task0 at T#20ms, all written in Structured Text.

In the glueVars lines, __IX0_0 and __QX0_0 are your two located variables. If one is missing, its Location field in the editor is empty or wrong.
Upload a new .st file whenever you change the rung. The runtime always runs the last program you compiled, not the project open in the editor.
How to Test the Program in OpenPLC Monitoring
Press Start PLC on the Dashboard, open Monitoring and change %IX0.0: LAMP must copy SWITCH within one refresh. Monitoring can write %QX outputs but not %IX inputs, so the input needs a source.
Our PC had no input card, so we used the runtime Python submodule as the hardware layer, and a small script set %IX0.0 TRUE or FALSE like a real selector switch. With SWITCH FALSE both rows read FALSE, and after we switched it ON both turned TRUE.

That screen proves your OpenPLC Editor first program runs. The top bar reads Running: First Program, and the green markers follow the switch.
The Write buttons on the LAMP row can force the output, but the rung overwrites it in the next scan. For this program LAMP always follows SWITCH.
Siemens and Allen Bradley Equivalents
The rung of your OpenPLC Editor first program exists on every PLC: a normally open contact on an input and an output coil. Only the symbol names and address format change.
Normally open contact on I0.0 and an assignment coil on Q0.0 in OB1.
XIC on the input tag and OTE on the output tag in the MainRoutine.
XIC on I:0/0 and OTE on O:0/0.
Before you port the rung, check the hardware families in S7 1200 vs S7 1500 and types of Allen Bradley PLCs. All of them follow the IEC 61131 3 programming languages ideas you meet here.
- The full edit, generate, upload and run loop
- How located variables map to real I/O
- How to prove a rung with live Monitoring
- Holding an output after the button is released
- Normally closed contacts and stop logic
- Timers, counters and analog values
Common Mistakes and Troubleshooting
Most faults in an OpenPLC Editor first program come from an empty Location field, a rung not wired to both rails, or an older program still running. Check each step of the flowchart before you change the logic.

| Symptom | Likely cause | Fix |
|---|---|---|
| Generate fails | Wire not connected to a rail | Redraw the wire to the pin |
| Variable not in Monitoring | No Location address | Set %IX0.0 or %QX0.0 |
| LAMP never turns TRUE | Input never reaches %IX0.0 | Check the hardware layer or wiring |
| Old behaviour after edit | Old .st still running | Generate and upload again |
| Monitoring asks for Modbus | Modbus server off | Enable it in Settings |
- Both variables have a Location address.
- Rung wired from the left rail to the right rail.
- Console ends with program generated successfully.
- Runtime log ends with Compilation finished successfully!
- Monitoring: LAMP follows SWITCH.
If the input never changes on real hardware, check the field wiring with sinking and sourcing in PLC and work through PLC troubleshooting steps.
The video below builds a beginner ladder example in OpenPLC; compare it with your rung.
For more editors and simulators see free PLC programming software, and for more rungs to practise try PLC ladder logic examples. When you are ready, test yourself with the PLC objective quiz.
OpenPLC Editor First Program FAQ
Create a new project in an empty folder, add a program POU in LD, declare SWITCH at %IX0.0 and LAMP at %QX0.0, and draw one contact to one coil.
Then generate the .st file, upload it on port 8080 and start the PLC.
The Monitoring page holds only located variables, the ones with a %I, %Q or %M address in the Location column. An internal bit with an empty Location stays hidden there.
Give it a spare address while testing, then generate and upload the program again.
A save writes the project files, plc.xml and beremiz.xml, so you can edit the rung later. Generating compiles the ladder into a .st file that the runtime can upload and run.
The runtime never reads plc.xml, only the generated .st file that you upload.
Worst case is about filter plus one interval plus output delay, so 3 + 20 + 10 = 33 ms with a relay output. Best case is about 13 ms.
Monitoring refreshes every 500 ms, so the screen lags behind the real output.
Yes, the runtime runs with no I/O card, and Monitoring can force %QX outputs directly. For %IX inputs we used the Python submodule as the hardware layer, with a script acting as the switch.
The program logic behaves the same as on real hardware.
Choose ladder (LD) if you work with relay panels or read electrical drawings, because contacts and coils match those symbols. The editor turns it into Structured Text anyway when you generate.
Later lessons in this series cover ST and FBD for maths and function blocks.
Related Articles
- Ladder Logic for Beginners
- Free PLC Programming Software
- How the PLC Scan Cycle Works
- PLC Memory Addressing
- PLC Ladder Logic Examples
External References
- Logix 5000 Controllers General Instructions Reference Manual (PDF)
- Creating Your First Project in OpenPLC
- Ladder logic (Wikipedia)
What We Learn Today
- An OpenPLC Editor first program is one rung where a normally open SWITCH contact at %IX0.0 drives a LAMP coil at %QX0.0.
- The editor generates a .st file, the runtime compiles it on upload, and Monitoring proves the program by showing LAMP follow SWITCH live.
- Response time depends on the scan: with a 20 ms task, a 3 ms filter and a relay output, the worst case delay is about 33 ms.

