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
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
Write or generate the source
The assistant writes
FUNCTION_BLOCK,FUNCTION,DATA_BLOCK,TYPEandORGANIZATION_BLOCKsources 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
Lint before TIA Portal sees it
scl_lintchecks 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
Preview, then build and compile
build_from_sourcewithdry_runprints 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_applylints, 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
Verify against the baseline
After a fresh export and scan,
verify_changechecks 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
Test, review, release
Run input-to-output cases on S7-PLCSIM Advanced with
plcsim_test, read the diff withproject_diff, and let a qualified engineer review and release the code. If anything is wrong,restore_backupbrings 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_sourcedry 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
| Stage | Tool | Catches |
|---|---|---|
| Lint | scl_lint | Unbalanced blocks, a three-part VERSION, global constants as CASE labels, undeclared #symbols, empty statements |
| Preview | build_from_source dry run | The whole plan: files, block names, tag tables, hardware changes and deletions, before anything opens |
| Compile | build_from_source, scl_apply, compile_project | Type, call and syntax errors from the TIA Portal compiler, with block, line and network |
| Verify | verify_change | Blocks changed outside the targets; interface, attribute, remanence and external-access changes; scan-shape regressions |
| Audit | audit_project | Multiple writers, unwired FB inputs, literal offsets in POKE, PEEK and BLKMOV, retain in volatile DBs |
| Test | plcsim_test | 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.0works;VERSION : 1.0.0produces an empty block without an error at generation.scl_lintrejects 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 CONSTANTsection, or use IF and ELSIF. - Remanence is only partly expressible.
VAR RETAINworks in an optimized global DB; memory-reserve settings are ignored, andVAR NON_RETAINin a Standard-access DB produces an empty block.verify_changecompares 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_changereports the External* flags per member. - An omitted FB input compiles clean and reads its start value forever.
audit_projectreports 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.
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_VARWho 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
- Analyse an inherited projectHow do I analyse an inherited TIA Portal project fast?
- Openness and AIHow does AI automate TIA Portal Openness?
- Cursor and VS CodeCan I use Cursor or VS Code with TIA Portal?
- Claude and TIA PortalHow do I use Claude with Siemens TIA Portal?
- MCP server for TIA PortalWhat is an MCP server for TIA Portal?
Reference
- Capability matrix: what is proven, with evidence and limits
- MCP tool reference: every tool with its arguments, effect and status
- Security and data flow: who sees what, and the threat model
- Get started: install, connect your AI app and run a first session
- Install in three steps
- Pricing: monthly or yearly, every tool included
- How TIATool compares with other ways to use AI in TIA Portal
- FAQ: install, licensing, data and TIA Portal versions
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.