Naming and structure conventions worth adopting
A convention nobody follows is worse than none. Here is a small set that survives contact with a real project.
By the LADX engineering team
Short answer
The conventions that survive are short: descriptive tag names that read in a rung, a consistent prefix or suffix scheme for signal types, one routine per machine area, and comments that explain intent rather than mechanism. A short standard people follow beats a comprehensive one they abandon in week two.
Every plant has a programming standard. Most of them are twenty pages long and followed for the first two weeks of a project.
Keep it short enough to remember
A convention that fits on a page gets followed. One that requires reference does not.
Names should read in a rung
Conveyor_1_Run_Cmd reads. CNV1RC does not, and the saving is meaningless on hardware that has not been short of memory for twenty years.
Pick an order, equipment then signal then type, and stay with it. Consistency is worth more than the specific choice.
Structure by area, not by instruction type
One routine per machine area, so somebody hunting a behaviour can guess where it lives. Grouping all timers together makes the program look tidy and makes it unreadable.
Comment intent
The code says what it does. The comment should say why it is there.
'Guard must remain closed two seconds after cycle end, added after 2019 incident' is worth a hundred comments that restate the mnemonic.
Enforce lightly
A review before handover catches most drift. A rule with no check is a suggestion, and everybody knows it.
Sources and further reading
- PLCopen software construction guidelinesplcopen.org
- Siemens Programming Guideline for S7-1200/S7-1500 (TIA Portal)cache.industry.siemens.com
Common questions
- How should PLC tags be named?
- So the rung reads as a sentence. Conveyor_1_Run_Cmd is better than CNV1RC, and the extra characters cost nothing on a modern controller. Include the equipment, the signal and the type, and stay consistent about the order, because consistency matters more than the specific scheme.
- Should I use a formal standard like PackML?
- If you build machines that integrate into other people's lines, yes, because the value is in the shared vocabulary. For a one-off machine maintained by one team it is usually more structure than the problem needs, and a short internal convention followed consistently delivers more.
Keep reading
- Practice
PLC simulators: what each one is actually for
Vendor simulators, virtual factories and browser tools solve different problems, and picking the wrong one wastes weeks.
- Practice
Learn PLC programming free: a 30-day plan with no hardware
A 30-day plan to learn PLC programming at home for free: ladder fundamentals, four virtual PLC machines, Structured Text and a small project, all in a browser.
- Practice
Virtual commissioning explained: testing PLC code before the machine exists
What virtual commissioning is, the model, software and hardware in the loop levels, what a plant model needs, the tools used and a small version you can run today.