The Problem
PLC programming in 2025 still looks like this:
- Open a 2GB proprietary IDE
- Click "New Rung"
- Drag a NO contact from a palette
- Click to place it
- Type the address in a popup
- Repeat 500 times
For X1 AND X2 → Y50, that's 12 mouse clicks.
The Solution
1 2 = 50
One line. 8 characters. Zero clicks.
I built BNS Lang — a minimal DSL where numbers are I/O addresses and symbols are logic operators. The entire grammar is 15 lines of BNF.
How it works
Numbers = I/O addresses
Space = AND (series)
| = OR (parallel)
- = NOT (normally closed)
= = output coil
Self-holding motor circuit
Every PLC engineer writes this 100 times a year:
1 -2 | 100 = 100
This compiles to:
──┤ X1 ├──┤/X2 ├──┬──( Y100 )
│
──┤Y100 ├──────────┘
And outputs IEC 61131-3 Structured Text:
Y100 := (X1 AND NOT X2) OR Y100;
Traffic light controller
T302 -T300 = 100 # Green phase
T300 -T301 = 101 # Yellow phase
T301 -T302 = 102 # Red phase
100 = T300 5000 # Green timer 5s
101 = T301 2000 # Yellow timer 2s
102 = T302 5000 # Red timer 5s
Six lines. Complete state machine.
AI-native: MCP server for Cursor / Claude Code
This is where it gets interesting. BNS Lang ships with an MCP server, so you can do this inside Cursor:
You: "Make a conveyor controller with emergency stop"
Cursor: [generates BNS] → [validates] → [compiles to ST] → [shows ladder diagram]
Natural language → BNS Lang → IEC 61131-3, without leaving your editor.
The .cursorrules file is included — clone the repo and Cursor already knows the syntax.
Why LLMs + BNS Lang?
Traditional ladder logic is visual (GUI layouts, not text). Structured Text is text-based but verbose — LLMs frequently mess up variable declarations and types.
BNS Lang is pure logic, zero boilerplate. An LLM only needs to know 5 rules. The compiler handles everything else.
Target PLCs
| Target | Status |
|---|---|
| LS Electric XGT | ✅ Production |
| IEC 61131-3 Generic | ✅ Production |
| Inovance H5U/H3U | 🚧 Beta |
| Siemens S7 | 📋 Planned |
| Mitsubishi MELSEC | 📋 Planned |
Why I built this
The industrial automation market is $200B+. PLC programming is a bottleneck. Most PLC engineers are aging out with no replacements.
AI-generated PLC code could be the bridge — but only if there's a language simple enough for AI to reliably produce. BNS Lang is that language.
MIT licensed. PRs welcome.
██████╗ ███╗ ██╗███████╗ ██╗ █████╗ ███╗ ██╗ ██████╗
██╔══██╗████╗ ██║██╔════╝ ██║ ██╔══██╗████╗ ██║██╔════╝
██████╔╝██╔██╗ ██║███████╗ ██║ ███████║██╔██╗ ██║██║ ███╗
██╔══██╗██║╚██╗██║╚════██║ ██║ ██╔══██║██║╚██╗██║██║ ██║
██████╔╝██║ ╚████║███████║ ███████╗██║ ██║██║ ╚████║╚██████╔╝
╚═════╝ ╚═╝ ╚═══╝╚══════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝
Write PLC ladder logic with just a numpad.
A minimal DSL that compiles to IEC 61131-3 ladder diagrams.
No IDE needed. No mouse clicking. Just type numbers → get rungs.
Quick Start · Syntax · Examples · Why? · Roadmap
⚡ 3 Seconds to Understand
Traditional PLC programming requires a GUI IDE, mouse-clicking contacts onto rungs, and navigating nested menus. BNS Lang lets you type it.
BNS Lang Ladder Diagram
1 2 + 3 = 50 ──┤ X1 ├──┤ X2 ├──┬──┤ X3 ├──── ( Y50 )
│
1 2 | 4 = 50 ──┤ X1 ├──┤ X2 ├──┤ X4 ├────── ( Y50 )
That's it. Numbers are I/O addresses. + is series (AND). | is…
Top comments (0)