One Missing Pair of Parentheses Changes PLC Logic? Prove the Truth Table
- PLC Play Ground
- 0
- Posted on
Mixed AND and OR expressions can mean something different from the sentence an engineer intended. When one combination unexpectedly enables a function, write the complete truth table and make grouping explicit.
Original Boolean example; do not substitute it for validated safety logic.
What is happening?
Languages define operator precedence, but readers may not remember it correctly. Parentheses express the intended grouping. The application requirement must decide which conditions apply to every alternative and which apply only to one branch.
Check these five things
-
Rewrite the requirement in plain language.
-
Identify conditions common to every permitted path.
-
Read the operator precedence for the actual language.
-
Add explicit grouping in a reviewed change.
-
Test all input combinations in simulation.
Worked example
Compare A OR (B AND C) with (A OR B) AND C. When A is true and C is false, the first can be true while the second is false. If C is required for every permitted path, the grouping matters even though both expressions contain the same variables.
Quick diagnostic reference
| A | B | C | Expressions differ? |
|---|---|---|---|
| True | False | False | Yes |
| False | True | True | No |
The mistake to avoid
A successful test of the common operating combination does not cover the combination that exposes the mistake. Exhaustive small truth tables are often more useful than long normal-cycle runs.
How to verify the fix
Record expected and actual outputs for every Boolean combination. Confirm the implementation reflects the approved functional requirement before release.
Field-work boundary: These are educational diagnostic guides. Use the exact equipment manuals and approved site procedures. Electrical testing and machinery changes belong to qualified, authorized personnel; control hazardous energy and validate affected functions before release.
Technical reference
Schneider Electric: Structured Text code elements. The examples and diagnostic tables above are original teaching material; they do not replace the product manual.
