agentleFS
SmailGSmailG/plc-programming/skills/convert/SKILL.md

convert

Skill0 starsChanged 37 days agoMITView on GitHub

Translate PLC logic between languages, dialects and exchange formats: IL→ST, LD↔ST, Siemens STL/AWL→SCL, SCL↔IEC ST↔TwinCAT/CODESYS/Machine Expert↔Logix ST, Control Expert (Unity) sections/DFBs↔Machine Expert, Rockwell RLL neutral text↔ST, 61131-3→61499, and into import files (PLCopen XML, SimaticML / SIMATIC SD / .scl sources, .TcPOU, L5X). Use when the user wants code ported, migrated, rewritten in another language or vendor, or packaged for import into another tool.

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Translate one POU at a time: Keep the original structure unless the user asks for a redesign, so that the port can be reviewed line by line.

    line 24

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Converting PLC logic

The rule: a conversion must preserve behaviour per scan, not just syntax. Timers, edges, execution order, retain and data types all hide semantics.

Procedure

  1. Identify the source dialect and version exactly. For example, S7-300 STL is not S7-1500 SCL, and Logix v35 mnemonics are not v36. Ask for the export if you only have screenshots.
  2. Inventory the semantics that do not carry over automatically (table below), and decide on each item with the user.
  3. Translate one POU at a time. Keep the original structure unless the user asks for a redesign, so that the port can be reviewed line by line.
  4. Package in the target format (see the platform skills and exchange-formats), then run python3 ${CLAUDE_PLUGIN_ROOT}/scripts/plc_validate.py.
  5. Deliver an equivalence test plan: identical stimuli on the old and new code with compared outputs, especially at timer edges, restart and fault paths.

Semantics that do not map 1:1

TopicWatch for
TimersIEC TON(IN, PT → Q, ET) with TIME. Siemens: multi-instance TON_TIME/IEC_TIMER, or a single-instance DB; legacy S5 timers S_ODT have different semantics. Logix: ladder TON(timer,pre,acc) with ms DINT; in ST, TONR on FBD_TIMER. Control Expert: TON EFB
EdgesR_TRIG instances vs Logix ONS/OSR (a storage bit per use) vs LD P/N contacts. One edge instance per signal and per use
Execution modelLD rung order and ST statement order are the same scan semantics. IEC 61499 is event-driven. Siemens OB priorities vs CODESYS task priorities
Local variablesSiemens #local, "global" and TEMP-before-write rules (non-optimized). CODESYS VAR_TEMP is re-initialised every call
Data typesSiemens S5TIME, DTL, Variant, DB_ANY. Logix DINT-centric, with no % addresses. Control Expert %MW located variables. Sizes: Siemens Char 8-bit / WChar 16-bit, String[n]
InstancesSiemens instance DBs vs FB instance variables. Logix AOI instance tags. The TwinCAT FB_init lifecycle
EnumsClassic S7 has no IEC enums (use constants). TwinCAT/CODESYS E.Member. IEC Ed.3 E#Member
Arithmeticoverflow behaviour, REAL→INT rounding (IEC: half-to-even; check the vendor), integer division
RetainSiemens retain per variable in optimized DBs. CODESYS RETAIN/PERSISTENT. Logix: every tag retains
IL / STL accumulator logicthe current result and status bits carry across lines. Siemens STL has status bits RLO, OS/OV, CC0/CC1, which is not IEC IL. Translate by data flow, not line by line
Graphical → textLD branches become OR, series becomes AND, coils become assignments. Keep one assignment per coil. S/R coils become explicit priority

Target-format notes

  • Siemens: author SCL as an external source (.scl, imported through "Generate blocks from source"), or, from TIA V20 Update 4 on, as SIMATIC SD (.s7dcl). Do not hand-write tokenised SCL SimaticML. Details are in the siemens skill.
  • TwinCAT: .TcPOU with ST only. Graphical languages go through PLCopenXML import.
  • CODESYS / Machine Expert / AC500: PLCopenXML (tc6_0200) or text pasted into the editor.
  • Logix: L5X component export with a Rung or Routine target. Use the v36+ mnemonics when targeting v36 or later.
  • Control Expert: XEF sections (.XST) are tool-generated. Prefer generating ST that the user pastes, unless you have a sample export of the same version to mirror.
  • IEC 61499: see the iec-61499 skill. Scan idioms become events.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.