Website review
This review may include AI-generated content and is not individually verified. Domain, certificate and other facts come from the observed data on this page.
What is Contact and Coil?
Contact and Coil is a personal blog about industrial automation and PLC programming, written from a working programmer's perspective. Its posts dig into ladder logic design, code structure and the everyday maintainability problems that automation engineers run into on real machines.
What the writing is like
The site's tone is opinionated and practical rather than tutorial-style. A representative post, "We Need More Functional Programming in our Ladder Logic," takes a concrete case: a machine with several pumps, each with its own routine, plus a separate rung that answers "is any pump running?" The author points out that whenever a pump is added or removed, someone must remember to revisit that rung, and that this kind of duplicated, easily forgotten logic is a common source of bugs. He walks through workarounds (an array with a FOR loop, or latch/unlatch bits collected across the scan) and explains why each is awkward and hard to cross-reference, then argues that PLC vendors should provide better tools.
Who it suits
- Controls and automation engineers who write ladder logic daily and want design-level discussion, not vendor manuals.
- Programmers maintaining inherited code who recognize the "who wrote this and why" problem.
- Readers interested in the craft side of PLC work—naming, structure, cross-referencing, scan-order thinking.
It is less useful if you need step-by-step instructions for a specific controller brand or introductory training material; the value is in the reasoning and the critiques.
A useful next step
If you maintain PLC code, read the pump example with your own project in mind: pick one summary rung or bit that depends on a list of devices, and check what happens when that list changes. That single exercise will tell you quickly whether the site's concerns match your situation. For broader community discussion of similar problems, PLCtalk hosts practitioner forums, and Reddit's automation communities carry informal day-to-day debate.
How can ladder logic be made more maintainable when adding or removing pumps?
The core fix is to stop maintaining a separate "Any Pump Running" rung by hand. Instead, make the summary logic derive itself from the pump logic, so adding or removing a pump routine doesn't leave a stale contact somewhere else in the program. Contact and Coil frames this as a functional-programming gap in ladder logic: the "any pump running" rung is physically separate from the per-pump routines, so nothing forces a programmer to revisit it when the machine changes.
Practical options, from simplest to most structural
- Array plus loop. Put each pump's running bit in an indexed array and compute "any running" with a FOR loop over the active count. This removes the edit step entirely, but only works if pumps are numbered sequentially, and it makes the coil hard to trace back to a specific pump. Contact and Coil calls this workable but ugly.
- Latch/unlatch accumulator. Reset a temporary "any running" coil at the start of the scan, latch it in parallel with each pump's running coil, then drive the real coil from the temporary. This is less ugly than the loop, but it still has the cross-referencing problem: you must remember to add the latch in every new pump routine.
- Self-contained pump routines. Give each pump one routine that owns its own logic and contributes to the summary, so copying the routine is the only step needed. The trade-off is that the summary coil no longer reads as a single visual rung.
- Ask for better tooling. The underlying complaint is that the editor won't flag a summary rung that has gone out of date when you add a pump. Vendor-side features—cross-reference checks, generated logic, or structured text for aggregation—address the root cause rather than working around it.
How to choose
For a machine with a fixed, small pump count, the latch approach is fine and readable. For a machine where the count changes often—the scenario Contact and Coil describes, where the original author may be long gone—favor the array/loop or self-contained-routine pattern, and document the convention in the routine header so the next programmer knows the summary updates automatically. If you're evaluating PLC platforms for a new line, treat "can this editor warn me when a summary rung references removed tags or misses added ones?" as a concrete selection criterion.
For more on ladder logic structure and industrial automation practice, see Contact and Coil.
Why does a separate 'Any Pump Running' rung create cross-referencing problems in PLC programs?
A separate "Any Pump Running" rung creates cross-referencing problems because it duplicates knowledge that already lives in each pump's own routine. The pump logic knows whether Pump1, Pump2, and so on are running; the summary rung re-states that list somewhere else. Whenever the machine changes—pumps added or removed—two places must change together, and nothing in the editor forces that.
Where it breaks down
- Adding a pump is the silent failure. Removing Pump2 usually triggers an editor warning about a missing tag. Adding Pump4 triggers nothing, because the new pump's logic is valid on its own; the summary rung simply never learns about it. The result is a rung that compiles cleanly and reports the wrong answer.
- The rung is position-dependent. It sits after the pump logic by convention, not by any language rule. Reordering routines or copying a pump routine into a new program can leave the summary stale without any visible error.
- Maintenance burden falls on whoever didn't write it. As the Contact and Coil author notes, the code may be years old or written by someone else, and the same pattern repeats for steps, missions, or hundreds of similar items—each one a place to forget.
Workarounds and their trade-offs
| Approach | What it fixes | What it costs |
|---|---|---|
| Array of pump-running bits plus a FOR loop | One place to update; scales to any count | Requires sequential numbering; hard to trace a single coil back to its source |
| Reset a temp bit at scan start, latch it in parallel with each pump coil, drive the real coil at the end | Avoids editing a long OR rung | Still needs a parallel edit per pump; same cross-referencing weakness; the author calls it ugly and admits to using it |
| Keep the explicit OR rung | Simple to read and trace | Every add or remove requires a manual edit |
A practical decision rule
If the count of items is fixed and small, the explicit rung is the clearest option—keep it. If the count changes often, prefer a structure where the summary is derived rather than listed: an array with a loop, or a function block that owns both the per-pump logic and the aggregate output, so adding a pump means instantiating one block and nothing else. The test is simple: when you add the next pump, how many files do you have to remember to open? The right design makes that answer one.
For more on this pattern and the case for more expressive ladder logic, see Contact and Coil.
What are the trade-offs of using a FOR loop or latch/reset hack versus functional programming for aggregating pump status?
A FOR loop or latch/reset pattern keeps the aggregate status rung working without hand-editing it each time a pump is added or removed, but both trade that convenience for reduced readability and harder cross-referencing. The functional-programming alternative the article argues for would let the aggregate be derived from the pump logic itself, so adding or removing a pump can't silently leave the "any pump running" rung stale.
The trade-offs
| Approach | What it buys you | What it costs |
|---|---|---|
| FOR loop over a pump-status array | No manual edits to the aggregate rung when pump count changes; works when pumps are numbered sequentially | Hard to follow which pump is driving the coil; requires sequential numbering; the article's author calls it "really ugly" |
| Latch/reset "tempAnyPumpRunning" coil | Less ugly than the loop; still avoids revisiting the rung on add/remove | Still a cross-referencing problem; the author admits using it and cursing ladder logic for being inexpressive |
| Functional aggregation (the article's proposal) | Aggregate is tied to the pump logic, so changes propagate | Depends on PLC tooling the author says vendors should provide; not a workaround you can apply in today's editors |
The core problem the article describes is that the aggregate rung sits after the pump routines and is separate from them. Removing Pump2 may trigger an editor warning about a missing tag, but adding Pump4 gives no prompt to revisit the rung—especially for someone unfamiliar with the code. That's the scenario to weigh: if your machine changes often and the code outlives its author, the loop or latch hack is a stopgap, not a fix.
Decision criterion
If pumps are strictly sequential and you can accept a less legible coil, the FOR loop is the least manual option available today. If legibility matters more and changes are infrequent, the latch/reset pattern is marginally easier to read. Either way, treat both as workarounds and ask your PLC vendor for aggregation tools that keep the "any pump running" logic coupled to the pump routines themselves. For related discussion of ladder logic structure, see Contact and Coil.
How does functional programming help industrial automation programmers avoid revisiting unrelated rungs?
Functional programming helps by removing the need for a separate rung that aggregates state. In the ladder-logic example on Contact and Coil, the "Any Pump Running" rung must be manually updated whenever a pump is added or removed. A functional approach would derive that result from the pump logic itself—for example, by reducing a collection of pump-running states into a single boolean—so adding or removing a pump changes only the pump definition, not a distant aggregate rung.
What changes in practice
- Single source of truth: The "any running" value is computed from the pump set rather than duplicated in a hand-maintained rung.
- Local edits: Adding Pump4 means adding its logic in one place; the aggregate updates automatically.
- Fewer cross-reference traps: There is no separate rung to remember, and no stale tag reference when a pump is deleted.
- Less reliance on editor warnings: Missing-tag detection helps when removing a pump, but it does not prompt you when adding one—the gap the article highlights.
Trade-offs
Ladder logic is visual and familiar to maintenance technicians; a functional or array-and-loop style can be harder to trace at a glance. The article itself notes that a FOR-loop workaround makes it difficult to follow the "AnyPumpRunning" coil back to the specific pump. A practical middle ground is to keep per-pump logic readable and generate the aggregate through a reusable function or structured pattern, rather than a hand-edited rung.
Next step: For a machine with frequently changing device counts, list every rung that references individual device tags outside the device's own routine. Each is a candidate for replacement by a derived aggregate.
What should PLC vendors provide to reduce the need for manual updates to summary rungs?
PLC vendors should give ladder-logic programmers a way to define a summary rung as a query over a set of similar objects—such as all pump routines or all pump-running bits—rather than as a fixed list of contacts. When a pump is added or removed, the summary should update because the set it references has changed, not because someone remembered to edit a separate rung.
What that looks like in practice
The page's example is a machine with Pump1, Pump2, and so on, each with its own routine, plus an "Any Pump Running" rung that ORs the individual running bits. The rung sits after the pump logic, so adding Pump4 creates no prompt to revisit it, and a programmer unfamiliar with the code may not know it exists. The author of Contact and Coil calls this a common ladder-logic problem that programmers "just live with," and argues they should ask vendors for better tools. His own workarounds—a FOR loop over an indexed array of running bits, or a latch/reset "tempAnyPumpRunning" coil—both still require the summary logic to be maintained separately and are hard to cross-reference.
The vendor features that would remove that burden, in concrete terms:
- Typed, named collections. A pump type with instances, so "all pumps" is a first-class reference instead of a hand-built list of tags.
- Aggregate instructions. Built-in "any" and "all" operations over a collection, so the summary rung is one expression that stays correct as members change.
- Automatic cross-reference and change prompts. When an instance is added or deleted, the editor flags or updates every consumer, including summary logic.
- Refactoring support. Rename, copy, and delete operations that carry dependent logic with them, the way routine-copying currently leaves summary rungs behind.
- Readable traceability. A way to expand or trace an aggregate back to its members, avoiding the FOR-loop problem where the AnyPumpRunning coil can't be followed to the specific pump that is running.
How to judge a vendor's answer
Ask for a demonstration rather than a feature list: add a fourth pump instance in front of the vendor and see whether the summary logic changes on its own, whether the editor warns about stale references, and whether an engineer who has never seen the code can trace the summary back to its members. The trade-off is that aggregate constructs can hide which member triggered a result, so weigh expressiveness against the diagnostic clarity the page values.
User reviews (0)