A real ladder editor, inside VS Code
Ladder Logic in VS Code
All posts · Nautilus ·
Companion post for the week-3 video. The 5-minute editor tour covers the same ground on screen: watch it here.
Last week was Structured Text. This week I'm adding a third task to the same project, in a third language: an annunciator in ladder logic using the Nautilus ladder editor in VSCode.
The project is the heated tank from the ST video, plus one file:
program.st the pump latch, the temperature PI loop, and the AH-101 alarm latch
sim.st the plant physics, in Structured Text
interlocks.ld the annunciator — a horn with a grace timer and an acknowledge
nautilus.yaml every tag, with its type, units and description
All three programs share one set of tags, and every tag has exactly one writer. The alarm bit is still set by the Structured Text program from last week. The horn and the acknowledgement are written by the new ladder program. I put the annunciator in ladder because that is where an operator or an electrician expects to find it.
Open With → Ladder Diagram
The diagram is a custom VS Code editor from the Nautilus extension. Right-click the file (or Reopen Editor With…) and pick Ladder Diagram, or configure it as the default editor for .ld files. With the controller running, power flow paints the rungs with live values: contacts light as their tags go true, the timer shows its elapsed time, the coil follows.
Every rung is a line of text
The .ld file is plain text, one rung per line, read left to right along the power rail:
RUNG horn (* either alarm, held 2 s, sounds the horn until the operator acks *)
[ HiTempAlm | TempLowAlm ] t1:TON(PT := T#2S, ET => InSecs) /HornAck ( Horn )
RUNG ackclear (* the ack releases itself once both alarms clear *)
/HiTempAlm /TempLowAlm ( R HornAck )
Elements in series AND together; square brackets make a parallel branch: an OR of the two alarms. The t1 is an IEC timer in the rung, with the standard's => binding capturing its elapsed time. The slash is a normally-closed contact (power passes while the acknowledgement is off), and the coil at the end assigns the horn every scan. The second rung's R coil is a reset: when both alarms are gone, it releases the acknowledgement for the operator.
No vendor dialect, no export format. This is the file, which is why everything below works.
Edit the diagram, watch the text change
Split the editor, the file as text on the left and the ladder on the right, and the diagram edits structurally. Double-click the timer, give the horn five seconds of grace instead of two, and the changed line lands in the text beside it as the rung redraws. Contacts, coils, branches, timers: every gesture becomes plain text you could have typed yourself.
The editor checks ladder's rules
In text form, Nautilus treats a .ld file the way it treats .st: live values as pills on every tag, the compiler on every keystroke. And it enforces ladder's rules. Power is boolean, so a math function can't gate a rung:
Put an ADD where a contact belongs and the rung gets a compile error immediately, and a program that doesn't compile won't download: the controller compiles on download and rejects a bad program with the old one still running. Download itself is the same command the ST video used, from the command palette.
A ladder change you can review
Because the rung is a line of text, the timer change is one line in git diff, readable on its own. And if you'd rather review it as ladder, nautilus: Diff Ladder Diagram (vs git HEAD) draws your working tree against the last commit as rungs, the changed timer boxed amber with the previous value.
That's the piece that mostly doesn't exist in traditional PLC IDEs outside of limited compare tools: ladder changes you can review over time, graphically, for any committed version, or hand one to a teammate as a pull request, where the one-line change reads like any other code review.
What's next
Next week: the same treatment for function blocks, the FBD editor, with live values in the diagram.
Docs: nautilus.joyautomation.com · Repo: github.com/joyautomation/nautilus
Subscribe to the weekly newsletter to keep up to date: joyautomation.com/newsletter
Nautilus is open source, Apache-2.0. If your plant has logic nobody dares touch because there's no record of why it works, that's the problem Joy Automation solves for a living. Start with a Control System Assessment: https://joyautomation.com/services#assessment