Skip to content
Back to skills

Siemens

ASecurity

Siemens SIMATIC PLC programming with TIA Portal (V20, V21) and SIMATIC AX: S7-1200/1500 (and legacy S7-300/400), OB/FB/FC/DB structure, optimized vs standard blocks, SCL/LAD/FBD/STL/GRAPH, SCL external sources (.scl/.db/.udt), SimaticML Openness/VCI XML (namespace versions per TIA version), SIMATIC SD (.s7dcl), instruction and data-type specifics (TON_TIME/IEC_TIMER, DTL, Variant), PROFINET/S7/OPC UA/Modbus communication, diagnostics, and Safety Integrated context. Use whenever the target is ...

  • 3 stars
  • 0 votes
  • 5 copies
  • 35 views
  • Added November 15, 2026
developmentpythongogitsecurity

Works with

  • cli

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned November 15, 2026

npx -y skills add SmailG/plc-programming --skill siemens --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Siemens?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Siemens
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/smailg-siemens/badge)](https://www.skillsdirectory.com/skills/smailg-siemens)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: siemens
description: >-
  Siemens SIMATIC PLC programming with TIA Portal (V20, V21) and SIMATIC AX: S7-1200/1500
  (and legacy S7-300/400), OB/FB/FC/DB structure, optimized vs standard blocks,
  SCL/LAD/FBD/STL/GRAPH, SCL external sources (.scl/.db/.udt), SimaticML Openness/VCI XML
  (namespace versions per TIA version), SIMATIC SD (.s7dcl), instruction and data-type
  specifics (TON_TIME/IEC_TIMER, DTL, Variant), PROFINET/S7/OPC UA/Modbus communication,
  diagnostics, and Safety Integrated context. Use whenever the target is a Siemens PLC or
  TIA Portal, the code uses #local/"global" SCL syntax, or the file is a TIA export.
---

# Siemens TIA Portal / SIMATIC S7

## Versions (as of 2026-09)

- **TIA Portal V21** was announced on 2025-11-11. **V20** had reached Update 5 by 03/2026.
- **SIMATIC SD** (`.s7dcl`/`.s7res`) is the new Git-friendly text format:
  - LAD, UDT and DB from V20 Update 3.
  - SCL, FBD, F-FBD, F-DB and mixed blocks from V20 Update 4.
  - V21 extends it further.
  - It does **not** support STL.
- **SIMATIC AX** is a VS Code-based ST toolchain with apax, OOP and unit tests. It is
  "Early Access for selected productive use cases". **AX ST is not SCL.**

Always ask for the exact TIA version and the CPU family, for example "S7-1500, V20 Upd 4".
Formats, namespaces and the available instructions all depend on them.

## Choosing the deliverable

| User wants | Deliver |
|---|---|
| SCL code to paste or import | an **external source `.scl`**, imported via *External source files → Generate blocks from source*. Template: [assets/FB_Conveyor.scl](assets/FB_Conveyor.scl) |
| a Git round-trip of LAD/FBD/SCL (V20 Update 4 or later) | **SIMATIC SD** |
| automated generation of LAD/FBD blocks or tag tables | **SimaticML**, matching the namespace to the TIA version. Template: [assets/FC_LadDemo_V18.xml](assets/FC_LadDemo_V18.xml) |
| STL (AWL) | SimaticML or an `.awl` source; SD cannot carry it |

Full format detail, the namespace-version table and the SCL-vs-IEC differences are in
[references/simaticml-and-sources.md](references/simaticml-and-sources.md).

## SCL rules you must follow

- **Locals and globals:**
  - Inside code, locals take `#` (`#start`). Declarations do not.
  - Global symbols are double-quoted: `"DB_Line".speed`, `"FC_Scale"(…)`.
- **Structure:** code follows `BEGIN`. Blocks end with `END_FUNCTION_BLOCK`,
  `END_FUNCTION`, `END_DATA_BLOCK` or `END_TYPE`. `REGION … END_REGION` groups code.
- **Timers:**
  - Prefer **multi-instances** in the FB's static area: `tonX : TON_TIME;`, called as
    `#tonX(IN := …, PT := …);`. An `IEC_TIMER` variable is called as `#t.TON(…)`.
  - Call them **every cycle** and gate `IN` (validator rules ST030–ST033 understand
    `#inst(` and `#inst.TON(`).
- **Optimized access** (`{ S7_Optimized_Access := 'TRUE' }`) is the default on S7-1200
  and S7-1500. Do not rely on absolute offsets into optimized DBs.
- **Enums:** classic S7 has no IEC enums. Use named constants (a local or global
  constant) or an `Int` state with documented values.

## Traps that cost the most on site

1. **An FB interface change re-initialises its instance DBs on download.** Setpoints and
   counters go back to their start values. Plan for download without reinitialization
   (memory reserve), or, on V21 with S7-1500 FW 4.1, "Keep actual values". Otherwise back
   up actual values first.
2. **Array index out of range:** the S7-1500 goes to STOP unless OB121 or local
   `GET_ERROR` handles it, while the S7-1200 stays in RUN. ENO is not cleared, so check
   indices explicitly.
3. **Cycle overrun:** OB80 is called. The CPU stops if OB80 is missing, or on a second
   overrun in the same cycle.
4. **Temps:** in standard blocks they are undefined until written. Write before you read.
5. **In SCL, "Set ENO automatically" is off by default.** Programming and I/O access
   errors never reach ENO.
6. **Forces survive going offline**, and only peripheral I/O can be forced.
7. **Modbus TCP server:** register 0 is the first word of `MB_HOLD_REG`, which clients
   call 40001. Each connection needs its own instance DB and ID.
8. **PUT/GET** has to be explicitly permitted, and it has no security of its own.
9. **Safety programs are F-LAD/F-FBD only**, with no REAL. Never present generated
   F-code as validated.

## References

- [references/platform-and-structure.md](references/platform-and-structure.md): versions,
  controller families and languages, the OB table, optimized vs standard access,
  parameter passing, references and arrays, and download impact.
- [references/scl-and-data-types.md](references/scl-and-data-types.md): SCL syntax beyond
  IEC, external-source rules, DTL/S5TIME/ANY/VARIANT/HW types, and timers.
- [references/simaticml-and-sources.md](references/simaticml-and-sources.md): the `.scl`
  / SD / SimaticML / AX formats and the namespace table.
- [references/style-guide.md](references/style-guide.md): style-guide rule IDs (ES, NF,
  SE, DA, PE…), naming, and the `status` WORD convention. Paraphrased, for licence reasons.
- [references/communication.md](references/communication.md): PROFINET, PUT/GET and
  S7comm-plus, OUC/`TCON_IP_v4`, Modbus TCP/RTU, the OPC UA server and client with
  licences, and data consistency.
- [references/diagnostics-safety-motion.md](references/diagnostics-safety-motion.md):
  monitoring, force, trace and the diagnostic buffer, `GET_ERR_ID`, the S7 review
  checklist, Safety Integrated, `MC_*`, and PID.

## Validate

Run `python3 ${CLAUDE_PLUGIN_ROOT}/scripts/plc_validate.py <file>`.

| File | Rules |
|---|---|
| `.scl` / `.st` | ST0xx |
| SimaticML `.xml` | SM0xx: namespace vs TIA version, hex `ID`, per-network `UId`, wires, sections |
| `.s7dcl` | SD0xx: `NETWORK`/`RUNG` nesting only |

None of these is a TIA compile. Tell the user to compile in TIA and to fix what it reports.

WinCC (classic, 7.x) Tag Logging archive segments are not TIA files. To read the fast-archive
blocks of one offline, see
[../other-platforms/references/wincc-tag-logging-archive.md](../other-platforms/references/wincc-tag-logging-archive.md):
undocumented format, reverse-engineered on WinCC 7.5 SP2.

Files in this skill

  • SKILL.md6 KB
  • assets/FB_Conveyor.scl1.1 KB
  • assets/FC_LadDemo_V18.xml1.4 KB
  • references/communication.md5.4 KB
  • references/diagnostics-safety-motion.md5.9 KB
  • references/platform-and-structure.md7.9 KB
  • references/scl-and-data-types.md5.1 KB
  • references/simaticml-and-sources.md9.1 KB
  • references/style-guide.md4.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.