MWL Automation Note
MWL Automation Note
Working code and maintainable code are not always the same thing.
Most controls engineers have probably inherited, or written, a PLC program that runs the machine perfectly well but could use some cleanup.
Maybe the naming is inconsistent. Similar functions are programmed several different ways. Old logic remains because nobody is completely sure whether it is needed. Comments no longer match the machine. A temporary fix made during startup eventually became part of the permanent program.
The programmer may know exactly what to clean up.
Then the production manager says:
“If it ain’t broke, don’t fix it.”
That is not necessarily bad advice.
A running production machine is usually not the place to reorganize software simply because the code could be cleaner. Refactoring introduces risk. A seemingly harmless change can affect sequencing, timing, interlocks, or an operating condition that rarely occurs.
In practice, major cleanup usually waits for a scheduled shutdown, controls upgrade, or another good reason to modify the machine.
Sometimes there is another opportunity. An OEM may have continued developing similar machines, and a newer system may already contain a cleaner, better-tested version of the same basic software. During a planned upgrade, some of those improvements may be brought back into the older machine rather than trying to clean up years of changes one rung at a time.
But there is a larger lesson.
The best way to deal with software technical debt may be to avoid creating so much of it in the first place.
That brings us to standardized, modular machine software.
If common functions such as motors, valves, alarms, permissives, manual controls, sequences, and diagnostics follow consistent structures from one project to the next, improvements become easier to reuse. Troubleshooting also becomes easier because engineers and technicians do not have to relearn the basic software architecture every time they open another machine.
The goal is not to make every machine identical. Laser cutting, welding, cladding, and additive manufacturing systems can have very different requirements.
The goal is to make the common parts common.
So maybe the question is not only, “When should we refactor this PLC program?”
It is also, “What can we do differently on the next machine so less refactoring is needed later?”