AutoPLC:为可编程逻辑控制器生成供应商感知的结构化文本
AutoPLC: Generating Vendor-Aware Structured Text for Programmable Logic Controllers
AI总结:
AutoPLC是一个自动从自然语言生成供应商感知的PLC结构化文本代码的框架,通过四阶段生成过程在914任务基准上实现90%以上编译成功率,成本低至每任务0.13美元。
摘要:
在可编程逻辑控制器(PLC)的编程语言中,结构化文本(ST)因其表达能力和灵活性而被广泛应用于工业自动化。然而,主要供应商以专有扩展和硬件特定库来实现ST——西门子的SCL和CODESYS的ST在语法和功能上各有不同。这种碎片化迫使工程师跨平台重新学习实现细节,造成巨大的生产力障碍。为应对这一挑战,我们开发了AutoPLC,一个能够直接从自然语言需求自动生成供应商感知的ST代码的框架。我们的解决方案首先构建两个针对各供应商规格定制的关键知识源:一个包含平台专属函数的结构化API库,以及一个记录真实世界实现经验的带注释案例数据库。在这些基础上,我们创建了一个四阶段生成过程,结合了逐步规划(通过轻量级自然语言状态机支持控制逻辑)、使用基于LLM的重排序的上下文案例检索、由工业数据指导的API推荐,以及通过与供应商IDE直接交互的动态验证。AutoPLC已为西门子TIA Portal和CODESYS平台实现,在我们的914任务基准(涵盖通用和过程控制功能)上实现了90%以上的编译成功率,优于所有选定的基线,平均每个任务成本仅为0.13美元。经验丰富的PLC工程师对生成代码的实际效用给予了积极评价,包括编译失败的案例。我们在https://github.com/cangkui/AutoPLC开源了我们的框架。
英文摘要:
Among the programming languages for Programmable Logic Controllers (PLCs), Structured Text (ST) is widely adopted for industrial automation due to its expressiveness and flexibility. However, major vendors implement ST with proprietary extensions and hardware-specific libraries - Siemens' SCL and CODESYS' ST each differ in syntax and functionality. This fragmentation forces engineers to relearn implementation details across platforms, creating substantial productivity barriers. To address this challenge, we developed AutoPLC, a framework capable of automatically generating vendor-aware ST code directly from natural language requirements. Our solution begins by building two essential knowledge sources tailored to each vendor's specifications: a structured API library containing platform-exclusive functions, and an annotated case database that captures real-world implementation experience. Building on these foundations, we created a four-stage generation process that combines step-wise planning (enhanced with a lightweight natural language state machine support for control logic), contextual case retrieval using LLM-based reranking, API recommendation guided by industrial data, and dynamic validation through direct interaction with vendor IDEs. Implemented for Siemens TIA Portal and the CODESYS platform, AutoPLC achieves 90%+ compilation success on our 914-task benchmark (covering general-purpose and process control functions), outperforming all selected baselines, at an average cost of only $0.13 per task. Experienced PLC engineers positively assessed the practical utility of the generated code, including cases that failed compilation. We open-source our framework at https://github.com/cangkui/AutoPLC.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。