TIATool

Guide · Updated

Can AI write SCL for S7-1500 safely?

Yes, inside a checked loop. The assistant writes SCL source, scl_lint checks it, and build_from_source previews the plan, then generates the blocks and compiles them in TIA Portal. Every write takes a new timestamped backup, the verify gate compares the result with your baseline, and a qualified engineer reviews and tests the code before it runs.

The loop, step by step

  1. Freeze the as-found state

    Create a workspace and set a baseline before the first change. The verify gate and every diff compare against it.

    Ask your assistant: Create a workspace for this project and set the current state as the baseline.

    Tools: workspace_init · baseline_set

  2. Write or generate the source

    The assistant writes FUNCTION_BLOCK, FUNCTION, DATA_BLOCK, TYPE and ORGANIZATION_BLOCK sources into a source folder, or generates them from the equipment model: 20 built-in templates, for S7-1500 by default or S7-1200, produce FBs, instance DBs, tag tables, alarms and docs that agree with each other.

    Tools: model_validate · model_generate

  3. Lint before TIA Portal sees it

    scl_lint checks the text offline in an instant: unbalanced IF, CASE, FOR, WHILE, REPEAT or REGION, a three-part VERSION (TIA Portal silently generates the block empty), a global constant as a CASE label, unquoted names with spaces, empty statements and undeclared #symbols. It is not a compiler; types and calls are checked by TIA Portal next.

    Tools: scl_lint

  4. Preview, then build and compile

    build_from_source with dry_run prints the full plan (SCL files and their block names, tag tables, hardware changes, deletions) in seconds and opens nothing. The real run takes a new timestamped backup, generates the blocks and compiles; compiler errors come back with block, line and network, matched against the knowledge base. For one source and one PLC, scl_apply lints, backs up, generates and compiles only that PLC in one call.

    Ask your assistant: Build the generated sources into the project, preview first.

    Tools: build_from_source · scl_apply · compile_project

  5. Verify against the baseline

    After a fresh export and scan, verify_change checks the blast radius against the declared targets, block attributes, interfaces (start value changes are warnings), the scan shape, and remanence and external access per member. The verdict is pass, fail or inconclusive; a check that cannot run is never a pass.

    Ask your assistant: Verify the change against the baseline: did anything change that I didn’t ask for?

    Tools: export_project · refresh_scan · verify_change

  6. Test, review, release

    Run input-to-output cases on S7-PLCSIM Advanced with plcsim_test, read the diff with project_diff, and let a qualified engineer review and release the code. If anything is wrong, restore_backup brings back the state before the write.

    Tools: plcsim_test · project_diff · restore_backup

Which check catches what

  • Lint

    Tool
    scl_lint
    Catches
    Unbalanced blocks, a three-part VERSION, global constants as CASE labels, undeclared #symbols, empty statements
  • Preview

    Tool
    build_from_source dry run
    Catches
    The whole plan: files, block names, tag tables, hardware changes and deletions, before anything opens
  • Compile

    Tool
    build_from_source, scl_apply, compile_project
    Catches
    Type, call and syntax errors from the TIA Portal compiler, with block, line and network
  • Verify

    Tool
    verify_change
    Catches
    Blocks changed outside the targets; interface, attribute, remanence and external-access changes; scan-shape regressions
  • Audit

    Tool
    audit_project
    Catches
    Multiple writers, unwired FB inputs, literal offsets in POKE, PEEK and BLKMOV, retain in volatile DBs
  • Test

    Tool
    plcsim_test
    Catches
    Outputs that do not match the expected values for given inputs, on S7-PLCSIM Advanced

What a TIA SCL source cannot express

Some block properties never travel through an SCL source. Knowing them keeps a rebuild from changing what you did not ask for:

  • VERSION is major.minor only. VERSION : 1.0 works; VERSION : 1.0.0 produces an empty block without an error at generation. scl_lint rejects it.
  • CASE labels must be literals or the block’s own constants. A constant from a PLC tag table is rejected; declare the values in the block’s VAR CONSTANT section, or use IF and ELSIF.
  • Remanence is only partly expressible. VAR RETAIN works in an optimized global DB; memory-reserve settings are ignored, and VAR NON_RETAIN in a Standard-access DB produces an empty block. verify_change compares remanence per member, so a rebuild cannot change it unnoticed.
  • OB event classes cannot be declared. A source named Startup is not a startup OB: add startup and diagnostic OBs in TIA Portal and paste the body in.
  • Regenerating an FB resets its external access. Statics come back externally accessible and writable, the source default, even when the LAD or FBD original had them closed. verify_change reports the External* flags per member.
  • An omitted FB input compiles clean and reads its start value forever. audit_project reports unwired FB inputs at call sites.

LAD and FBD networks reach the assistant as SCL renderings. A network that could not be rendered completely is flagged lossy: never judge an interlock from a flagged network, and never paste a rendering back as source.

What a clean source header looks like

The header of the built-in DOL motor template follows the conventions the lint and the audit check: a block prefix, a two-part VERSION and PascalCase members. template_show with include_source=true returns the full source.

fb.scl (excerpt)
FUNCTION_BLOCK "FB_MotorDol"
{ S7_Optimized_Access := 'TRUE' }
AUTHOR : TIATool
FAMILY : Equipment
VERSION : 1.0
   VAR_INPUT
      CmdStart : Bool;   // HMI: start (manual)
      CmdStop : Bool;   // HMI: stop (manual)
      // …
      RunningFb : Bool;   // Contactor feedback
      ThermalOk : Bool;   // Thermal overload OK (NC)
      // …
   END_VAR

Who signs off

TIATool makes every AI change reversible, journaled and checked against your baseline. Whether code is fit for a machine is decided by people: a qualified engineer reviews the diff, tests it on S7-PLCSIM Advanced and on site under your commissioning procedure, and releases it. Safety-related functions follow your own safety process.

Want a person to confirm named write tools before they run? An administrator sets confirm_mode in the policy file; the model cannot give that approval itself. See security and data flow.

Frequently asked questions

Does the AI compile the code itself?

No, TIA Portal compiles it. The assistant calls build_from_source, scl_apply or compile_project, and the compiler messages come back with block, line, network and matching knowledge-base entries, so the assistant can fix the source and build again.

What happens if a build breaks the project?

Every write takes a new timestamped backup first, and older backups are never overwritten. restore_backup restores into a new folder by default, or in place after taking a fresh backup of the current state.

Does it work for S7-1200 as well?

Yes. The equipment model targets S7-1500 by default and S7-1200 when you set the CPU family, and the build tools take the PLC by name in any TIA Portal V19 or V21 project.

Can it read my existing LAD and FBD blocks?

Yes, as SCL renderings, so the assistant can follow the logic. A network that could not be rendered completely is flagged lossy; never judge an interlock from a flagged network, and never paste a rendering back as source.

Will the assistant wait for my approval before a build?

No. A build runs when the assistant calls it, after a backup. Ask for a preview first (dry_run), or have an administrator set confirm_mode in a policy file so a person confirms named tools.

Is AI-written SCL ready for a running plant?

The rails make each change reversible and checked; fitness for a machine is decided by people. Test on S7-PLCSIM Advanced with plcsim_test, review the diff and commission under your own procedures before code reaches a running plant.

More guides

Reference

Try it on your own project.

All 75 tools and every update, running on your engineering PC. After the trial a seat is €99.99 a month or €999.99 a year, one PC per seat.

Every plan starts with a 3-day free trial. A card is required at checkout; cancel in your account before the trial ends and nothing is charged.