Overview
Renumbering a Function Block (FB) in a Siemens SIMATIC Step 7 Classic (S7-300/S7-400) project is a routine but high-risk maintenance task. The block number is referenced in every call location (FCs, other FBs, OB1, multi-instance DBs, the symbol table, the System Data, and any CFC/SFC chart) and the underlying absolute address inside the block is referenced from the instance DB. If you simply delete the old FB and insert a new one at a different number you will orphan every call, scramble the instance DB mapping, and force a full rewire of multi-instance code by hand.
Step 7 Classic ships a dedicated tool for this exact situation: Options → Rewire... It rewrites every reference to the old block number with the new block number, retains the instance DB, retains the symbol assignment (if one exists), and produces a change log so you can verify what was touched before you save the offline project and download to the PLC.
Prerequisites
- STEP 7 V5.4 SP5 or newer (V5.6 SP2 recommended). The Rewire dialog requires the SIMATIC Manager component installed; it is not present in the older STEP 7 Lite toolset.
- An offline S7 project with the FB already compiled cleanly. Resolve every compiler warning or error before the rewire, otherwise the change log will be polluted with pre-existing problems that hide real new issues.
- The Symbol Table (S7-Program → Symbols) editable and writable on disk. If the project lives on a read-only share, copy it locally first.
- Sufficient free numbers in the FB number range. By default the user FBs occupy 0-255; extended FBs use 256-2047. If you are renumbering to FB1060, you must be working in an S7-400 station with the extended number range, or the S7-300 CPU firmware you are using must permit it (e.g. CPU 319 with firmware ≥ 2.4). Verify this against your CPU's manual before attempting the rename.
- A clean, versioned backup of the project archive (.zip or .arj) so the change can be rolled back if Rewire reports an unexpected number of substitutions.
Understanding the Two Priority Modes
Step 7 Classic supports two mutually exclusive resolution strategies between symbolic names and absolute addresses. Every rewire decision depends on which one is active when the program is compiled. Always check Options → Customize → Block tab → Address Priority before the procedure and restore it afterwards.
| Mode | How the compiler resolves a call | Effect of a ReWire | Effect of inserting in the middle of an instance DB |
|---|---|---|---|
| Symbol has priority (default in most projects) | The symbol in the symbol table is authoritative; the absolute address is refreshed from the symbol when the project is compiled. | Changing the symbol's target block number causes every call site that uses the symbol to follow on the next compile. Symbolic calls update automatically; absolute calls do not. | Safe. The compiler re-anchors every absolute access to the new offset. A full recompile is required after the edit. |
| Absolute Address Has Priority | The absolute address is authoritative; the symbol is updated from the absolute address on compile. | You must change the absolute address first (Rewire does this), then update the symbol. This is the mode the Rewire procedure depends on for safe completion. | Unsafe. Inserting a new row in the middle of the instance DB shifts the absolute offsets of every subsequent row but Rewire will not touch them. Any FC/FB accessing the DB by absolute offset will read or write the wrong variable silently. Use this mode for rewire only; never for editing DB contents. |
Step-by-Step Rewire Procedure
The procedure below renames FB60 to FB1060 while keeping every parameter, instance, multi-instance, and symbol association intact. It assumes a single S7-400 station with a standard distributed I/O topology. Adapt station names to your project.
Step 1 — Archive the project
- Close the project in SIMATIC Manager.
- From Windows Explorer, right-click the project folder → 7-Zip → Add to archive (or use the STEP 7 built-in File → Archive). Save the archive outside the source directory.
- Record the project version, station type, and CPU firmware in a release note. The rewire change log is meaningless without a before-state.
Step 2 — Compile the project to a clean state
- Open the project, right-click the S7-Program node of the target station, choose Compile and Check Objects.
- Open the Accessible Nodes or the local offline view and read the Compile Log window. Resolve every entry that is not informational.
- Re-run Check Block Consistency (Options → Check Block Consistency). A green status here is the only safe starting point for a rewire.
Step 3 — Switch to Absolute Address Has Priority
- Select Options → Customize... in SIMATIC Manager.
- Open the Block tab (in some translations Bausteine).
- Under Address priority, select Absolute Address Has Priority and click Apply. Do not close SIMATIC Manager.
Step 4 — Add the new symbol entry
- Open S7-Program → Symbols.
- Locate the row for the old symbol (commonly
FB60with a meaningful mnemonic such asMotor_Control_FB). Note the symbol name and data type (FB 60). - Right-click the row and choose Insert Row just above it, or scroll to an empty row.
- Enter the new symbol name, the new address (
FB 1060), and the data typeFB 1060. Keep the old row temporarily; you will delete it after Rewire completes. - Save and close the symbol table.
Ctrl+Swrites the file to the project directory.
Step 5 — Run the Rewire
- Select the Blocks folder of the S7-Program so that Rewire applies to the entire program, not just a single object.
- Choose Options → Rewire...
- In the Old Number field enter
60. In the New Number field enter1060. - Leave All block types unchecked except FB, or you will accidentally rewrite FC, DB, OB, and SFB/SFC numbers that happen to match.
- Click OK. A progress bar shows the number of files scanned; expect several hundred to several thousand substitutions on a medium-sized plant project.
Step 6 — Read the change log
Rewire writes a plain-text report. The default location is the project root with a name like Rewire.log; in some installations the report opens inline in the SIMATIC Manager message window. Read it cover to cover and look for:
- Number of FCs/FBs modified (this is your objective evidence the rename was applied).
- Number of OBs touched. OB1, OB35, OB82-87, OB100-102, OB121-122 are the common ones.
- Number of DBs touched. Each instance DB associated with FB60 will need its background block re-anchored — this is expected.
- Any line beginning with
ERRORorWARN. These block the rename from completing; resolve and re-run.
Step 7 — Reconcile the symbol table
- Open the symbol table again.
- Delete the row for the old address (
FB 60). Keep the row for the new address (FB 1060). - If any consumer of the project referenced the old symbol in operator faceplates (WinCC flexible, WinCC, HMI tags) update the tag pointer. WinCC stores the absolute block number in the tag address; Rewire does not modify the HMI project.
Step 8 — Return to Symbol-has-priority and recompile
- Open Options → Customize → Block tab and select Symbol has priority.
- Click Apply.
- Run Check Block Consistency followed by Compile and Check Objects. Every block should compile without warnings.
- Save the project (
Ctrl+Son the S7-Program node).
Step 9 — Download to the PLC
- Connect to the target CPU and place it in STOP if you are changing a block that runs in OB1, OB35, or any time-critical OB. For a pure renumber with no logic change, a download in RUN-P is also possible in newer CPUs (firmware ≥ 3.1 on S7-400 CPUs and CPU 319), but STOP is safer for a first deployment.
- Perform a full download of the Blocks container. A delta download may skip the new FB if the comparison engine matches it against the cached offline file.
- Perform a Cold Restart only if a multi-instance DB reset is required. For an in-place renumber, a Warm Restart is sufficient and preserves retain data.
Verification
Verification is the part of the rename that actually matters. Do not declare success after a clean compile alone.
- Cross-reference check. Open the Reference Data → Display from the Blocks folder. Filter by the old block number. The result must be empty. Filter by the new block number. The list must contain every call site that referenced the old number, plus the multi-instance FB instantiations inside other FBs.
- Symbol resolution check. In any FC that called the old FB, place the cursor on the call line. The status bar at the bottom of SIMATIC Manager must show the symbol name of the new FB, not ??.
- Online block comparison. In RUN or STOP, right-click the new FB and choose Compare → Online/Offline. The result must be Identical. Repeat for every instance DB that was re-anchored.
- Live I/O check. For a motor-control FB, force a single instance in the instance DB and observe the I/O. The block number on the B-Stack of the online block viewer must be 1060, not 60.
- HMI tag check. Trigger a value change in a WinCC tag that points to a DB variable used inside the renamed FB. The faceplate should update within one configured acquisition cycle.
- Cross-station consistency. If you have a redundant S7-400H pair or a software redundancy package, repeat the download on the standby CPU. The IM/IML sync must report In sync.
Multi-Instance DB Considerations
Every call to an FB creates an Instance DB (for single-instance calls) or a multi-instance slot inside the caller's instance DB. The instance DB records the FB number it was created from, the FB's static variable layout, and the start address of each VAR_TEMP/VAR_INPUT/VAR_OUTPUT/VAR_IN_OUT/VAR_STAT/VAR_TEMP. A renumber does not change the static layout, but it does change:
- The
FB-Nrfield in the DB header, which is what the CPU uses to verify the instance is bound to the right FB type. - The
AR2register setup when the DB is opened, which is computed from the DB number and the FB number.
Rewire updates both transparently. You can confirm by opening the instance DB in Declaration View online; the header should now read FB 1060 and the View → Data View initial values should match the offline project exactly.
SF and CPU diagnostic buffer entry Event ID 16#4570 "STOP due to BLOCK_DB-OPEN error". The fix is to delete the instance DB, recompile, and let the FB re-create it. Do this only after the rewire is fully verified, and only in STOP.What Rewire Does Not Touch
| Item | Rewire updates it? | What you must do |
|---|---|---|
| FC/FB/OB/DB bodies in the Blocks folder | Yes | Recompile to refresh cross-references. |
| Symbol Table | No (it adds the new address, never removes the old one) | Delete the stale row manually. |
| S7-Program > Sources (STL source files) | Partially — only if the source is also compiled and online | Update textual references and recompile the source. |
| CFC charts (PCS 7) | No — CFC stores its own interconnections | Open the chart, search for the old FB number, drag a new instance and re-wire signals, or use the CFC bulk-edit. |
| SFC charts (PCS 7) | No | Re-create the step conditions or use the SFC editor's find-and-replace. |
| WinCC / WinCC flexible / TIA WinCC tags | No — tag address is stored in the HMI project, not the PLC project | Update tag pointers; in WinCC, the tag address is the absolute DB number, but the structure offset is what matters, so the tag typically still resolves. Verify with the tag simulator. |
| Third-party OPC servers (Kepware, Softing) | No | Recompute the address space; OPC uses absolute DB offsets, not symbolic names. |
| Documentation (Word, Excel, PDF) | No | Out of scope. Update engineering documentation by hand. |
Common Pitfalls and Field-Proven Caveats
- Renumbering into a number that is in use. If FB 1059 already exists with a different signature, Rewire refuses to continue but leaves the project in a half-modified state. Always list the entire FB range in the Blocks folder before choosing the new number.
-
Renumbering past the CPU's maximum FB number. S7-300 CPUs without the extended FB number range (older CPU 312/314/315) limit user FBs to 0-255. Re-numbering to 1060 will compile offline but download will fail with
STOP: load error (type 33 / W#16#4579). Check the CPU manual first; the latest CPU 319-3 PN/DP (6ES7 318-3EL01-0AB0, firmware V3.3) supports the extended range up to 2047. - Renumbering an SFB/SFC. Rewire will accept the input but the system function tables are read-only. The change log will show 0 modifications. Treat any SFB/SFC rename attempt as a configuration error.
- Renumbering across stations. A multi-station project (e.g. AS01 + AS02) shares the symbol table at the project level but has independent Blocks folders. ReWire acts on the currently selected S7-Program. You must run it once per station, or use the project-wide Check Block Consistency to find every occurrence.
- Forgetting the safety program. If the FB participates in a F-runtime group (S7-300F/S7-400F), the F-shared DB and F-call signature must be re-checked. A rewire does not change the F-signature, so the safety program will continue to pass the signature check, but you must still document the change in the safety log book.
- Compiling in Absolute-Address-Has-Priority mode by accident. If the engineer on call switches back to Symbol priority and then makes any edit to a DB, the offsets are refreshed. This is the safe behavior — but if the edit was made while still in Absolute priority, the offsets are now wrong and the rewire's effect is partially undone. Always end the procedure with a recompile under Symbol priority.
- Forgetting to delete the stale symbol row. Step 7 tolerates the duplicate, but the online viewer will show two symbols for the same address and the HMI download will warn. The duplicate is the single most common cause of "it works on my laptop but not at the plant" symptom patterns.
Alternative: Symbolic-Only Renumbering
If the goal of the rename is purely cosmetic (for example to make the FB number match a project-wide naming convention), the entire procedure can be reduced to a symbol table edit. The block number on disk stays the same, but every consumer that references the symbol follows on the next compile. The trade-off is that the on-disk number still says FB60, which can confuse a future engineer reading cross-references. Use symbolic renumbering only when:
- The CPU's number range forbids the new number.
- You do not have authorization to do a STOP-mode download.
- The project is shared with an OEM who will not accept a different block number.
Related Procedures
- Copying an FB to a new number uses the same Rewire mechanism but with a different intent. After the copy, the original FB is deleted and every call is rewired to the new number. Step 7 offers a one-shot Blocks → Copy/Paste followed by a manual Rewire, which is the workflow preferred by teams that audit every modification.
- Renaming the symbol but not the number is the inverse of this procedure. Edit the symbol table only, recompile. Useful when the engineering convention uses the block number for nothing more than an internal handle.
- Moving an FB to a library requires a separate Rewire with Library block enabled, plus an update of the master data library. The change log will list every block that imported the old FB.
Diagnostic Codes Encountered During the Procedure
| CPU diagnostic entry | Hex code | Cause | Remedy |
|---|---|---|---|
| STOP due to BLOCK_DB OPEN error | 16#4570 | Instance DB references a missing or wrong-version FB after partial download. | Delete the instance DB and let the FB re-create it on next cold restart. |
| STOP due to block not found | 16#4579 | Number is outside the CPU's permitted FB range. | Verify the CPU's maximum FB number against the manual and re-number into a valid slot. |
| STOP due to type conflict | 16#4B47 | Multi-instance header mismatch. | Re-run Rewire with Block Type filter = FB only, then recompile. |
| Diagnostic interrupt (OB82) | 16#3951 | Slot fault caused by partial download to a configured but empty slot. | Complete the download. |
FAQ
Can I rename FB60 to FB1060 in Step 7 Classic without a STOP-mode download?
Yes on S7-400 CPUs with firmware ≥ 3.1 and on CPU 319 with firmware ≥ 2.4, provided the project is in RUN-P and the CPU permits online block renumbering. Use Target system → Download after Rewire. For maximum safety, especially on S7-300 stations, switch the CPU to STOP first.
What happens if I forget to switch back to "Symbol has priority"?
The project continues to run, but any later edit to a DB that inserts a row in the middle of the declaration will silently desynchronize the absolute offsets. Symbolic callers will point at the wrong variable until the project is recompiled under Symbol priority and downloaded. The single most defensive habit is to recompile at the end of the rename and review the warnings.
Does the Rewire tool also rename instance DBs?
No. The instance DB number (e.g. DB100 backing the old FB60) is a separate parameter and is preserved. ReWire rewrites only the block type field in the DB header. Renaming the DB number itself requires a separate Rewire call with Block type: DB enabled and the appropriate old/new pair.
Why does the change log report a different number of substitutions than the cross-reference list shows?
The cross-reference list shows call sites only (FCs, FBs, OBs). The Rewire change log also counts every occurrence inside the block headers, the system data (SDB), the diagnostic buffer references, and any block-aware comment fields. A difference of 5-15% is normal. A difference greater than that usually means a hidden source file or a generated block is being missed.
Can I batch-rename multiple FBs in a single Rewire pass?
No. The dialog accepts only one old/new pair per invocation. To rename a sequence, run the dialog once per FB, reading the change log between passes. For very large refactors, write a Step 7 script (VBS or the S7-SCL "AWL-rewire" macro) that calls the Rewire API in a loop, then archive the project between every iteration so a single failure does not corrupt the working copy.