In this article, we introduce Finite State Machines (FSMs), State Charts, and Conditional Logic, and how they can be used to develop automation software.
Vitesse Automation is developing a Generative AI solution to democratize the use of state machines, so that automation engineers no longer have to choose between agility and reliability.
State charts or FSMs model system behavior as a series of defined states with transitions triggered by conditions or events (e.g. "In State A, if event B occurs, transition to State C"). FSMs provide structure, making complex processes easier to visualize, debug, and scale, especially when managing sequential or hierarchical behaviors.
Conditional logic is a set of rules where actions depend directly on specific conditions ("If sensor A is triggered, then do X"). It’s straightforward but can become complex and hard to manage as systems grow.
Manufacturing automation organizations have been the theater of fierce debates around using state machines or conditional logic to program industrial robots and programmable logic controllers (PLCs).
Whether FSMs are easier or faster to program than conditional logic depends on the complexity and nature of the automation process, the goals, and the resources available to develop the programs.
Each approach has its advantages and tradeoffs, but FSMs often provide greater clarity and long-term maintainability for complex systems.
A finite state machine is a model used to control systems by defining a set of strictly defined states and rules for switching between them.
Think of it like a flowchart: each state represents a condition or mode (like "Idle," "Running", “Homed” …), and transitions define when and how the system moves to another state (such as "Button pressed", “Part placed”, etc.)
FSMs are useful for systems that follow predictable sequences, such as traffic lights, vending machines, and of course manufacturing equipment.
By breaking complex behaviors into manageable states, FSMs make processes easier to design, understand, and troubleshoot.
They’re like a roadmap for system behavior!
It’s important to note that when we refer to state machines, it’s likely state charts that we talk about. However, the automation controls engineering jargon almost always refers to "state machines" even where the specifications and use cases clearly point to state charts.
State charts, a powerful extension of finite state machines, were introduced by David Harel in the 1980s. His seminal paper, "Statecharts: A Visual Formalism for Complex Systems" (1987), significantly advanced the modeling of complex, real-world systems by addressing the limitations of traditional FSMs.
Harel's state charts became foundational in software engineering (UML State Diagrams) and embedded systems, particularly in avionics, automotive, and robotics. User interface and user experience (UI/UX) development also took great advantage of state charts, and finally, in the field of industrial automation, state charts are extensively applied in PLC programming and control systems.
State charts addressed the complexity of real-world systems where traditional FSMs struggled, making Harel’s work a landmark in system modeling and design.
Avionics and industrial automation were the first industries to gain a great advantage when state charts were adopted and shortly followed by other industries, including video games.
David Harel’s work was foundational in the development of the SCXML standard, 20 years later.
As state machines and state charts evolved, the industry was looking for a way to standardize state chart diagrams. With the globalization of the Internet and markup languages, XML was a viable option as the standard support for such format, which led to the specification of SCXML: State Chart eXtensible Markup Language.
So, SCXML is an XML-based language that provides a generic state-machine-based execution environment based on Harel state charts.
SCXML is able to describe complex finite state machines. For example, it is possible to describe notations such as sub-states, parallel states, synchronization, or concurrency, in SCXML.
To know more about SCXML, you can check the W3C page on SCXML, published in September 2015.
Because it is the most recognized and trusted standard to describe state charts and state machines, Vitesse Automation relies on SCXML to develop and manipulate automation processes.
Finite state machines and state charts are commonly used in programming PLCs. FSMs provide a structured way to model the behavior of systems by defining a set of states and transitions between them, which aligns well with the sequential and deterministic nature of many PLC-controlled processes.
It is true that to develop and tune an FSM (or state chart) typically requires more work than it takes to implement a similar system using conditional logic.
Therefore, it is common to find partially implemented FSMs, particularly for some transient states: Typically, the “Home” state cannot be automatically reached from all other states, because a universal “Homing” transition requires a significant effort to be programed on a complex machine.
As agility is becoming a priority in the world of automation, developers tend to abandon state machines and to develop more conditional logic “on the fly”, leveraging iterations to develop reuseable software components.
In most cases, they don't realize they end-up hardcoding a state machine!
While the value of rapid iterations and agile development using conditional logic is clear, the downside is the complexity of maintaining and developing these systems.
FSMs are generally better for optimizing equipment with parallel tasks when coordination, maintainability, and error handling are critical – key requirements in the field of manufacturing and operations automation.
Even if parallelism becomes a key challenge, state charts or frameworks that support concurrent state management and nesting of states greatly improve modularity and scalability.
As task dependencies grow, conditional logic can become difficult to manage, debug, and scale while FSM and particularly state charts will handle these cases particularly well.
Imagine a world where state machines would be as easy (and even easier) to develop as conditional logic. We would get all the benefits of using FSM and state charts, with the better visibility and maintainability they offer, but without the heavy upfront investment required to develop them.
Generative AI can greatly assist in the development of FSMs, quickly turning process requirements into FSM code or diagrams. It will dramatically reduce errors as the AI validation minimizes logical errors in transitions or state definitions.
Using standard state charts definition such as SCXML, a generative AI assisted tool handles large, complex FSMs more efficiently than using manual methods.
Finally, natural language descriptions reduce the need for expertise in FSM design, democratizing the creation of FSMs and empowering process and manufacturing engineers to develop FSMs.
Using Generative AI to assist in the development of FSMs brings unfair advantages such as speed, error reduction, scalability and ease of use.
The Vitesse AI Wizard, set for release in Q3 2025, takes this a step further as a groundbreaking Generative AI assistant for creating and refining SCXML-compliant state charts.
By combining user prompts and documentation, it allows seamless interaction to develop, iterate, and validate FSMs for diverse equipment and processes.
Beyond design, Vitesse integrates these state charts with production equipment via the Vitesse platform and uniquely generates PLC code for states requiring direct PLC execution.
This end-to-end capability streamlines automation, bridging design, execution, and control in one tool.
Using an interactive prompt in natural language, the AI Wizard lets user refine the FSMs to fine tune the behavior based on their requirements. For instance, here the user wants to introduce more specific error handling, with dedicated states based on the nature of the error:
The resulting state chart can be executed by Vitesse in either simulation mode or using Vitesse connectors to run the state machine against a digital twin and/or the physical equipment.
It can also be exported as a standard SCXML file, and soon Vitesse will generate the PLC code for all or parts of the state machines.
Automation controls experts will appreciate that the AI wizard can also be used while editing the SCXML file, for instance this is the same error handling with the states generated based on above user’s requests:
To use state machines, and more particularly state charts, for the controls of processes and equipment is the best practice to adopt.
Automation controls and process engineers can now develop or fine tune state machines to accelerate the bringing up and recommissioning of industrial equipment and processes.
A great advantage of using generative AI driven solutions like Vitesse, is a platform-agnostic environment allowing for the programming of robots and PLCs independently of the hardware platforms, protocols and brands.
Contact us for more information about the Vitesse platform and the AI Wizard.
Our specialists will be happy to help!