Skip to content

AI for PLC

AI for PLC Programming

The guide for automation engineers: what an AI agent really delivers when programming a PLC, which tools exist, and how generated code reaches the controller verified.

TIA Portal V15-V21 · CODESYS 3.5 · ST/SCL · local or cloud

How AI code gets into the PLC safely

  1. Give context

    The AI has to know the project: tag names, data types, existing blocks, your house standard. Without context it invents symbols.

  2. Review the proposal

    Generated code is a proposal. You read the diff, adjust and confirm. Nothing enters the controller silently.

  3. Prove it

    Import over the official API, compile against the real project, unit tests on PLCSIM Advanced or the real PLC.

Contents

AI for PLC programming in 2026 means one concrete thing: a large language model (LLM) reads, writes, converts and explains controller code, above all Structured Text under IEC 61131-3 (ST, called SCL at Siemens), and a tool around the model makes sure the code fits the project and reaches the controller verified. The tools range from a chatbot in the browser, through vendor assistants such as Siemens Industrial Copilot, to integrated engineering IDEs such as AnyAutomation Studio that know the TIA Portal or CODESYS project. This guide shows what AI delivers when programming a PLC today, where it fails, how to recognise a usable tool, and what the path from prompt to controller looks like. The tools themselves are lined up in the comparison of AI tools for PLC programming.

What AI can do in PLC programming today

Five tasks where AI saves real time, in the order most teams adopt them:

  1. Understand and document. The AI reads an unfamiliar block (SCL, STL or a text form of the graphical languages), explains the logic, names states and interlocks, and writes the documentation. For existing plants this is the most common and lowest-risk entry point.
  2. Generate. A description ("FB for a conveyor with start/stop, seal-in and an overload interlock") becomes a block in ST/SCL. The result is usable when the AI knows the real tag names and data types of the project. How that works in TIA Portal is on Generate SCL with AI.
  3. Convert. Move STL legacy code to SCL, rebuild ladder logic as ST, migrate blocks between naming conventions. Pattern work where AI is fast and reliable.
  4. Refactor. Replace magic numbers with constants, clean up interfaces, bring comments up to date, structure a state machine properly.
  5. Test and troubleshoot. The AI writes unit tests for the block, explains a compile error, or finds the cause of a behaviour when it can see live values or a trace.

What is missing from this list is missing on purpose: safety functions (F-logic), hardware configuration without review, and anything that depends on assumptions about cycle time and peripherals. More on that below.

Legacy PLC code: explain, comment, migrate (STL to SCL)

Most plants run on code nobody in today's team wrote. That is where AI saves the most time at the lowest risk, because the first step only reads. Three stages have proven themselves:

  • Explain. The AI reads the block and describes in plain language what it does: states, interlocks, timers, interfaces to other blocks. An unfamiliar project becomes readable in hours instead of weeks, for new team members too.
  • Comment and document. The explanation turns into comments in the code and documentation that stays with the project. You review and adopt it like any other change, through a diff.
  • Migrate. STL blocks move to SCL with comments and interface preserved. A compile against the real project and a unit test that compares old and new behaviour show whether the conversion is right.

The order matters: understand first, change second. A migration never replaces the acceptance test on the plant. In AnyAutomation Studio the assistant reads STL, SCL and graphical blocks straight from the TIA project; what that looks like in detail is on TIA Portal AI.

Structured Text first: which languages AI handles

Language models are text models. That is why AI for PLC programming works best with Structured Text (ST), called SCL at Siemens and ST under IEC 61131-3 at CODESYS and most other vendors. A model can also read STL, which makes it a good source for a conversion to SCL. For ladder (LAD) and FBD the AI needs a text representation: in TIA Portal that is SimaticML XML or, from V20, the textual S7DCL source; in CODESYS it is PLCopenXML. A tool that translates those formats makes graphical blocks readable for the AI and, with care, editable. AnyAutomation Studio edits LAD, FBD and GRAPH blocks as S7DCL source in the editor from TIA Portal V20 on.

Which AI tools exist for PLC programming?

Four categories that differ in context, data flow and pricing:

  • Vendor assistants. Siemens Industrial Copilot and the agentic Eigen Engineering Agent for TIA Portal; TwinCAT Chat at Beckhoff; the FactoryTalk Design Studio Copilot at Rockwell; AI-supported engineering plus an MCP server at CODESYS; the PLC Code Generation Copilot at Schneider Electric. Deeply integrated, but tied to the vendor, the model and usually a cloud.
  • Independent engineering IDE. AnyAutomation Studio, the IDE for TIA Portal V15-V21 and CODESYS with a free choice of model.
  • General chatbots and coding agents. ChatGPT, Claude or Gemini in the browser, or Claude Code and Cursor with a community MCP server. Free choice of model, but no project context, or a connection you build yourself. For Claude Code and other MCP clients there is also the ready-made AnyAutomation MCP server for TIA Portal.
  • Open source and research. MCP servers for TIA Openness on GitHub, prototypes such as LLM4PLC, Agents4PLC and AutoPLC, the Fraunhofer ChatPLC project. Good for understanding the technique, not meant for production.

The tools of all four categories are lined up with environment, model choice, local option, path into the project, testing and pricing in the comparison of AI tools for PLC programming.

From assistant to agent: what a PLC AI agent does

An AI assistant answers in a chat window. An AI agent for PLC programming works with tools: it reads the project itself, writes the block, imports it after your confirmation, compiles, runs the unit tests and reads the result, and it keeps going until the task is done or it needs your decision. That is what people mean in 2026 when they look for a copilot for PLC programming or a PLC AI agent. The deciding question is not the model but the tools the agent can use and the gates in front of every change: a diff before the import, a confirmation before every write, a compile and a test behind it.

Chatbot or integrated assistant: the difference is context

A chatbot in the browser does not know your project. It invents symbol names, guesses data types, and knows neither your house standard nor the blocks that already exist. The code looks plausible and does not compile, or worse: it compiles and still does not fit the plant. An integrated assistant reads the project before it writes: tag tables, data types, existing blocks, in TIA Portal over the official Openness API. The result fits on the first try far more often, and the import stays reproducible because it runs over the same API instead of copy and paste. What ChatGPT delivers without that context, and where it fails, is in the post ChatGPT for TIA Portal.

The proposal arrives as a diff: every changed line is visible before anything reaches the project.

Cloud or local: may PLC code go to an LLM?

In many companies this question decides the whole deployment. Three answers are possible. Cloud under your own contract: you use Claude, GPT or Gemini with your own API key, or an enterprise offering such as Azure OpenAI, Vertex AI or AWS Bedrock; the data goes to the provider under your terms, not through a third-party server. Vendor cloud: with Industrial Copilot or the Eigen Engineering Agent the requests run over Siemens infrastructure. Local: a model via Ollama, LM Studio, vLLM or SGLang on your own hardware; inference never leaves the machine. For confidential plants, know-how-protected blocks and regulated industries the local option is often the only one that passes approval. AnyAutomation Studio supports all three paths and routes no request through a server of its own; details on AI for TIA Portal.

AI on the running PLC: OPC UA

Programming does not end at the compile. On the running controller the agent in AnyAutomation Studio operates the built-in OPC UA client: it builds watch tables, observes variables, records a sequence over several PLC cycles as a trace or with the CSV Data Logger and reads the trace samples to point to the cycle where a fault starts. Reading and observing run directly, writes run after you confirm. The client works with OPC UA servers in general and has been tested with Siemens S7-1500 and CODESYS controllers.

Limits: what AI must not do

An LLM does not replace a PLC programmer, and generated code does not belong on a plant unreviewed. Four limits apply regardless of tool:

  • Hallucinated system blocks. Language models occasionally invent calls or parameters that do not exist. A compile against the real project catches that; a chat window does not.
  • Timing and hardware. Assumptions about cycle time, peripherals, interrupt OBs or communication behaviour are yours to verify, not the model's to guess.
  • Safety-related logic. F-logic stays manual work with acceptance testing. Generate, yes, but only standard logic.
  • Responsibility. A human signs off. That is why a diff belongs before every import, and a test behind it.

Whoever uses AI for PLC programming seriously treats it like a fast junior: lots of output, always reviewed.

The workflow in AnyAutomation Studio

In AnyAutomation Studio the path from prompt to controller has three stages. First you describe the task in the chat; the assistant reads tags, data types and blocks of the TIA project over Openness (V15 through V21) or of the CODESYS project. Second it produces the block as a diff preview; you read, adjust, confirm. Third the code enters the project over the Openness API, is compiled, and is verified with SCL unit tests against PLCSIM Advanced or the real S7 PLC. You pick the model per task: Claude, GPT, Gemini, 20+ cloud providers or a local model. On top come Git, CI/CD, EPLAN import and the Forge block library that feeds the agent with your house standards. How the assistant works agentically beyond that is on the TIA Portal AI page.

Which PLC platforms the agent works with

  • Siemens TIA Portal V15-V21, over the official Openness API: SCL, STL and the graphical languages as text sources, unit tests on PLCSIM Advanced or a real S7.
  • CODESYS 3.5: Structured Text in the project tree and editor, PLCopenXML export and import, unit tests on CODESYS Control Win. More on AI for CODESYS.
  • OMRON Sysmac Studio: for NJ, NX and NY controllers, Structured Text and ladder as files for the Sysmac Studio import. More on the page AI for OMRON Sysmac Studio.
  • Controllers with an OPC UA server: live values, watch tables and Data Logger through the OPC UA client (tested with S7-1500 and CODESYS; trace tested on S7-1500).

Frequently asked questions

Can AI program a PLC?

Yes, for standard logic in Structured Text (ST/SCL): generating, converting, refactoring, documenting and testing blocks. Not on its own and not unreviewed: the AI delivers proposals, a human reviews the diff, and the compile plus a unit test deliver the proof. Safety functions stay manual work.

What is an AI agent for PLC programming?

An AI model that works with tools instead of only answering: it reads the PLC project, writes and imports code after your confirmation, compiles, runs unit tests and observes the running controller. In AnyAutomation Studio the agent works in TIA Portal and CODESYS projects with the model of your choice, and by default every change passes a diff or a confirmation first.

Does it work with my controller?

With Siemens S7-1200 and S7-1500 through TIA Portal V15-V21, with CODESYS 3.5 controllers, and over OPC UA with controllers that run a standard OPC UA server (tested with S7-1500 and CODESYS). With OMRON NJ, NX and NY controllers through Sysmac Studio projects.

Can the AI agent read live values from the PLC?

Yes, over OPC UA, from the Pro+ plan. The agent builds watch tables, records a sequence and works through the trace samples to find faults across PLC cycles; writes run after your confirmation. Details on the page OPC UA client with AI.

Which AI tools exist for PLC programming?

Vendor assistants (Siemens Industrial Copilot and Eigen Engineering Agent, Beckhoff TwinCAT Chat, Rockwell FactoryTalk Design Studio Copilot, CODESYS AI engineering, Schneider PLC Code Generation Copilot), the independent engineering IDE AnyAutomation Studio, general chatbots and coding agents (ChatGPT, Claude, Gemini, Claude Code with an MCP server) and open-source and research projects. The comparison with a table is on the page Best AI for PLC programming.

Which AI is best for SCL in TIA Portal?

A strong reasoning model such as Claude, GPT or Gemini in its large variant for complex blocks, a fast coder model for completion while typing, a local model via Ollama for confidential projects. More important than the model is project context: the same AI writes far better SCL with access to tags and data types than without.

Can ChatGPT write PLC code?

ChatGPT explains SCL well and drafts usable scaffolds, but it does not know your project. Symbol names and data types are guessed, and the import is copy and paste. That works as a learning aid and for small blocks; project work needs an assistant with project context and an import over the Openness API. What a browser chat can do and where it breaks is in ChatGPT for PLC programming.

Will AI replace PLC programmers?

No. It shifts the work: less typing of boilerplate and state machines, more specifying, reviewing and testing. Plant knowledge, safety assessment and the responsibility for sign-off stay with people.

Is AI-generated PLC code safe?

As safe as the process that brings it into the project. Without gates it is a risk. With a diff review, an import over the official API, a compile against the real project and unit tests on PLCSIM Advanced or the real PLC it is as safe as hand-written code with a review. Safety-related logic (F-logic) is not generated.

May I send PLC code to a cloud LLM?

Your approval process decides. Three paths: cloud under your own contract with the provider (including Azure OpenAI, Vertex AI, AWS Bedrock), a vendor cloud as with Siemens, or fully local via Ollama, LM Studio, vLLM or SGLang. AnyAutomation Studio supports all three and routes no request through a server of its own.

Is there AI for CODESYS?

Yes, the overview is on the page AI for CODESYS. CODESYS itself offers AI-supported engineering and an MCP server for external AI clients. AnyAutomation Studio opens CODESYS 3.5 projects, shows the objects as a tree, edits Structured Text and saves it back, compiles the project, creates and organizes objects, compares the project with an export folder, and exports and imports PLCopenXML; the AI chat works with that context and can change and compile the code itself after your confirmation.

Which AI migrates STL to SCL?

Any strong language model reads STL and converts to SCL. The difference is the tool: an integrated assistant reads the STL block straight from the project, keeps comments and interface, and the Openness import plus compile shows immediately whether the conversion is right. In AnyAutomation Studio that is one prompt: "Convert FC_LegacyPlant from STL to SCL and keep the comments."

Does AI work with ladder and FBD too?

Through a text representation, yes. In TIA Portal that is SimaticML XML or, from V20, the S7DCL source; in CODESYS it is PLCopenXML. AnyAutomation Studio edits LAD, FBD and GRAPH blocks as S7DCL source from TIA Portal V20 on. AI works best in Structured Text (ST/SCL), though.

What does AI for PLC programming cost?

Vendor assistants are subscriptions on the vendors' marketplaces, browser chatbots start at a free tier. In AnyAutomation Studio the AI chat is included from the Basic plan (CHF 10 per month or CHF 110 per year); add your own API key with the model provider, or a local model with no key. Try free for 30 days.

How do I get started with AI in PLC programming?

With the lowest-risk step: have an existing block explained and documented. Then generate a small standard block, read the diff, import, compile, test. Only when that loop runs smoothly, take on larger tasks. A tool with project context, diff preview and test integration gives you the guardrails; the workflow is on Generate SCL with AI.

Try it now

Use AI in your PLC project

Try AnyAutomation Studio free for 30 days, no credit card. For TIA Portal V15-V21 and CODESYS 3.5.

Free account required: sign in with your email address and a code, then the download starts.

Questions? support@anyautomation.ch