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.
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.
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
- Safety
SIL or PL: which one does your machine need?
Two standards, two scales, and one machine. Which one applies, how they map to each other, and why the answer is usually ISO 13849.
- Safety
Categories B, 1, 2, 3 and 4, in plain terms
Five architectures, what a single fault does to each, and the practical wiring that goes with them.
- Safety
Safety relay or safety PLC: how to decide
One is a wiring decision, the other is a programming one. The count of safety functions, not the size of the machine, is what settles it.