Cookies are important for this site to function properly, to guarantee your safety, and to provide you with the best experience. By clicking OK, you accept all cookies. For more information, please access our Privacy Policy.
Table of Contents
Tutorials / 
An Introduction to the Function Block Diagram (FBD) Language in TIA Portal
Beginner

An Introduction to the Function Block Diagram (FBD) Language in TIA Portal

Siemens
TIA Portal
PLC Programming
IIoT

Introduction

Industrial automation relies on various programming languages to implement control logic effectively. Among the five languages IEC 61131-3 standardized, the Function Block Diagram (FBD) is a prominent choice. This graphical programming language offers engineers a powerful tool for designing complex control sequences within the TIA Portal environment. FBD is renowned for its ability to harness predefined function blocks, encompassing mathematical operations, timers, counters, and logical functions. Operating within a visual canvas, these blocks interconnect via lines representing data flow, facilitating intricate automation systems' design, debugging, and maintenance.

The Function Block Diagram (FBD) language, part of Siemens' TIA Portal ecosystem, facilitates the creation of sophisticated control algorithms through graphical programming. With the FBD language, engineers can build control logic by selecting and connecting function blocks, creating a cohesive and efficient control sequence. 

In this tutorial, you will learn how to harness the power of FBD language in TIA Portal for creating diverse control logic scenarios. You will be guided through adding new blocks, connecting function blocks, and utilizing instructions from the FBD language library. The tutorial covers three practical programs: implementing Boolean algebra, modeling linear equations, and programming a motor control application.

Prerequisites

To follow this tutorial, you will need an installation of TIA Portal. We will use the latest versions to date (v18), but you can use any other version. No additional hardware or software is required.

Programming in FBD language in TIA Portal

Let’s start by creating a new TIA Portal project. Once done, click “Add new device” in the project tree.

Figure 1.1 - TIA Portal Function Block Diagram (FBD) PLC Programming | Creating a new TIA Portal project
Figure 1.1 - TIA Portal Function Block Diagram (FBD) PLC Programming | Creating a new TIA Portal project

After that, you can select any CPU of your choice; FBD is supported by all Siemens PLC models. Here, we will use a 1511-1 PN CPU. Then click on “OK.”

Figure 1.2 - TIA Portal Function Block Diagram (FBD) PLC Programming | Selecting a CPU
Figure 1.2 - TIA Portal Function Block Diagram (FBD) PLC Programming | Selecting a CPU

Once the station is created, we can add a new FBD program block. Click “Add new block” in the program blocks section of the project tree.

Figure 1.3 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding a new block
Figure 1.3 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding a new block

The FBD language can be used in OBs, FBs, and FCs. Here, we create an FB. In the “Add new block” window, select “Function block.” Then, open the languages list and select “FBD.” 

Figure 1.4 - TIA Portal Function Block Diagram (FBD) PLC Programming | Selecting the FBD language
Figure 1.4 - TIA Portal Function Block Diagram (FBD) PLC Programming | Selecting the FBD language

After that, give the block a name and click “OK.”

Figure 1.5 - TIA Portal Function Block Diagram (FBD) PLC Programming | Naming and creating the FB
Figure 1.5 - TIA Portal Function Block Diagram (FBD) PLC Programming | Naming and creating the FB

After the block is created, we arrive at the FBD programming interface. 

The FBD language is a graphical language that allows you to create complex control sequences by utilizing predefined function blocks, such as mathematical operations, timers, counters, logical operations…etc. FBD operates on a visual canvas where these function blocks are interconnected through lines representing data flow. Users can design their logic by arranging and connecting these blocks to create the desired control behavior.  

Figure 1.6 - TIA Portal Function Block Diagram (FBD) PLC Programming | FBD programming interface
Figure 1.6 - TIA Portal Function Block Diagram (FBD) PLC Programming | FBD programming interface
  1. Block interface: As with any other FB block, FBD blocks have an interface where you can define the block’s inputs, outputs, constants, temps…etc.
  2. Workspace: This is where you assemble and connect function blocks.
  3. Instructions: Contains all the function blocks available in the FBD language, such as bit logic operations, timers, math functions…etc.

To illustrate how the FBD language works, we will create 3 small programs for 3 applications. The first program will contain a boolean algebra equation. The second program will contain a simple linear math equation. The third program will contain a simple motor control application.

Boolean algebra

Let’s start with the Boolean algebra equation. We will model this simple equation (A+B)(C+D) = D, which can be translated to ( A OR B ) AND ( C OR D ) equals E. To do so, we will use Network 1 of the FB.

Figure 2.1 - TIA Portal Function Block Diagram (FBD) PLC Programming | Boolean algebra in Network 1
Figure 2.1 - TIA Portal Function Block Diagram (FBD) PLC Programming | Boolean algebra in Network 1

To model this equation, we will use bit logic operations only. Open the “Bit logic operations” folder in the basic instructions section. Here, you will find all the usual boolean instructions such as AND/OR operators, affectation, set, reset…etc.

Figure 2.2 - TIA Portal Function Block Diagram (FBD) PLC Programming | Bit logic operations
Figure 2.2 - TIA Portal Function Block Diagram (FBD) PLC Programming | Bit logic operations

Let’s start by adding an OR operator. Select the OR operator ( >=1 ) in the instruction list and drag it to the workspace.

Figure 2.3 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an OR function block
Figure 2.3 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an OR function block

The OR function block appears in the workspace. It contains two inputs on the left, where you specify boolean tags/elements, and an output containing the logic result of the operation.

Figure 2.4 - TIA Portal Function Block Diagram (FBD) PLC Programming | OR Function block
Figure 2.4 - TIA Portal Function Block Diagram (FBD) PLC Programming | OR Function block

After that, create two boolean inputs in the interface (A and B) that we will use in the block to model the A + B part of the equation.

Figure 2.5 - TIA Portal Function Block Diagram (FBD) PLC Programming | Creating interface inputs
Figure 2.5 - TIA Portal Function Block Diagram (FBD) PLC Programming | Creating interface inputs

Once done, add these inputs to the block, as shown in the following figure.

Figure 2.6 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding the inputs to the block
Figure 2.6 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding the inputs to the block

Now, repeat this operation to create the C +D part. To do this, create two more Boolean inputs in the interface (C and D) and add them to a second OR function block.

Figure 2.7 - TIA Portal Function Block Diagram (FBD) PLC Programming | Creating a second OR block
Figure 2.7 - TIA Portal Function Block Diagram (FBD) PLC Programming | Creating a second OR block

We now have the two OR parts. The next part is to connect both result outputs of these blocks to an AND function block. Select an AND operation (&) in the instructions section and drag it to the output of the first OR block.

Figure 2.8 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an AND block
Figure 2.8 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an AND block

The AND block is added to the workspace with its first input connected to the output of the first OR block. However, as you can notice, it is not connected to the second OR block.

Figure 2.9 - TIA Portal Function Block Diagram (FBD) PLC Programming | AND block is created
Figure 2.9 - TIA Portal Function Block Diagram (FBD) PLC Programming | AND block is created

To connect the second OR block to the AND block, select its output and drag it to the second input of the AND block.

Figure 2.10 - TIA Portal Function Block Diagram (FBD) PLC Programming | Connecting the second OR block to the AND block
Figure 2.10 - TIA Portal Function Block Diagram (FBD) PLC Programming | Connecting the second OR block to the AND block

The second OR block becomes connected to the AND block.

Figure 2.11 - TIA Portal Function Block Diagram (FBD) PLC Programming | The AND block is connected
Figure 2.11 - TIA Portal Function Block Diagram (FBD) PLC Programming | The AND block is connected

We have almost completed the construction of the equation; the last step is to retrieve the result at the output of the AND block. To do this, we have to add an affectation function block at the output of the AND block. Select the affectation function block (=) in the instructions and drag it to the AND block output.

Figure 2.12 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an affectation block
Figure 2.12 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an affectation block

The affectation function block appears in the workspace with its input directly connected to the AND block output. It lets us retrieve a logic result and put it in a tag or interface element.

Figure 2.13 - TIA Portal Function Block Diagram (FBD) PLC Programming | The affectation block is added
Figure 2.13 - TIA Portal Function Block Diagram (FBD) PLC Programming | The affectation block is added

After that, create a Boolean output (E) in the blocks interface and add it to the affectation block.

Figure 2.14 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding output to the affectation block
Figure 2.14 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding output to the affectation block

We have finished modeling the equation in FBD language. 

The last thing we will cover here is how to add inputs to blocks. In cases where you need more than two inputs in a block, each block has a small yellow star icon that allows you to add multiple inputs to the block.

Figure 2.15 - TIA Portal Function Block Diagram (FBD) PLC Programming | Yellow star icons
Figure 2.15 - TIA Portal Function Block Diagram (FBD) PLC Programming | Yellow star icons

If you click on one of these icons, this will add an input to the block. Click on the yellow star icons on both OR  blocks.

Figure 2.16 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding blocks inputs
Figure 2.16 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding blocks inputs

Once done, create a new Boolean input (Flag) and add it to the newly created inputs.

Figure 2.17 - TIA Portal Function Block Diagram (FBD) PLC Programming | Filling the newly created inputs
Figure 2.17 - TIA Portal Function Block Diagram (FBD) PLC Programming | Filling the newly created inputs

Linear equation

Let’s move on now to the linear equation. Here, we will model a simple mathematical linear equation (Y = AX + B), which consists of a multiplication followed by an addition. For this, we will use Network 2.

Figure 3.1 - TIA Portal Function Block Diagram (FBD) PLC Programming | Linear equation in Network 2
Figure 3.1 - TIA Portal Function Block Diagram (FBD) PLC Programming | Linear equation in Network 2

For this application, we will use Math functions. You can find them in the “Math functions” folder in the basic instructions section.

Figure 3.2 - TIA Portal Function Block Diagram (FBD) PLC Programming | Math functions
Figure 3.2 - TIA Portal Function Block Diagram (FBD) PLC Programming | Math functions

We will first start by creating two integer elements in the interface: X as an input and Y as an output.

Figure 3.3 - TIA Portal Function Block Diagram (FBD) PLC Programming | Creating integer I/Os
Figure 3.3 - TIA Portal Function Block Diagram (FBD) PLC Programming | Creating integer I/Os

After that, add a multiplication (MUL) function block in the workspace by selecting it and dragging it.

Figure 3.4 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding a multiplication block
Figure 3.4 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding a multiplication block

This will add a multiplication block. It has two inputs (that can be extended) for the elements to multiply and an output for the result. It also has an EN and ENO I/Os used for the block execution sequencing.

Figure 3.5 - TIA Portal Function Block Diagram (FBD) PLC Programming | The multiplication block is created
Figure 3.5 - TIA Portal Function Block Diagram (FBD) PLC Programming | The multiplication block is created

Next, we need to add a function block. Select it in the instruction list and drag it to the ENO output of the multiplication block.

Figure 3.6 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an addition block
Figure 3.6 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an addition block

This will create an addition function block connected to the multiplication block through its EN input. As you can see, it is impossible to connect the result of the multiplication block directly to one of the inputs of the addition block. This is possible only with Boolean results. 

Figure 3.7 - TIA Portal Function Block Diagram (FBD) PLC Programming | The addition block is added
Figure 3.7 - TIA Portal Function Block Diagram (FBD) PLC Programming | The addition block is added

After that, we need to add I/Os to the blocks. Fill in the blocks’ I/Os as shown in the following figure.

Figure 3.8 - TIA Portal Function Block Diagram (FBD) PLC Programming | Filling the blocks
Figure 3.8 - TIA Portal Function Block Diagram (FBD) PLC Programming | Filling the blocks

The last thing we need to do is to communicate the multiplication result to the input of the addition block. To do this, we will use a temporary interface element that will serve as a bridge between the blocks. Create a temp element and add it to the output of the multiplication block and the input of the addition block.

Figure 3.9 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding a temp element as a bridge
Figure 3.9 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding a temp element as a bridge

And with this, the model of the equation is done.

Motor control

For this last section, we will program a small motor control application in Network 3.

Figure 4.1 - TIA Portal Function Block Diagram (FBD) PLC Programming | Motor control in Network 3
Figure 4.1 - TIA Portal Function Block Diagram (FBD) PLC Programming | Motor control in Network 3

We will base ourselves on the following program in LADDER to build its equivalent in FBD.

Figure 4.2 - TIA Portal Function Block Diagram (FBD) PLC Programming | Motor control in LADDER
Figure 4.2 - TIA Portal Function Block Diagram (FBD) PLC Programming | Motor control in LADDER

The two parallel branches (containing #Start and #Motor) translate to an OR operation. Next, the #Stop element is in series with the previous elements, translating to an AND operation. Then, the final result is affected by the #Motor element. So, to reproduce this program, we will need an OR operator, an AND operator, and an affectation.

Let’s start by adding an OR block. Select it (>=1) and drag it to the workspace.

Figure 4.3 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an OR block
Figure 4.3 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an OR block

After that, repeat the same step but, this time, add an AND operator and connect it to the output of the OR block.

Figure 4.4 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an AND block
Figure 4.4 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an AND block

Since the #Stop contact is normally closed, we need to invert the second input of the AND block. Select an “invert” instruction and drag it to the second input of the AND block.

Figure 4.5 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an inverted input
Figure 4.5 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an inverted input

The last block we need to add is an affectation block in the output of the AND block. select it and drag it to the output of the AND block.

Figure 4.6 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an affectation
Figure 4.6 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding an affectation

Now, you can create the I/Os we need (#Start, #Stop, and #Motor) in the interface as Booleans.

Figure 4.7 - TIA Portal Function Block Diagram (FBD) PLC Programming | Creating the interface I/Os
Figure 4.7 - TIA Portal Function Block Diagram (FBD) PLC Programming | Creating the interface I/Os

Once done, add them to the function blocks, as shown in the following figure.

Figure 4.8 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding the I/Os to the program
Figure 4.8 - TIA Portal Function Block Diagram (FBD) PLC Programming | Adding the I/Os to the program

And with this, we are done with the motor control program in FBD.

Conclusion

In this tutorial, you learned how to harness the power of Siemens' Function Block Diagram (FBD) language within the TIA Portal environment. You crafted three programs with step-by-step instructions: a boolean algebra equation, a linear mathematical equation, and a motor control application. These applications cover the most common operations performed using the FBD language. Following these hands-on exercises, you gained practical experience utilizing FBD's graphical approach to design and implement control logic.

The Function Block Diagram (FBD) language is a powerful tool for creating control logic in industrial automation. FBD empowers engineers to design, debug, and maintain control systems with enhanced clarity by offering a visual means of expressing complex algorithms. Function blocks representing various operations are interconnected to model intricate control behavior, enabling seamless implementation of mathematical calculations, timing operations, and logic control. With FBD, automation engineers can bridge the gap between complex algorithms and practical implementation, fostering efficiency and accuracy in industrial automation.