r/PLC • • 2d ago

PLC Question AI agents for PLC programming

Is anyone using an AI agent for PLC programming? If so what has your experience been and where do you see it going?

0 Upvotes

58 comments sorted by

10

u/SensiSharp 2d ago

Yes, I use it for a final project audit or at specific points if needed, to review the entire program and spot consistency issues or careless mistakes, which I then fix. Tested across 3 or 4 PLC ranges, it works. 

25

u/theaveragemillenial 2d ago

No, helps with documentation though.

7

u/tokke 2d ago

I can't get it to produce good, readable logic. Ladder is just something claude has trouble with. Structured text is easy.

But we've build offline tools with claude that we didn't know we needed. IO, modbus, compare (this one is a beast, works a million times better than the original rockwell compare tool), ...

But I guess in 1-3 years we are building projects with library/tool assisted AI

2

u/Weak-Chemist-2054 2d ago edited 2d ago

It comically struggles with FBD too.

6

u/tokke 2d ago

With rockwell I provide it L5X exports. A single routine is doable. But when there's data manipulation and subroutines being called or AOI's... it gets lost and starts hallucinating. But compared to even 6months ago it's insane what it can do.

People being against AI... keep living in your bubble. But I will be figuring out how to use it, build tools and libraries. Our sector has been in a standstill for the past 40 years. We all have to use expensive closed source software. There's no real CI/CD and version control (thank you copia for being the best out there).
Progress is happening really fast outside our OT-world, and we are going to lose the race (we did already some decades ago). And I don't want to hear the bullshit copium that a PLC is so much better than whatever the IT-world has as solutions... I haven't seen PLC's being used int surgery rooms, or banking, or in your car, ...

→ More replies (3)

2

u/danielv123 2d ago

I don't know. I use it for FBD with Siemens, and it's not having any problems at all. I do have some basic prompting regarding style guides but it's not all that complicated. What struggles are you having with FBD?

26

u/green_gold_purple 2d ago

No. You need to understand every case and condition. It needs to be strictly deterministic. It's not appropriate.

3

u/durallymax 1d ago

Who needs to understand every case and condition? It catches edge cases we never considered.

With proper libraries and defined skills, the codegen is very deterministic.

→ More replies (6)

4

u/Itchy_Charity_6924 2d ago

Works great for me on studio 5000.

20

u/swisstraeng 2d ago

Fuck no. Not even to write documentation because I actually care for the guy who will read it.

3

u/cakes365 2d ago

I’ve used it for some small scl routines.  It’s came a long way in 6 months. When I first tried it was all over the place and took a lot to make it work. Had to update data types and use the correct syntax.  But now just a short prompt and it spits out a source file that works. 

3

u/CapinWinky 1d ago

We have attempted this using a few different methods and have had mixed results.

  • It is doable now to have AI create a first crack outline that can then be heavily modified by a human to get a good result faster than the overwhelming possibility of a blank slate.

    • We have to give it example programs and spend a few hours with it.

    • The smaller the scope the better

  • AI is a great rubber duck to bounce problems off of, it often has real solutions to offer. Just give it the whole project and tell it what you're seeing.

  • AI is way better at finding, and understanding documentation that google search.

3

u/durallymax 1d ago

Yes but you will get a lot of response from people that simply copy/paste into their chatbot of choice and receive subpar results.

Good results come from using something like an MCP to have full program context and tooling available, and a host of refined skill files and code repos to use to ensure you get repeatable quality results.

We've deployed numerous projects this year that were 100% AI coded from the PLC logic to the HMIs, simulations, FAT and SAT checkouts as well as the final operators manuals (which were often cost/time prohibitive in the past, but now take minutes).

→ More replies (1)

5

u/AlternativeContent72 2d ago

May be viable for structured text. I've done some stuff reading/parsing basic ladder programs. I wouldnt trust the programs without thorough testing/qualification.

10

u/landsharkuk_ 2d ago

In the last 6 months the models have gotten very good at writing PLC code.

I am now at the stage where Claude and Gemini are producing perfect Siemens SCL code that passes rigorous testing and getting deployed on real systems.

Manually writing code for PLCs is a dying skill.

5

u/Weak-Chemist-2054 2d ago

Yeah, buts that’s SCL…

→ More replies (11)

3

u/Z-Kneusje 2d ago

Same i’m also in this stage not only with siemens but i managed to do this fully with different brands. Full hmi design and code using old projects as reference standard. Building extra tests to simulate catches alot. Still have to commision but that was before also. Started up few full packaging lines already this method.

2

u/Strict-Midnight-8576 2d ago

I am happy that people have written somewhat thoughtful answers here, very interesting, thank you guys

2

u/sswebz 1d ago

writes great CLICK plc ladder code via clicknick & the pyrung engine (shameless plug). I see it only increasing - but it has to have the proper framework and the ability to WRITE tests that run against real simulation of the ladder.

Now we only need a text-based HMI software to match up!

2

u/durallymax 1d ago

If you're using AD, it can write C-More HMI screens just fine. Export the screen to the screen library, let AI do its work on it, then re-import the screen. It can likely do the entire project file. I gave it to it once on an old project to find a rogue variable and it found it. May be able to just generate the entire project with enough back and forth.

→ More replies (2)
→ More replies (1)

4

u/nuck1014 2d ago

Recently got into using Claude code with tiaopenness. Obviously not touching any safety stuff but it does a really good job at automating HMI work. I've used it for generating specific SCL functions before and it does a pretty good job of that too. Where I see this going is pretty far tbh, the models are good now and only going to get better.

3

u/Supreme_Schnitzel 2d ago

Nice!

I want to try the same thing. May you describe how you did it? Like downloading Claude and using that TIA openness dll or how do you connect Claude?

4

u/nuck1014 2d ago

Download Claude code and do the terminal install, open the project folder in the terminal and tell it to generate what you want and use tiaopenness

→ More replies (1)

4

u/Infinite_Living_2980 2d ago

Yes, through TIA openness.
It’s insane how good ai has gotten in the past year.
Wonder what our job will look like in a couple of years.

1

u/ConsistentOriginal82 2d ago

It does not integrate directly into TIA portal so I used it to write routines for one of my FB's. It did okay, but so much prompting its really just not efficient

→ More replies (3)

1

u/5hall0p 1d ago

It's better at structured text that ladder. Search through this sub. One commenter was talking about saving his sample AB Studio 5000 program in XML format, feeding it and spreadsheet of points to be added to using the same code and getting good results.

0

u/Available-Distance81 1d ago

It depends, I've used AI to summarize uncommented code for me. as far as asking it to write code? AI doesn't follow KISS very well, it overcomplicates everything. But, despite what the boomers in this thread are saying it's probably close enough that it will be able to just write your code for you in a few years.

-1

u/Ok_Amphibian_3042 20h ago edited 20h ago

AI is getting really good at writing PLC code, both text based and also ladder (given the proper tools or skills). However one thing I see underlooked but that I also see discussed in regular computer software development circles is software legibility. In ladder especially, form absolutely is substance, and can improve legibility of a network dramatically (for quick troubleshooting, for handing it over to an inexperienced technician...). I think legibility is a fundamental aspect that should drive AI adoption in companies and govern how it is actually carried out. And at the moment, AI code works, is logically coherent but most of the times is very difficult to read. That being said, using AI to help you understand and troubleshoot existing code is fantastic and I think nobody should renounce on that regardless of their opinion on actually putting in production AI generated code.