Debugging Story: Clever Use of "Re-wiring" Feature



In this edition of "Debugging Stories," I'd like to share a little trick in Siemens STEP7 programming: using the "Rewire" feature to quickly modify program variables.


Here's the situation: Due to changes in the project's process flow, I needed to replace a specific boolean variable in the PLC program (let's assume it's M100.1) with another boolean variable (let's assume it's M200.2). After examining the references to "M100.1," I found many function blocks (FB) and functions (FC) that were using this variable. And all instances of "M100.1" in these function blocks needed to be changed to the new variable, "M200.2."

To address this issue, one approach is to manually modify each reference to "M100.1" to "M200.2" within the relevant function blocks or functions (FB/FC). This is feasible for smaller projects with fewer references. However, for larger projects like mine, involving over 10 function blocks and more than 30 modifications, manual changes are not only time-consuming but also prone to oversights. So, what can be done?


I thought of using the "Rewire" feature in STEP7.

So, I accessed this feature, and after a few simple steps, the problem was quickly resolved. At this moment, I truly appreciate how the SIMATIC development platform is suitable for large project development. Those seemingly simple features can effortlessly solve problems. Of course, it's essential to be aware of these features, and the accumulation of knowledge in everyday work is also crucial. Now, let me share with you how to use the "Rewire" feature in STEP7.

Firstly, in the STEP7 development environment, right-click on "Blocks," then select "Object Properties," as shown below:









In the pop-up dialog box, click on "Address priority" and select "Absolute value has priority." There are two options, and I usually choose the latter, as shown below:



In the pop-up dialog box, enter the source address in the "Old address" field, such as "M100.1"; enter the destination address in the "New address" field, such as "M200.2," as shown below:


Click "OK," and SAMATIC STEP7 will automatically replace the variable in the "Old address" with the variable in the "New address." After completion, it will also generate a text file, allowing you to see which FB/FC have variable modifications, making it very convenient.

In this example, since we selected the entire "Blocks" folder, you will see that the modification scope includes all FB, FC, and OB in "Blocks." If you only want to modify certain FB, select the corresponding FB, right-click, and choose "Rewire."

Isn't it simple? A small feature with great utility.

Alright, that's it for this edition of "Debugging Story Time."