Difference Between FC and FB in Tia Portal

So, you are working in the TIA Portal software of Siemens, and are new to function blocks and function codes in them. You will be required sometimes to write a program where you will need to use your own function blocks, to reduce your programming task. TIA Portal provides two options for writing your own libraries – using a function block or a function call. Both need a clear understanding of when to use them, otherwise, you will run your library in the wrong way. So, in this post, we will see the difference between a function call and a function block in the TIA Portal software for writing logic.

What is a user-defined library in PLC programming?

First of all, let us understand why we are discussing this topic. A PLC has two types of libraries – predefined and user-defined. A predefined library is one that is already developed by the PLC manufacturer and comes built-in with the software, like timers and counters. A user-defined library is one that can be developed by the programmer according to their needs, basically meaning that it is customisable. So, it will also have its set of inputs and outputs, similar to how you see the input and output of a timer. The only difference is that the IOs will have their own name defined by the user, and the logic written inside will also be defined by the user. Both these libraries can be called multiple times, known as multiple instances, where you can use the same logic multiple times, and that too independently of each other.

For example, you are using timers in the program four times, each called by different logic, and the output goes in different ways. Similarly, you are using your own libraries four times, each called by different logic, and the output goes in different ways.

What is a function block in TIA Portal?

Let us first start with a function block. Refer to the image below. A function block is represented by a blue symbol, as shown in the left-hand bar with the name we highlighted, for example, Motor_Avail_Logic. It has the following parameters: input, output, inout, static, temp, and constant. So basically, you can link your own inputs and outputs, and create a logic inside the function block. Once you take a new FB, it will ask you to create a new instance DB or data block. This means that each FB will have its own data block for storing the values. Every instance of an FB is thus defined by its own data block.

What is a function block in TIA Portal?

In FB, you have the main advantage of retaining the current values inside each of its instances used, which are independent. Due to this, it is ideal for logic that is used multiple times in the same way, and requires storing its last values even after a power off. But as it is a function block, it is of no use in the logic if any of its instance is not used in the program. This is because, like a normal logic section that you write and call in a task configuration, this is not a normal logic section but a function block.

More details about Function Blocks Here:

What is a function call in TIA Portal?

Let us now proceed with a function call. Refer to the image below. A function call is represented by a green symbol, as shown in the left-hand bar with the name we highlighted, for example – Auto_Mode_New.

It has the following parameters: input, output, inout, return, temp, and constant. So basically, you can link your own inputs and outputs, and create a logic inside the function call. Once you take a new FC, it will not ask you to create a new instance DB or data block. This means that each FC will not have its own data block for storing the values. Every instance of an FC is thus not defined by its own data block.

What is a function call in TIA Portal

In FC, you have the main point of not retaining the current values inside each of its instances, which are independent. Due to this, it is ideal for logic that is used multiple times in the same way, and does not store its last values after power off. But as it is a function call, it is of no use in the logic if it is not called in the task configuration of the CPU. This means that FC is a normal logic section that we use in the program to write logic, and can also as a purpose of a function block with multiple instances, the difference being that it will not have it’s own DB and not be able to store the last hold values inside each of it’s instances.

Read More Information on Functions Here:

FB vs. FC in TIA Portal

  1. A function block instance uses its own set of DB for storing the values inside it and retaining them, whereas a function call instance does not use its own set of DB for storing the values inside it and retaining them.
  2. A function call needs to be made in the task configuration CPU to use it in the program, which is not the case with the function block. If FB is to be used in the program, then at least one instance must be created. So, once you call FC, then write a logic inside it and either keep it as it is, or further use its multiple instances in the other parts of the program.
  3. As FB uses data blocks, memory consumed in CPU is more than FC which does not use data blocks or retains values. So everytime a FC instance is called, it will have to recalculate all the logic once again from the current inputs, as it does not know which were the last values. So, it will require inputs every time for executing their instances, which is not the case with FB.
  4. The execution speed of FB is slower than FC, because no instance DB is used in FC and also not required to store the last values.

In this way, we saw the difference between FC and FB in the TIA Portal.

Read Next:

Don't Miss Our Updates
Be the first to get exclusive content straight to your email.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address

Leave a Comment

Share via
Follow us and never miss an update!