Combinatorial and sequential logic in PLCs
Matteo Migliore

Matteo Migliore is an entrepreneur and software architect with over 25 years of experience developing .NET-based solutions and evolving enterprise-grade application architectures.

He has led enterprise projects, trained hundreds of developers, and helped companies of all sizes simplify complexity by turning software into profit for their business.

When I started working with PLCs, I immediately recognized one different form of architecture, no less sophisticated than that of enterprise software but optimized for completely different objectives.

There were no elegant classes, objects, or design patterns, just ladder diagrams that resembled schematics more than elegant code, and combinatorial logic with no room for interpretation.

It was a context in which software architecture it had to communicate directly with physics, and where my years of experience in systems design found a new application.

Designing software capable of managing industrial processes represented for me a natural evolution of my architectural skills, applying the same principles of modularity and composition to a context in which reliability is not an optional requirement but an absolute necessity.

I started studying how adapt consolidated patterns to this new scenario and I discovered that concepts such as state machine, observer and command found their most direct expression here.

I developed an approach in which each component respected solid design principles, but oriented towards ensuring deterministic control rather than abstract flexibility.

When the first system flawlessly integrated sequential and combinatorial logic, coordinating dozens of actuators with millisecond precision, I saw the architecture demonstrate its operational robustness.

I was applying design patterns to systems that produced concrete value, where every architectural choice directly affected operational performance.

Today, those approaching industrial automation find a mature and structured ecosystem: advanced IDEs, modular libraries, consolidated patterns and solid development methodologies.

This evolution makes it possible to bring architectural best practices into control systems, maintaining the extreme robustness that the industry requires.

Developing for automation means extend already acquired skills towards a field where precision and reliability are essential design parameters.

If you have experience in software architectures, you already have a huge competitive advantage.

The sector is looking for professionals capable of designing reliable and scalable systems, capable of applying principles of good design to the control of industrial processes critical for safety and operational continuity.

And if you want to see with your own eyes how every pattern you know can find its ideal implementation in industrial contexts, I can guide you on a path where design is not just theory but becomes control, safety and operational continuity.

What is combinatorial logic and where is it used in PLCs

Combinatorial logic in PLCs for industrial automatic controls.

Imagine a pressure sensor in an industrial boiler: when the pressure exceeds the critical threshold, the safety valve opens instantly.

It doesn't wait for confirmations, it doesn't consult databases, it doesn't check previous conditions: evaluates only the current data and reacts according to precise and immediate rules.

This is pure combinatorial logic: a mechanism that transforms present inputs into deterministic outputs, without memory of the past or worries about the future.

In a highway tunnel ventilation system, when sensors detect dangerous concentrations of carbon monoxide, the fans automatically turn on.

The decision does not depend on how many cars have passed before or on weather forecasts, but exclusively on the current values measured by the sensors.

In fire safety systems, combinatorial logic governs automatic shutdowns: high temperature AND presence of smoke AND lack of authorized personnel generate immediate activation.

Each condition is evaluated simultaneously and the result is always identical for the same input combination, guaranteeing absolute reliability.

In food packaging lines, combinatorial logic controls the metal detector: when it detects metallic contamination, it automatically ejects the product from the line.

The reaction occurs in milliseconds because any delay means contaminated product that could reach consumers with serious legal and health consequences.

In the pharmaceutical sector, automatic dosing systems use combinatorial logic to verify the weight, temperature and purity of the components before authorizing mixing.

Only when all parameters are within the specified ranges the process can proceed, otherwise the batch is automatically discarded to ensure regulatory compliance.

In automatic warehouse handling systems, combinatorial logic coordinates robotic pallet trucks: correct position AND safe load AND free path authorize the movement.

This decision architecture eliminates subjective interpretations and guarantees that every industrial action is based on measurable and instantly verifiable facts.

The strength of combinatorial logic in PLCs lies in its ability to transform the complexity of the physical world into simple, immediate and infallible rules.

The difference between combinatorial and sequential logic explained with examples

Combinatorial and sequential logic in PLC systems.

To understand the difference between these logics, distinguish i mechanisms that react instantly from those who advance step by step:

  • Combinatorial logic: evaluate reality at the precise moment it happens, without worrying about the past or the future that could occur.
    It's there immediate response of a system to a detected condition, such as a sensor that stops production as soon as it detects a critical anomaly.
    The smoke detector in the kitchen goes off and the alarm goes off immediately, without asking what I was doing because the current condition requires immediate reaction.
  • Sequential logic: builds the result step by step, where each phase is the indispensable foundation on which the next one rests.
    Order is not an option but an absolute necessity: changing the sequence compromises the final product, regardless of the perfection of the other steps.
    For a cake you preheat the oven, mix the ingredients, bake and wait: changing the order inevitably compromises the complete final result.
    In a pharmaceutical plant an incorrect sequence would force throw away lots of very high value or it would put customers' health at risk.

In the industrial world these logics live in a dynamic balance that decides the fate of each process, without one prevailing over the other.

It is not theoretical redundancy but survival guarantee for systems that cannot afford errors of any kind.

It is a pact between speed and rigor: the sequential advances only when the combinatorics confirm that the conditions are completely safe.

The experienced professional knows that mastering a single logic is like knowing half a language and pretend to write a novel.

In PLCs, time management is non-negotiable: every millisecond is calculated with atomic precision because minimal deviations cause defects.

This temporal precision synchronizes complex operations like an orchestra in perfect harmony, where combinatorics prepare the instruments and sequential directs the performance.

The absence of one of the two would leave room for dangerous improvisations or sudden blocks that would compromise the entire automation system.

In every serious project their integration is one structural necessity which transforms abstract rules into real, reliable and measurable industrial processes.

It is the invisible boundary that separates safe, continuous production from unstable production at risk of costly operational incidents, and this is where your experience becomes crucial.

Because we need professionals who recognize the architectural implications behind each logical condition and know how to design systems that perfectly integrate combinatorics and sequential.

People capable of bringing the same methodical attention to the industrial world that they put into their code, where every millisecond and every decision has measurable consequences.

If you want to transform your software expertise into a high-value industrial specialization, the PLC programming course guides you in the concrete application of this logic.

It's about using your skills where reliability is not an objective but the only possible path to operate safely.

Reflect on where you want to go in the next few years and involve those close to you: their support can make the difference in this professional transition.

If you decide to start, do it with full conviction because here there are no "let's see how it goes" approaches that really work in this world.

Time will pass anyway: the difference lies in what you have built and whether you want to find yourself with the same skills or with a background that opens up new possibilities.

The industrial sector seeks experienced developers to build solutions where every mistake has a real cost: the opportunities are there, the only variable is you.

How to implement combinatorial logic in ladder diagram

Simplicity and robustness of industrial Ladder Diagrams.

A Ladder Diagram looks like a artifact from the sixties: only lines and symbols, without objects or classes that show apparent graphic elegance.

Yet, that "primitive design" governs million-dollar production lines, power plants and plants that produce vital drugs such as insulin.

When a line stops at three in the morning, you don't want to decipher microservices but open the Ladder and understand in seconds where to intervene.

The Ladder is direct: it does not allow complexity to be hidden behind refined patterns, because every logic is exposed and immediately verifiable without ambiguity.

For those coming from traditional software this is a cultural revolution: no functions or objects, nowhere to disguise less elegant code.

Everything is visible and traceable.

This forced transparency becomes the foundation of reliability that other environments cannot guarantee.

Writing in Ladder means managing every condition immediately and well, without postponing it to a "next release" because every error has direct consequences.

In Ladder you don't write to amaze but to guarantee: not being able to hide the complexity you learn to eliminate it, not being able to abstract you learn to simplify.

The result is code that a technician can analyze with a flashlight and tester, without having to interpret hidden logic or complicated abstractions under pressure.

Modern ladders include visual debuggers that show the flow of power in real time, making the logic visible as the process happens.

It's like having a constant x-ray of the code, where every step can be observed and traced without having to imagine what's happening internally.

There are libraries with already tested and certified function blocks, designed for recurring operations with high industrial reliability requirements:

  • Motor control in high precision repetitive scenarios
  • PID regulation to maintain constant physical parameters
  • Management of communications between PLC, sensors, HMI and MES or SCADA systems

This approach avoids reinventing the wheel by using components with reliability proven in thousands of systems, reducing development times and risks.

After years of elegant but fragile code, discover a logic that always works without surprises It has a charm that cannot be forgotten.

In PLC programming course learn to think in Ladder, expertise that transforms every industrial project.

Once this change of mentality is consolidated, it is difficult to go back: it is like learning SQL instead of imperative loops, with the same clarity.

Use of memories and multiple conditions

Deterministic memory management in industrial PLC systems.

The memories in a PLC are enhanced global variables which here do not create chaos as in traditional software, because determinism makes them safe.

A PLC does not work in multithreading, therefore, there are no race conditions or asynchronous callbacks that change the state by surprise.

It scans the program from top to bottom, repeating the cycle every few milliseconds always in the same order without exceptions.

This one Rigidity is the key to its reliability: every action always behaves in the same way, without surprises or anomalous behavior.

In the PLC, memories are communication tools between parts of the system, where the modules coordinate operations and constantly pass information.

In a complex plant, dozens of PLCs work together: the one that controls the oven signals to the conveyor belt by writing to shared memory.

When a memory is written, the value is available already on the next scan cycle without random delays or uncertain callbacks.

Managing multiple conditions is like conducting an orchestra where each instrument must come in at the exact moment to avoid disharmony.

M1 indicates piece in position, M2 confirms correct temperature, M3 signals operator OK: only when all are true does the process start.

In reality these conditions can be hundreds, each with priorities and constraints to respect while the line produces thousands of pieces per hour.

In a fast system two incompatible actions cannot be activated together, under penalty of machine downtime with significant economic costs.

Memories are like the DNA of the system: if you organize them well at the beginning everything runs smoothly, if you make mistakes you will spend years correcting them.

I define expressive naming schemes with prefixes by area and suffixes by function, so operators immediately recognize the purpose and priority of the variables.

I introduce controlled resets: critical memories cleared only in safe states, the diagnostic ones preserve the history for root cause analysis.

Each multiple condition is tested with truth matrices and simulations with increasing load, verifying logical correctness and temporal stability.

I document decision-making paths by connecting memories, sensors and actuators with operational notes for autonomous corrections by the staff on duty.

I foresee graduated alarms and deterministic fallbacks: priority in case of conflict Freezes the process safely recording events for improvements.

It's like Tetris at maximum speed, but here making a mistake doesn't mean losing points but stopping production with considerable costs for the company.

Learning to use memories methodically is a key competence to design logic that is robust, understandable and maintainable even under pressure.

What is sequential logic and how does it represent work cycles

Robust state machines for critical industrial automation.

Sequential logic is where a developer brain finally feels at home, finding states, transitions and workflows with clarity linked to real processes.

In software, a problem is resolved with the restart of a service or a database rollback, while in a physical plant it causes immediate damage.

With real materials you can't press cancel: an out-of-time pour or dosage creates irreversible problems that require rapid and rigorous decisions.

Sequential logic in PLCs is the heart of the operation of a line, where each state represents a sensitive point and each transition conditions verified with surgical precision requires and each exit is a validated checkpoint.

On a bottling line the cycle seems linear, but full bottles or stopped machines require safe and traceable deviations.

When the capper stops or the labels end up with hundreds of pieces in the queue, the sequence must provide robust behavior without losing coherence.

For every possible anomaly the system must provide:

  • Safe and immediate fallback behavior
  • Error management that does not compromise the sequence
  • Possibility of controlled automatic or manual shooting
  • Detailed event recording for subsequent analyses

It's like writing code that he never encounters undefined behaviors, because in industry improvisation has unacceptable costs.

The real difficulty is not the stable state but the threshold between states, where errors find fertile ground and multiply their effects.

When moving from filling to capping, if an operator presses pause, the system must know how to stop and start again without problems.

Operational options are defined in advance for avoid ambiguous behavior:

  • Complete the phase already started even if a break is required
  • Immediately stop the current operation without completing it
  • Wait for a safe state before stopping completely
  • Mark the stopping point to allow controlled recovery

When the operator restarts, the system resumes from the agreed point maintaining temporal consistency and ensuring that instruments are in the right state.

In PLCs, each work cycle is a story repeated to perfection without improvisation, because the repeatability is the basis of reliability and compliance.

Time management includes mechanical inertia, valve opening delays and settling times which make the difference between theory and practice concrete.

The timings are carefully calibrated: two hundred milliseconds of advance or delay change alignments, pressures and synchronisms with measurable effects.

The collaboration between sequential and combinatorial logic creates a double checkwith immediate reactions and rigorous orders that reduce the room for error.

Your code decides whether a 50-ton press stops before crushing a worker's hand, whether a pump stops working when the pressure exceeds 8 bar, whether a conveyor belt slows down when it detects an abnormal weight.

Create step-by-step sequences with counters and flags

Persistent counters and flags for industrial PLC traceability.

In industrial systems the counters are not simple integers but persistent memory which resists blackouts, reboots and network interruptions without losing information.

When the power is removed with the value at 4732, when the power returns the system finds exactly the same number.

This reliability transforms the meter into historical archive of the plant which remembers cycles performed, process duration and alarm frequency for preventive maintenance interventions.

In a line that produces pacemakers, each piece requires rigorous traceability: losing the count means discarding the entire batch, compromising safety.

The meters record operational data that guide the crucial decisions on how to plan scheduled downtime, replace worn components and prevent quality drift.

Alongside the counters, flags come into play, which in common software are ephemeral Booleans while in PLCs they are messengers that pass through processes carrying instructions.

A flag communicates that a phase has closed correctly, authorizes the start of the next and turns on warning lights when an anomaly requires intervention.

In industrial control a flag represents the backbone which keeps sensors, actuators and operators aligned, avoiding operational gray areas.

Flags are the system's short-term memory and are used to:

  • Remember what happened in the previous cycle to maintain a clear operating context even after pauses or forced restarts
  • Anticipate what needs to happen next by indicating actions and prerequisites to downstream units without creating bottlenecks
  • Report conditions that trigger other parts of the process by enabling controls and interlocks for safe production continuity
  • Provide essential traces to reconstruct problems by creating audit trails for rapid root cause analysis

The real art is not to use counters and rain flags but to decide how many are necessary: too few reduce control, too many create unmanageable noise.

This work resembles designing application interfaces where you define useful endpoints and essential parameters by deriving superfluous data from present information.

In industrial control, however, you cannot add functions with simple requests: any variation requires plant shutdown, reprogramming and testing with significant costs.

In the PLC world, one rule wins: if you can't explain a flag in ten seconds you probably don't need it, and removing it simplifies everything.

Synchronization is the most delicate part: dozens of sequences must fit together without uncertainty, with robot A finishing before robot B begins.

When A suddenly blocks, B waits for a defined time and C avoids advancing thanks to status flags that prevent operational collisions.

Managing these dependencies means transforming the flags into a reliable choreography where each message invites the right component to enter at the right time.

The programmer counts variables and instructions, the professional directs the flow like an orchestra conductor, harmonizing digital signals and physical constraints.

The meters tell the story of the system with numbers that don't lie, the flags direct the plot by deciding when to open, close or suspend safely.

Without reliable counters the process memory breaks, without clear flags the synchronization breaks because the production does not forgive ambiguity, and it is precisely this concrete complexity that makes PLC programming fascinating.

Here you are no longer writing code for abstract functionality but controlling the real world, orchestrating sequences where every millisecond counts and every error has immediate consequences.

It's the kind of challenge we face in the PLC programming course, simulating industrial scenarios where every transition must be perfect.

PLC programming is a natural evolution that extends your existing skills towards industrial control, where errors corrected and systems maintained become a guarantee of reliability.

Companies are not looking for experimenters but for mature professionals who understand the responsibilities of industrial control where every decision has measurable consequences.

Learning on your own is possible but risky: here it is not enough to "do and see if it works" because every mistake can lead to production downtime with direct economic impacts.

A structured path gives you what self-learning cannot offer: method, operational safety, technical support and time saved.

The timing is perfect because the industrial sector is looking for people who combine software logic and understanding of industrial processes, a profile that companies struggle to find.

Historical programmers are leaving the scene and those with solid digital skills can fill a huge void with concrete opportunities.

If you have experience in APIs, databases and distributed systems you are already ahead: modern automation is looking figures capable of uniting IT and OT.

Management of conditional transitions and resets

Safe reset and checkpoint for responsible industrial automation.

The reset marks the boundary between those who write code and those who understand the responsibilities of industrial automation with all its implications.

In generic software it means starting from scratch, in automation it requires bringing every element back to safety without damaging machines or people.

A poorly managed procedure leaves a gas valve open, a robot in an unstable position or a cocked press turning trivial actions into serious accidents.

Similar episodes are not textbook theories but facts that end up in security reports and sometimes in newspaper reports.

The reset is not only reserved for emergencies but represents an integral part of daily management: end of shift, product changes, preventive maintenance interventions.

To deal with it correctly you need a form of constructive attention that anticipates every possible unexpected event before it manifests itself in real conditions.

Every ignored question like "what happens if the operator presses STOP during a job?" hides a potential risk ready to become an accident on the field.

In the design phase, the difference can be seen immediately: in systems that consider every reset scenario, unexpected events become controlled deviations, not emergencies.

The most important question is always the same: how would the code behave if human lives were at the center of the procedure?

Designing an intelligent reset means creating an orderly sequence where each step ensures that safety occurs before the definitive interruption.

Le dangerous parts are stopped immediately, the systems stop operations in the reverse order at startup and only after careful checks are the variables reset.

This approach is reminiscent of the mooring maneuver of a ship where it is not enough to turn off the engines but to consider inertia, currents and wind to avoid damage.

In many situations it is not necessary to return everything to the initial state but to correct an error and continue without starting from scratch completely.

This is why checkpoints are created, precise and safe points of the process where the status of each component is known, controlled and accurately documented.

These checkpoints work like savepoints in a video game, but here each shot in the loop affects machinery, materials and personnel safety.

Knowing that you can resume from a safe point allows you to reduce downtime, minimize risks and restore production flow without a complete reset.

When designed correctly, conditional transitions and resets are not just technical functions but guarantees of continuity, efficiency and protection of people.

Design the logic before writing the code

Preventive design for reliable PLC controls.

Designing logic before code means deciding how the system will react in each condition, long before touching an editor or loading projects into the PLC.

Design is not a theoretical step but the phase that determines whether a system will operate safely or become a continuous source of operational problems.

I map the actors of the process, their allowed states and allowed transitions, thus defining security invariants that can never be violated.

Explicit preconditions and postconditions for each phase including interlocks and confirmations, so no operation proceeds without them objective safety tests.

I foresee orderly, immediate shutdown paths and a controlled restart, clearly separating maintenance, manual and automatic to avoid dangerous gray areas.

The design includes a matrix of critical events with priorities, reactions and maximum intervention times so that the alarms become concrete operational triggers.

I document the conditions of stop, stop during transition and recovery after stop, specifying the exact point from which to start again without losing coherence.

I add minimum and maximum times to stay in the states to avoid oscillations between commands and confirmations which become unwanted vibrations in the field.

The logic is drawn on state diagrams and transition tables, then translated into readable sequences with clear names for memories and flags.

I prepare offline test with simulator, dry runs without product and controlled production tests, recording times and deviations to calibrate timers and thresholds.

Each choice has a written reason because, when the line stops at three in the morning, you need a reason that is as readable as an operating instruction.

The result is a more predictable system where the error does not become an accident but a contained deviation, with orderly recovery and controlled downtime.

Designing first saves time later: the code follows a clear design and discussions move to measurable facts, not personal interpretations.

The quality is born in the analysis phase and the PLC executes logic already designed for the real world with the precision it demands every day.

Practical example: automatic filling and unloading cycle

Automated control of tank cycles for industrial processes.

A ten thousand liter tank cycle seems to simply require fill, process, drain and repeat, but already in planning they emerge dozens of operating conditions.

Foam formation must be evaluated as a potential source of false levels that induce incorrect perception of vacuum when residual product is still present.

A scheduled delay after the low level signal with a second check should be provided to reduce waste and premature transitions to the next state.

Mechanical inertias such as non-instantaneous valve times, pump delays and sensor response must be integrated into the calculations because physics does not obey ideal logic.

The redundancy of level and weight measurements reduces the risk of calibration errors and drift by considering the influence of temperature, pressure and vibration.

The programmed restart points must allow consistent resumption after interruptions without forcing unnecessary resets with an HMI interface that guarantees complete visibility.

Here's how a well-designed loop should work:

  • Preliminary check: Is the tank really empty?
    Provide for redundancy and implement cross-checked with weight measurements because physics provides confirmations that electronics alone may not guarantee.
  • Controlled filling: don't just open the valve but monitor pressure and flow rate.
    An excessive flow generates harmful turbulence, while too little slows down the cycle with a direct economic impact.
  • Process control: verify level, temperature and real stability, avoiding the "more or less" which in chemical or pharmaceutical contexts compromises the quality of the batch.
  • Processing: it is the transformation phase where every parameter such as mixing, heating and reaction must remain within defined margins.
    Minimal deviations in time or temperature they alter the quality
  • Smart exhaust: manage foam formation, control downstream pressure and coordinate operational queues. If the next tank is not ready, define time limits and recirculation strategies
  • Final validation: confirm that the cycle is completed with parameters within limits providing clear decisions for anomalies such as scrap, rework or downgrading
  • Reset and preparation: reset variables and prepare the system for the next cycle by evaluating the need for washing or product changes with appropriate times and agents

The design integrates coordination logics between tanks to avoid bottlenecks and prepare safe alternative routes in the event of prolonged waits.

Only by considering all these aspects in advance the cycle works reliably even on first startup, avoiding relying on corrections during construction.

Learning to manage all this is not just a matter of logic but of vision, and this is where your professional experience becomes decisive.

It doesn't take a genius to program a PLC that "works" but it does take an expert professional to design cycles that hold up the shock of reality.

If you have seen in these details a challenge worthy of your level, perhaps it is time to go beyond curiosity and take concrete action.

Every aspect you ignore today becomes a problem tomorrow, and in industrial processes problems have real measurable costs that no company can afford.

The PLC programming course it is not designed for beginners but for those who have software experience and want to put it at the service of the industry.

For those who are not satisfied with seeing numbers on the screen and want to see their code move valves, coordinate processes and generate measurable impacts.

It's no longer a question of asking yourself if you are capable, but of evaluating what do you risk by staying still while the market is looking for exactly these skills.

With each passing month the gap between what you know and what the industry is looking for may widen, not just in technical terms.

Staying still has a price: the feeling that the work no longer evolves, that the days repeat themselves without onereal professional growth.

It is also the price of regrets, that annoying "who knows how it would have gone" that can accompany you for years without ever finding an answer.

Learning PLC programming is not easy but it is immensely rewarding.

When something moves because you programmed it, the satisfaction is deep and immediate, completely different from any traditional software project.

If you have experience in APIs, databases and distributed architectures you are already ahead: industrial automation is looking for hybrid figures that they talk to both engineers and IT teams.

It's a bridge between the world you know and the one that awaits you, where work produces tangible results.

If you've read this far you probably feel it's time to evolve: the real question isn't "can I do it?" but "how much would it cost me not to try?".

Leave your details in the form below

Matteo Migliore

Matteo Migliore is an entrepreneur and software architect with over 25 years of experience developing .NET-based solutions and evolving enterprise-grade application architectures.

Throughout his career, he has worked with organizations such as Cotonella, Il Sole 24 Ore, FIAT and NATO, leading teams in developing scalable platforms and modernizing complex legacy ecosystems.

He has trained hundreds of developers and supported companies of all sizes in turning software into a competitive advantage, reducing technical debt and achieving measurable business results.

Stai leggendo perché vuoi smettere di rattoppare software fragile.Scopri il metodo per progettare sistemi che reggono nel tempo.