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 CFC [Control Flow Chart] PLC Programming in TIA Portal
Intermediate

An Introduction to CFC [Control Flow Chart] PLC Programming in TIA Portal

Siemens
TIA Portal
PLC Programming

Introduction

In modern industrial automation, the need for efficient and intuitive control logic programming has become increasingly crucial. Traditional text-based programming languages, while powerful, can be complex and challenging to visualize, especially for complex control strategies. This creates a significant problem for automation engineers, leading to longer development times, increased debugging efforts, and reduced overall productivity. To address these challenges, Siemens has introduced the Continuous Function Chart (CFC) language in their TIA Portal software, providing a graphical programming approach that allows engineers to design control logic visually using interconnected function blocks.

CFC, standing for Control Flow Chart, is a powerful graphical programming language that simplifies control logic design within Siemens' TIA Portal environment. It employs interconnected function blocks to visually represent the control flow, reminiscent of electronic or logic-based diagrams. By utilizing this visual approach, automation engineers can intuitively design intricate control strategies by arranging and linking these function blocks. Additionally, the CFC language enables the creation of multiple charts or sub-charts that can be interconnected, providing a modular and scalable approach to programming complex control systems. Together, these features make CFC a valuable tool for developing sophisticated control logic efficiently and with greater clarity.

In this tutorial, you will learn how to use the CFC language in Siemens' TIA Portal to program a simple motor control function. The tutorial will start by guiding you through creating a new project. Then you will then learn how to access and utilize the CFC charts section in the project tree to develop and manage CFC charts. Afterward, you will be shown how to integrate function blocks into the CFC chart, linking the inputs and outputs to the relevant tags. Finally, you will compile the chart's organization blocks and use a simulation instance to test the motor control program's execution, verifying that the motors respond correctly to the input signals.

Prerequisites

To follow this tutorial, you will need an installation of TIA Portal and CFC. PLCSim Advanced is optional and can be replaced with the regular TIA Portal’s PLCSim. We will be using the latest versions to date, but you can use any other version. No additional hardware or software is required.

The CFC language in TIA Portal

Let’s start by creating a new project. After that, add a CPU of your choice. Here we will be using a 1511 CPU. If you installed CFC (with its licenses), you will find a “Charts” section in your project tree where you can create and manage CFC charts. Double-click on “Add new chart.”

Figure 1.1: Control Flow Chart PLC programming in TIA Portal | Creating a new project and accessing the CFC charts
Figure 1.1: Control Flow Chart PLC programming in TIA Portal | Creating a new project and accessing the CFC charts

Figure 1.1: Creating a new project and accessing the CFC charts.

CFC is a graphical programming language. It uses interconnected function blocks to represent control logic visually. The charts' visual style is similar to electronic or logic-based diagrams. You can design complex control strategies intuitively by arranging and linking these blocks. Also, you can create multiple charts or sub-charts and connect them.

The CFC interface consists of five parts:

  1. Inputs zone: All inputs of your program will be placed in this zone. You can link them from here to other blocks.
  2.  Workspace: Space where you put and link blocks.
  3. Output zone: All program outputs will be placed in this zone. You can link them from here to other blocks.
  4. Chart interface: Here you can define the chart’s interface (inputs, outputs…etc).
  5. Instructions: List of the instructions you can use with the CFC language.
Figure 1.2: Control Flow Chart PLC programming in TIA Portal | CFC chart working interface
Figure 1.2: Control Flow Chart PLC programming in TIA Portal | CFC chart working interface

The instruction list contains all the tools you need for programming like any other language. The instruction set available in CFC is similar to the FBD set.

Figure 1.3: Control Flow Chart PLC programming in TIA Portal | CFC instructions
Figure 1.3: Control Flow Chart PLC programming in TIA Portal | CFC instructions

Before programming the CFC chart, let’s create an FB we will use inside it. Go to the “Program blocks” of the project tree and click on “Add new block”.

Figure 1.4: Control Flow Chart PLC programming in TIA Portal | Adding a new block
Figure 1.4: Control Flow Chart PLC programming in TIA Portal | Adding a new block

Select “Function block” and give a name to the block.

Figure 1.5: Control Flow Chart PLC programming in TIA Portal | Selecting “Function Block” and giving a name to the block
Figure 1.5: Control Flow Chart PLC programming in TIA Portal | Selecting “Function Block” and giving a name to the block

We will build a simple motor control function. This function will be used multiple times to control four motors. Create the following program.

Figure 1.6: Control Flow Chart PLC programming in TIA Portal | Creating the FB program
Figure 1.6: Control Flow Chart PLC programming in TIA Portal | Creating the FB program

Then, add the following inputs/outputs in the FB interface and add them to the program as follows.

Figure 1.7: Control Flow Chart PLC programming in TIA Portal | Setting the inputs/outputs of the FB
Figure 1.7: Control Flow Chart PLC programming in TIA Portal | Setting the inputs/outputs of the FB

After that, we need to define the tags for the four motors. Open the default tag table in the project tree.

Figure 1.8: Control Flow Chart PLC programming in TIA Portal | Accessing the PLC tags
Figure 1.8: Control Flow Chart PLC programming in TIA Portal | Accessing the PLC tags

And create the following tags.

Figure 1.9: Control Flow Chart PLC programming in TIA Portal | Creating the tags of motor 1
Figure 1.9: Control Flow Chart PLC programming in TIA Portal | Creating the tags of motor 1

We create the first’s motor tags, we can duplicate them to create the three others automatically. Select the tags, then, click on the bottom left corner of the selection and drag down nine lines.

Figure 1.10: Control Flow Chart PLC programming in TIA Portal | Selecting the tags
Figure 1.10: Control Flow Chart PLC programming in TIA Portal | Selecting the tags

You should obtain a tag list complete with the right numbers as shown below.

Figure 1.11: Control Flow Chart PLC programming in TIA Portal | Creating the tags of the remaining motors
Figure 1.11: Control Flow Chart PLC programming in TIA Portal | Creating the tags of the remaining motors

We have now the tags we need for the four motors. Go back now to the CFC chart and select the “Motor control” FB in the project tree and drag it to the workspace.

Figure 1.12: Control Flow Chart PLC programming in TIA Portal | Adding the FB to the CFC chart
Figure 1.12: Control Flow Chart PLC programming in TIA Portal | Adding the FB to the CFC chart

The block should appear inside the chart. As you can notice, the block has the two inputs and the output we created in its interface (Motor start, Motor stop, and Motor). It also has an instance DB created automatically.

Figure 1.13: Control Flow Chart PLC programming in TIA Portal | FB call and instance DB
Figure 1.13: Control Flow Chart PLC programming in TIA Portal | FB call and instance DB

To add tags to the I/Os, drag and drop them from another section or right-click on it and select “Interconnection to operand.”

Figure 1.14: Control Flow Chart PLC programming in TIA Portal | Adding the tags
Figure 1.14: Control Flow Chart PLC programming in TIA Portal | Adding the tags

A field appears where you can type the tag you want to add. By typing the beginning of the tag, it should appear in the list. Select “Start motor 1”.

Figure 1.15: Control Flow Chart PLC programming in TIA Portal | Adding the “Start motor 1” tag
Figure 1.15: Control Flow Chart PLC programming in TIA Portal | Adding the “Start motor 1” tag

The “Start motor 1” appears in the inputs zone, and it becomes linked to the FB’s input.

Figure 1.16: Control Flow Chart PLC programming in TIA Portal | The tag is added
Figure 1.16: Control Flow Chart PLC programming in TIA Portal | The tag is added

Repeat the same step to add the “Stop motor 1” tag to the Motor stop input of the FB.

Figure 1.17: Control Flow Chart PLC programming in TIA Portal | Adding the “Stop motor 1” tag
Figure 1.17: Control Flow Chart PLC programming in TIA Portal | Adding the “Stop motor 1” tag

And repeat them for the “Motor 1” output. This time, the tag will appear in the outputs zone.

Figure 1.18: Control Flow Chart PLC programming in TIA Portal | Adding the “Motor 1” tag
Figure 1.18: Control Flow Chart PLC programming in TIA Portal | Adding the “Motor 1” tag

You should obtain a block linked as follows. To create the other three blocks, we can copy this one and paste it three times. Select the FB and copy it.

Figure 1.19: Control Flow Chart PLC programming in TIA Portal | Completed FB
Figure 1.19: Control Flow Chart PLC programming in TIA Portal | Completed FB

And paste it three times to obtain three FBs, as shown below.

Figure 1.20: Control Flow Chart PLC programming in TIA Portal | Pasting three other blocks
Figure 1.20: Control Flow Chart PLC programming in TIA Portal | Pasting three other blocks

Then, add all the inputs as we did before to all FB blocks.

Figure 1.21: Control Flow Chart PLC programming in TIA Portal | Adding the inputs to the remaining blocks
Figure 1.21: Control Flow Chart PLC programming in TIA Portal | Adding the inputs to the remaining blocks

And do the same for the outputs.

Figure 1.22: Control Flow Chart PLC programming in TIA Portal | Adding the outputs to the remaining blocks
Figure 1.22: Control Flow Chart PLC programming in TIA Portal | Adding the outputs to the remaining blocks

The program is now done. Click the “Compile” button to generate the chart’s Organization blocks. These blocks will contain the program in the CFC charts and will be executed here.

Figure 1.23: Control Flow Chart PLC programming in TIA Portal | Compiling and generating the CFC Organization blocks
Figure 1.23: Control Flow Chart PLC programming in TIA Portal | Compiling and generating the CFC Organization blocks

You can create a simulation instance to test the program’s execution. Here we’ll be using a PLCSim Advanced instance, but you can use a regular PLCSim instance instead. Create the instance and load the program into it.

Figure 1.24: Control Flow Chart PLC programming in TIA Portal | Creating a simulation instance
Figure 1.24: Control Flow Chart PLC programming in TIA Portal | Creating a simulation instance

We will use a watch table containing all the tags we used for the testing. Create the following watch table.

Figure 1.25: Control Flow Chart PLC programming in TIA Portal | Creating the watch table
Figure 1.25: Control Flow Chart PLC programming in TIA Portal | Creating the watch table

Run the watch table in visualization mode and change the tags’ values as shown below.

Figure 1.26: Control Flow Chart PLC programming in TIA Portal | Testing the motors
Figure 1.26: Control Flow Chart PLC programming in TIA Portal | Testing the motors

As you can see, all motors work as intended. Changing the value of the “Start motor” tags to 1 does turn on its associated motor. Doing the same for the “Stop motor” tags but to 0 does turn off the motor.

Conclusion

In this tutorial, you learned how to utilize the Continuous Function Chart (CFC) language in Siemens' TIA Portal to create a simple yet effective motor control function—starting with the creation of a new project and accessing the CFC charts section to design control logic visually using interconnected function blocks. You learned how to define a custom function block for motor control, create tags for the motors, and integrate the function block into the CFC chart by linking inputs and outputs to relevant tags. We also covered the compilation of organization blocks and using a simulation instance to test the motor control program's execution. 

Adopting the Continuous Function Chart (CFC) language in Siemens' TIA Portal offers numerous benefits that significantly improve the efficiency and intuitiveness of programming for industrial automation. CFC simplifies complex strategies by providing a graphical representation of control logic, allowing engineers to design and understand control programs more easily. The interconnected function blocks in CFC enable modular and organized programming, enhancing code reusability and maintainability. With the straightforward interface and extensive instruction set, CFC empowers automation engineers to design sophisticated control strategies more intuitively, reducing development time and debugging efforts. Overall, CFC proves to be a powerful tool that not only accelerates the programming process but also enhances the overall productivity and quality of industrial automation projects.