Overview: Bridging Maintenance Work and Advanced PLC Programming
Most maintenance and reliability engineers reach a plateau in Siemens TIA Portal because their daily work consists of small modifications: adding a sensor, swapping a barcode reader, or replacing an I/O card. These tasks are technically achievable without deep programming knowledge, yet the same engineers are blocked when they encounter safety interlocks, fail-safe blocks, password-protected F-blocks, or unfamiliar data structures such as UDTs and arrays.
This reference walks through the concrete skills required to move from "I can download a project" to "I can modify a running S7-1200 or S7-1500 program safely." It is written for an engineer who owns a TIA Portal workstation, has no in-house automation peer, and needs to perform the typical 5-95% modifications that production environments demand every week.
Prerequisites
| Item | Required Specification | Notes |
|---|---|---|
| Engineering station | TIA Portal V17 or V18 with STEP 7 Professional | Basic edition cannot edit safety programs |
| License | STEP 7 Safety Advanced (for F-CPU edits) | 15-day trial available on Siemens Online Support |
| CPU access | Ethernet / PROFINET, configured IP, online reachable | Test via "Go online" → "Accessible devices" |
| Project archive | Functional .zap17/.zap18 file or TIA Portal multiuser server | Required before any online change |
| Backup policy | Git, SVN, or TIA Portal Project Server | See Backup Strategy section below |
| Hardware SP | Current hardware catalog packages | Download via TIA Portal Support Packages |
Step 1: Build a Reproducible TIA Portal Workflow
The single highest-impact change you can make is to formalize the offline / online / backup loop. Every modification should pass through the same path:
- Open the project from a versioned archive (do not edit the "master" copy directly).
- Go online with the CPU in STOP if you intend a full download, or remain in RUN with appropriate online change privileges for incremental work.
- Make the edit in the offline project tree.
- Compile (Project tree → right-click CPU → "Compile all"). Errors must be zero.
- Download to device. Select the correct target (the CPU, not a simulated instance).
- Back up the updated project immediately after successful download.
Step 2: Mastering UDTs and Structs
A User-Defined Type (UDT) is the equivalent of a struct in C. It bundles related tags under one name and gives them semantic meaning. In maintenance work this is critical because most production programs already use UDTs to represent devices (motors, valves, drives, barcode readers). Without understanding UDTs, you cannot safely add a new device — you will create a flat tag namespace that nobody else can read.
Defining a UDT for a sensor
For an inductive product-detection sensor, define:
TYPE "UDT_Sensor"
VERSION : 1.0
STRUCT
iRawInput : Bool; // physical input
bPresent : Bool; // debounced state
bFault : Bool; // wire-break / short
rSignalLevel : Real; // analog percentage 0-100
sDeviceTag : String[16]; // "S101_BEAM_OK"
dwUptime_s : DWord; // since last fault clear
END_STRUCT;
END_TYPE
Then create an instance DB:
DATA_BLOCK "DB_Sensors"
STRUCT
stS101 : "UDT_Sensor";
stS102 : "UDT_Sensor";
stS103 : "UDT_Sensor";
END_STRUCT;
END_DATA_BLOCK
To add a fourth sensor later, you only append stS104 : "UDT_Sensor"; in the struct and re-compile. The HMI tags automatically inherit the new tag if you generated them from the PLC tag table.
Arrays of UDTs
For variable-length equipment (a 12-position rotary table, a 24-bottle filler), use an array:
DATA_BLOCK "DB_Positions"
STRUCT
astPos : Array[1..24] of "UDT_Sensor";
END_STRUCT;
END_DATA_BLOCK
Indexing with a tag lets you loop through all positions in SCL:
FOR #i := 1 TO 24 DO
IF "DB_Positions".astPos[#i].bPresent THEN
// handle position
END_IF;
END_FOR;
Step 3: SCL vs LAD vs FBD — When to Use Each
| Language | Strength | Typical use |
|---|---|---|
| LAD (Ladder) | Visual for bit logic, easy for electricians | I/O mapping, simple interlocks |
| FBD (Function Block Diagram) | Good for analog math, PID | Continuous control loops |
| SCL (Structured Control Language) | Loops, math, string handling, complex conditionals | Recipe handling, barcode string parsing, motion sequencing |
Why SCL matters for maintenance
Most "the barcode reader changed and we need to update the prefix" tasks involve string parsing. String handling in LAD becomes unreadable very quickly. In SCL:
// Strip the leading 4-character prefix and validate
#sRaw := "DB_Comm".sBarcodeRaw;
IF LEN(#sRaw) >= 8 THEN
#sPrefix := LEFT(IN := #sRaw, L := 4);
#sBody := MID(IN := #sRaw, L := 4, P := 5);
IF #sPrefix = "NEW-" THEN
"DB_Comm".bPrefixOK := TRUE;
"DB_Comm".sBodyClean := #sBody;
END_IF;
END_IF;
The same logic in LAD would require LEN_STRING, LEFT_STRING, MID_STRING, and EQ_STRING blocks chained together with status bits — possible, but unmaintainable.
Step 4: Multi-Instance Function Blocks
Multi-instancing is the difference between "copy-paste FB10 twelve times with renamed instance DBs" and "declare one FB with an instance inside another FB." The latter scales.
FUNCTION_BLOCK "FB_Motor"
VAR
iRun : Bool;
bFault : Bool;
tRampUp : Time;
END_VAR
BEGIN
// motor control logic
END_FUNCTION_BLOCK
Use it inside another FB:
FUNCTION_BLOCK "FB_Conveyor"
VAR
motDrive : "FB_Motor"; // multi-instance
motTail : "FB_Motor"; // multi-instance
END_VAR
BEGIN
motDrive(iRun := #bStartDrive);
motTail (iRun := #bStartTail);
END_FUNCTION_BLOCK
The advantage: only one instance DB for the entire conveyor. HMI tag generation, online diagnostics, and search all reference motDrive.iRun instead of "DB_Motor1".iRun.
Step 5: Adding an Inductive Sensor — Field Procedure
Scenario: a line needs an additional inductive sensor to detect product presence at station 5.
- Wire the sensor to a free DI on the local ET 200SP or the CPU's onboard DI. Note the channel number (e.g.,
I 8.6for slot 8, channel 6). - In the device configuration, confirm the channel is configured as DI (not deenergized). On ET 200SP this is in Properties → DI8 → Channel template.
- Add a tag in the PLC tag table:
iS5_Present : Bool %I8.6. - Add the tag to the existing UDT instance in
DB_Sensorsor to the relevant equipment DB. - Use the tag in the program. For a simple presence latch, drop a normally-open contact
iS5_Presentin series with the existing "station 5 ok" rung. - Compile → download to device (RUN mode with online changes is acceptable for adding a new input; you are not removing anything).
- Verify with a watch table: force the input off, verify the related permissive drops; release the force, verify it re-arms.
Step 6: Updating a Barcode Reader Prefix — Field Procedure
- Identify the read function block. Typical patterns:
FB_BarcodeReader,FB_RD800, or a vendor-supplied FB. - Find the prefix comparison. Search for the old prefix as a string constant: Find and replace → "Search in all blocks for string 'OLD-'".
- Open the SCL source. Change the comparison string from
"OLD-"to"NEW-". - Compile. If the block is referenced as a multi-instance, the change propagates automatically.
- Download with online change (full download not required for a string literal change).
- Verify by scanning a sample code and watching
DB_Comm.bPrefixOKgo TRUE.
Step 7: Backup Strategy and Version Control
The phrase "I am afraid to download because I might break it" is solved by backups. Three layers:
| Layer | Tool | Retention |
|---|---|---|
| Project file archive | File → Archive → .zap17 | Every change |
| Version control | Git LFS or Siemens TIA Project Server | Tagged baselines |
| Online backup | CPU → Online → "Backup from online device" | Before every download |
Online backup procedure
- Select the CPU in the project tree.
- Go online.
- Right-click → "Backup from online device".
- Save the
.s7pbkfile with a name including the date and the modification performed:Line3_CPU_backup_2024-11-08_added_S5_sensor.s7pbk.
This file lets you restore the CPU to the exact state before the change. Without it, a failed download on an F-CPU can lock the safety signature and require a master reset.
Step 8: Safety Blocks and Fail-Safes — Solving the "I Cannot Download" Problem
The most common TIA Portal frustration is being unable to download to an F-CPU. The diagnostic buffer contains one of these patterns:
| Symptom | Diagnostic entry | Cause | Fix |
|---|---|---|---|
| Download refused, F-signature mismatch | 0xE4FE / "Safety signature does not match" | Online program differs from offline F-block signatures | Recompile safety program, accept new signature, document new value in safety log |
| F-block greyed out | — | STEP 7 Safety Advanced not installed | Install license, restart TIA Portal |
| Cannot delete F-block | — | Block is password-protected and you lack the F-password | Request F-password from the safety engineer. NEVER bypass safety to bypass password. |
| CPU in STOP after download attempt | 0x75D2 / "F-CPU: Safety program incomplete" | F-runtime group references a deleted block | Restore from backup, recompile F-runtime group, ensure all referenced FBs are present |
Step 9: Migrating a LOGO! Workstation to S7-1200
The user's plant has early-2000s workstations running on LOGO! (or other odd solutions). These are candidates for migration. The conversion is not trivial but is achievable in one weekend per station.
| LOGO! feature | S7-1200 equivalent | Migration note |
|---|---|---|
| Digital inputs (I1-I8) | Onboard DI or SM 1221 | Map directly |
| Relay outputs (Q1-Q4) | SM 1222 RLY or DO | Verify contactor coil voltage |
| LOGO! Soft Comfort program | TIA Portal SCL or LAD | Re-implement, do not auto-convert |
| LOGO! TD text display | Basic Panel KTP700 or HMI Tag | Recreate screens |
| LOGO! clock flags | SCL clock generator FB | 1 Hz, 0.5 Hz, etc. |
Recommended hardware for migration
- CPU 1214C DC/DC/DC with firmware V4.5 (article number
6ES7214-1AG40-0XB0) - SM 1221 DI 16 x 24 V DC (
6ES7221-1BH32-0XB0) if DI count exceeds onboard 14 - SM 1222 DO 16 x 24 V DC (
6ES7222-1BH32-0XB0) - CSM 1277 unmanaged switch for HMI connection
- Basic Panel KTP700 Basic (PN, 7")
Step 10: Self-Directed Learning Path
For an engineer with no in-house PLC peer, Siemens Learning Journey provides a structured curriculum. Recommended sequence:
- TIA Portal S7-1200 Basic (TIA-PRO1) — online or instructor-led, 5 days.
- TIA Portal S7-1500 Service (TIA-SERV) — 3 days, focused on maintenance and diagnostics.
- TIA Portal Programming 2 (TIA-PRO2) — SCL, UDTs, multi-instances, complex data structures.
- SIMATIC Safety in TIA Portal (TIA-SAFETY) — required before touching any F-program.
Between courses, pick one workstation, reverse-engineer its function, and rebuild it offline. Simulate with PLCSIM. Iterate.
Verification Checklist Before Going Online
- [ ] Offline project compiles with zero errors and zero warnings.
- [ ] Online backup of the CPU is saved to a versioned folder.
- [ ] Watch table is created with the affected tags.
- [ ] For F-CPU work: safety engineer has been informed, signature change is approved.
- [ ] After download: CPU diagnostic buffer shows no new errors.
- [ ] Force table is used (not the program) for any temporary logic verification.
- [ ] Project archive
.zap18is saved with a descriptive filename.
Troubleshooting Matrix
| Problem | Likely cause | Resolution |
|---|---|---|
| "Online: no accessible devices" | Firewall, wrong IP subnet, PROFINE T cable | Set PG/PC interface to the correct NIC, ping CPU IP |
| "Cannot compile: instance depth exceeded" | FB recursion or too many levels of multi-instance | Restructure FBs, avoid calling an FB from inside itself |
| HMI tags show "##" | Tag not in PLC tag table as HMI-visible | Project tree → PLC tags → tick "Accessible from HMI" |
| Download succeeds but CPU stays in STOP | OB100 / startup blocks missing or referenced block deleted | Check diagnostic buffer entry, restore missing OB |
| SCL block downloads but does not run | EN/ENO handling or uninitialized variable | Insert explicit initialization at top of block |
FAQ
How do I add a new inductive sensor to a running S7-1200 program without stopping the line?
Wire the sensor to a free DI, add the tag in the PLC tag table (%I8.x), reference it in the program, compile, and download with online changes. Verify with a watch table before relying on it for production.
What is the difference between a UDT and a DB in TIA Portal?
A UDT is a type definition (a template). A DB is a variable of that type (or of a STRUCT). Always model with UDTs so that adding an instance requires only one line of code and inherits all member tags automatically.
Why does TIA Portal refuse to download to my F-CPU?
Either the safety signature has changed and you have not accepted the new signature, the F-block is password-protected without the F-password, or the offline F-runtime group is missing a referenced block. Install STEP 7 Safety Advanced, recompile the safety program, and document the new signature.
Can I migrate a LOGO! program directly to S7-1200?
There is no automatic converter. Re-implement the logic in SCL or LAD after documenting the original function with screenshots and I/O lists. Plan one full weekend per simple workstation.
How do I version-control TIA Portal projects?
Use the TIA Project Server for multi-user collaboration, or archive each project as a .zap18 file and store the archives in Git LFS. Always archive before any modification and after every successful download.