December 5, 2025 · tia-portalplc-programmingbest-practicessiemensfunction-blocks
When you insert a child function block inside another FB in TIA Portal, a pop-up window asks how to create the instance. The default selection is single-instance.
For anyone new to TIA Portal, the default seems like the safe choice. It is not. In almost every case, you should select multi-instance instead.
Here is what each option actually does, why it matters, and when to use which.
What Happens With Single-Instance
When you select single-instance for a child FB, TIA Portal creates a global instance data block (DB) for that child. The child’s data lives in its own separate DB, completely independent of the parent FB.
This might sound fine at first. The child works, the parent works, everything runs. But the problem shows up when you try to reuse the parent FB.
Because the child has its own global instance DB, that child is essentially a global variable living inside your function block. If you call the parent FB a second time (say, for a second motor or a second valve), both calls share the same child instance DB. The data overlaps. Things break.
To work around this, you would need to manually create additional global instance DBs for each copy of the parent. Your project tree fills up with instance DBs. Your code becomes harder to maintain and impossible to put into a library.
What Happens With Multi-Instance
When you select multi-instance, the child FB’s data is stored as a static structure inside the parent’s instance DB. No separate DB is created. The child’s data lives inside the parent, nested cleanly.
Each time you call the parent FB, each call gets its own instance DB, and each instance DB automatically contains its own copy of the child’s data. No overlap. No manual DB management. Everything stays self-contained.
This is how function blocks are meant to work in TIA Portal.
The OOP Analogy
If you come from a software development background, the analogy is straightforward.
A single-instance child FB is like a global variable that your class depends on. It creates a hidden coupling that breaks when you instantiate the class more than once.
A multi-instance child FB is like a private member object inside a class. Each instance of the parent class gets its own copy. You can also think of it as a method of the parent class, or a static variable of a user-defined type (UDT).
In object-oriented terms: multi-instance gives you proper encapsulation. Single-instance breaks it.
Why Multi-Instance Is Almost Always Better
The advantages of multi-instance are practical and immediate:
Reusability. Your FB can be instantiated multiple times without manual DB management. Call it ten times, and each call gets its own data automatically.
Library-ready. If you ever want to put your FB into a library and reuse it across projects, it must use multi-instance children. Single-instance FBs cannot be library blocks.
Cleaner project tree. No extra global instance DBs cluttering your project. The data structure stays nested and organized.
Easier maintenance. When all the data lives inside the parent’s instance DB, you can see the complete data structure in one place. No hunting through separate DBs.
Consistent behavior. No risk of two calls accidentally sharing data through a global instance DB.
When to Use Single-Instance
There are rare cases where single-instance makes sense:
Intentionally shared data. If you genuinely need two different parent FBs to share the same child instance and its data, a global instance DB is the mechanism for that. This is uncommon but valid in specific architectures.
Legacy code. Some older projects or migrated Step 7 Classic programs use single-instance patterns. When maintaining legacy code, it may not be worth refactoring.
For new development, the answer is almost always multi-instance.
How to Change the Default Behavior
TIA Portal defaults to single-instance in the pop-up dialog. There is no global setting to change this default. You need to manually select multi-instance each time you insert a child FB.
It takes one extra click. Build the habit. Your future self (and anyone who inherits your code) will thank you.
The Bottom Line
Multi-instance function blocks keep your data encapsulated, your code reusable, and your projects clean. Single-instance creates hidden global dependencies that break reusability and complicate maintenance.
When TIA Portal shows you that pop-up, select multi-instance. Every time.
Planning a project? Contact us to discuss how we can help.
