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 PID Programming in Siemens TIA Portal
Advanced

An Introduction to PID Programming in Siemens TIA Portal

Siemens
TIA Portal
Software Engineering

Introduction

In industrial automation, achieving precise and stable control of various processes is often a critical requirement. One common challenge is the need for effective regulation, especially in scenarios where maintaining a specific parameter such as temperature, pressure, or flow rate is essential. This is where Proportional-Integral-Derivative (PID) control comes into play. PID controllers are widely used to ensure that a system's output reaches and maintains a desired setpoint by continuously adjusting control inputs. However, configuring and programming PID controllers can be a complex task, demanding careful consideration of various factors.

Fortunately, Siemens' TIA Portal offers a comprehensive solution to simplify the implementation of PID control in your automation projects. Within TIA Portal, you'll find a ready-to-use PID function that streamlines the PID programming process. This integrated PID functionality allows you to efficiently set up and configure PID controllers for various applications, making your automation projects more efficient and precise

In this tutorial, you will learn how to set up and program PID control using TIA Portal. We will begin by creating a new project and exploring the necessary organizational blocks for PID control. Then, we'll dive into the configuration of the PID controller, covering fundamental settings such as controller type, input/output parameters, process value settings, and advanced settings. Finally, we'll walk you through the final steps of programming, including the creation of PLC tags and their integration into the PID control instruction. 

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.

PID programming setup

Start by creating a new TIA Porta project using your chosen 1200 or 1500 CPU. Here, we will be using a 1511-1 PN CPU. Once done, click on “Add new block” in the program blocks section of the project tree.

Figure 3.1 - Siemens TIA Portal PLC PID Programming | New TIA Portal project
Figure 3.1 - Siemens TIA Portal PLC PID Programming | New TIA Portal project

In the case of PID applications, we need the regulation to be executed constantly and regularly. For this, we use “Cycle interrupts” Organization Blocks. This type of OB is called and executed at a set frequency, interrupting any other current execution.

On the “Add new block” window, select “Organization block”, select “Cycle interrupt”, give the block a name, and click on “OK”.

By default, the cycle time is set at 100,000 µs (Executed each second). We will keep this value but don’t hesitate to change this value to adapt to your actual system.

Figure 3.2 - Siemens TIA Portal PLC PID Programming | Creating a new cycle interrupt OB
Figure 3.2 - Siemens TIA Portal PLC PID Programming | Creating a new cycle interrupt OB

Once the block is created, we come to its programming interface where we will add PID instructions.

Figure 3.3 - Siemens TIA Portal PLC PID Programming | Cycle interrupt OB
Figure 3.3 - Siemens TIA Portal PLC PID Programming | Cycle interrupt OB

You can find these instructions in the instruction section by opening the “Technology” part. Inside the “PID control” folder, you will find a “Compact PID” subfolder containing three types of instructions: 

  • PID_Compact: Universal instruction used to program any type of PID application.
  • PID_3Step: Instruction adapted to 3-valve regulation applications.
  • PID_Temp: instruction adapted to temperature regulations applications (heating and cooling).
Figure 3.4 - Siemens TIA Portal PLC PID Programming | Compact PID instructions
Figure 3.4 - Siemens TIA Portal PLC PID Programming | Compact PID instructions

For this tutorial, we will showcase the PID_Compact instruction for its universal nature. Select a “PID_Compact” instruction and drag it to the first network. 

Figure 3.5 - Siemens TIA Portal PLC PID Programming | Adding a PID_Compact instruction
Figure 3.5 - Siemens TIA Portal PLC PID Programming | Adding a PID_Compact instruction

You will be asked to create an instance DB associated with the PID_Compact instruction. Then, click on “OK”.

Figure 3.6 - Siemens TIA Portal PLC PID Programming | PID_Compact instance DB
Figure 3.6 - Siemens TIA Portal PLC PID Programming | PID_Compact instance DB

Once done, the PID_Compact instruction will appear in the workspace. In short, there are three main interface elements: Setpoint, Input, and Output. You can notice that there are two types of inputs (Inpus and Input_PER) and three types of outputs (Output, Output_PER, and Output_PWM). You can only use one type of Input and one type of Output. Not all of them at once. You can define which input and output to use in the PID configuration.

  • Setpoint: Setpoint input of the regulation.
  • Input: Actual process input value (Already scaled).
  • Input_PE: Peripheral process input coming directly from the analog input of the sensor (Not scaled).
  • Output: Actual process output value (Already scaled).
  • Output_PER: Peripheral process output coming directly from the analog output (Not scaled).
  • Output_PWM: Output used in PWM mode.
  • State, Error, and ErrorBits: Monitoring and diagnostics outputs.
Figure 3.7 - Siemens TIA Portal PLC PID Programming | PID_Compact instruction
Figure 3.7 - Siemens TIA Portal PLC PID Programming | PID_Compact instruction

Input and Output are used when you are working with already scaled values. Input_PER and output_PER are used when you want to work with the analog data directly from the analog inputs and outputs.

PID configuration

We are done setting up the PID instruction, we can head now to the configuring. Open the “Technology objects” section in the project tree. You will notice that a PID_Compact section has been created. Here, you can access the PID’s configuration and commissioning sections. 

Figure 4.1 - Siemens TIA Portal PLC PID Programming | PID section in the Technology objects
Figure 4.1 - Siemens TIA Portal PLC PID Programming | PID section in the Technology objects

In this tutorial, we will focus exclusively on the configuration side. The Commissioning part will be covered in the PID tuning tutorial.

Open the “Configuration” in the PID_Compact section. 

Basic settings

The first section of the basic settings is the controller type. Here, you can define which physical quantity will be regulated (Temperature, pressure, flow… etc.), which unit to use, and the PID’s operating mode.

Figure 4.2 - Siemens TIA Portal PLC PID Programming | Controller type
Figure 4.2 - Siemens TIA Portal PLC PID Programming | Controller type

In our case, we will pretend that we want to regulate pressure (In bars) Open the quantities list and select “Pressure”.

Figure 4.3 - Siemens TIA Portal PLC PID Programming | Setting the quantity type
Figure 4.3 - Siemens TIA Portal PLC PID Programming | Setting the quantity type

Next, select “bar” as the unit.

Figure 4.4 - Siemens TIA Portal PLC PID Programming | Setting the unit
Figure 4.4 - Siemens TIA Portal PLC PID Programming | Setting the unit

In an actual process situation, we want the PID to work automatically. For this, select “Automatic mode” in the “Set mode to” section.

Figure 4.5 - Siemens TIA Portal PLC PID Programming | Setting the PID operating mode
Figure 4.5 - Siemens TIA Portal PLC PID Programming | Setting the PID operating mode

The controller type configuration is now complete.

Figure 4.6 - Siemens TIA Portal PLC PID Programming | Complete controller configuration
Figure 4.6 - Siemens TIA Portal PLC PID Programming | Complete controller configuration

Now, let’s head to the next section of the basic settings; The Input/output parameters. Here, you can define which type of Input and Output to use (From the ones covered previously). By default, the parameters are set to the PER Input and Output.

Figure 4.7 - Siemens TIA Portal PLC PID Programming | Input/output parameters
Figure 4.7 - Siemens TIA Portal PLC PID Programming | Input/output parameters

We will consider that we are working with actual values in our system. We need to set the parameters to “Input” and “Output”. Open the Input section and select “Input”.

Figure 4.8 - Siemens TIA Portal PLC PID Programming | Setting the Input
Figure 4.8 - Siemens TIA Portal PLC PID Programming | Setting the Input

Then, select “Output” in the output section.

Figure 4.9 - Siemens TIA Portal PLC PID Programming | Setting the Output
Figure 4.9 - Siemens TIA Portal PLC PID Programming | Setting the Output

The Input/output parameters are now complete.

Figure 4.10 - Siemens TIA Portal PLC PID Programming | Complete I/O parameters
Figure 4.10 - Siemens TIA Portal PLC PID Programming | Complete I/O parameters

Process value settings

Let’s move on to the next section of the configuration; The process value settings. Here, you can define the process value limits and the process value scaling.

Open the “Process value limits” section. Here, you can define the maximum and minimum reachable process values. Typically, you would introduce your sensor’s measurement range. Here, we are considering that our sensor operates between 0 and 120 bars.

Figure 4.11 - Siemens TIA Portal PLC PID Programming | Process value limits
Figure 4.11 - Siemens TIA Portal PLC PID Programming | Process value limits

Next is the Process value scaling section. Here, you can define the scaling of the PER Input and Output as you would use the SCALE/UNSCALE functions with analog inputs and outputs. This section is enabled only when using a PER Input or Output. Since we are using regular Input and Output, This section is disabled. 

Figure 4.12 - Siemens TIA Portal PLC PID Programming | Disabled Process value scaling
Figure 4.12 - Siemens TIA Portal PLC PID Programming | Disabled Process value scaling

To enable this section, change the Input section of the Input/output parameters to “Input_PER” (You could also do the same for the Output)

Figure 4.13 - Siemens TIA Portal PLC PID Programming | Changing the Input type
Figure 4.13 - Siemens TIA Portal PLC PID Programming | Changing the Input type

If you come back to the Process value scaling section, you will find that it became enabled and you can edit the high and low values (works exactly the same as the SCALE/UNSCALE functions). 

Figure 4.14 - Siemens TIA Portal PLC PID Programming | Enabled Process value scaling
Figure 4.14 - Siemens TIA Portal PLC PID Programming | Enabled Process value scaling

Advanced settings

The last section of the PID configuration is the Advanced settings. First, open the “Process value monitoring” section. Here, you can define the warning limits of your process value for monitoring. For example, we set up the high limit to 100 bar and the low limit to 20 bar. If the process value exceeds the high limit, it will trigger a high limit warning. If the process value goes below the low limit, it will trigger a low limit warning.

Figure 4.15 - Siemens TIA Portal PLC PID Programming | Process value warnings
Figure 4.15 - Siemens TIA Portal PLC PID Programming | Process value warnings

Next is the PWM limits, Here, you can define the minimum and maximum ON/OFF times of the moduled pulse width.

Figure 4.16 - Siemens TIA Portal PLC PID Programming | PWM limits
Figure 4.16 - Siemens TIA Portal PLC PID Programming | PWM limits

After that is the “Output value limits” section. Here, you can define the maximum and minimum Output values. They are scaled as a percentage of the Process value.

Figure 4.17 - Siemens TIA Portal PLC PID Programming | Output value limits
Figure 4.17 - Siemens TIA Portal PLC PID Programming | Output value limits

The last section of the Advanced settings is the PID parameters. Here, you can define the Proportional, Integral, and Derivative parameters of your PID controller. By default, this section does not allow manual modifications.

Figure 4.18 - Siemens TIA Portal PLC PID Programming | Disabled PID parameters
Figure 4.18 - Siemens TIA Portal PLC PID Programming | Disabled PID parameters

To enable the manual editing, check the “Enable manual entry” checkbox. This will allow you to edit the P, I, and D parameters according to your specifications.

Figure 4.19 - Siemens TIA Portal PLC PID Programming | Enabled PID parameters
Figure 4.19 - Siemens TIA Portal PLC PID Programming | Enabled PID parameters

Finalizing the PID programming

We are done configuring the PID controller, we can head to the programming finalization. To do this, we will create PLC tags and introduce them in the PID_Compact instruction created earlier.

First, open the default tag table and create the following tags. Since we are using the regular Input and Output (with the actual values), be sure to define the data types as Reals.

Figure 5.1 - Siemens TIA Portal PLC PID Programming | PLC tags
Figure 5.1 - Siemens TIA Portal PLC PID Programming | PLC tags

Once done, add them to the PID_Compact instruction as shown in the following figure.

Figure 5.2 - Siemens TIA Portal PLC PID Programming | Complete PID_Compact instruction
Figure 5.2 - Siemens TIA Portal PLC PID Programming | Complete PID_Compact instruction

We have configured the PID controller with the Input and Output interfaces. These values are already scaled independently from the internal scaling of the instruction. The PID controller reads the Process value in the Input interface and corrects the Output interface according to the Setpoint.

Conclusion

In this tutorial, you learned how to set up and program PID control in Siemens' TIA Portal, simplifying a complex and critical aspect of industrial automation. We began by creating a new project, introducing cycle interrupt blocks, and exploring the PID function blocks available within TIA Portal. We then delved into the configuration process, covering controller type, input/output parameters, process value settings, and advanced settings. Finally, we concluded with the integration of PLC tags into the PID control instruction. Through these steps, you've gained the knowledge and skills needed to implement PID control effectively within the TIA Portal environment.

Integrating a PID compact in TIA Portal has proven to be remarkably straightforward and efficient. With its user-friendly interface and readily available function blocks, TIA Portal simplifies the setup of PID controllers in industrial projects. This integration streamlines the entire process, from initial configuration to real-time monitoring, empowering engineers and operators to achieve precise control and optimal performance in their industrial applications. As industries continue to demand enhanced automation and control capabilities, TIA Portal stands as a valuable tool in simplifying complex tasks like PID control, ultimately contributing to increased efficiency and productivity in industrial environments.

‍