Indian Journal of Science and Technology, Vol 8(35), DOI: 10.17485/ijst/2015/v8i35/82262, December 2015 ISSN (Print) : 0974-6846 ISSN (Online) : 0974-5645 Concept and Application of PID Control and Implementation of Continuous PID Controller in Siemens PLCs Babak Rooholahi* and P. Lokender Reddy Department of Electrical Engineering, University College of Engineering, Osmania University, Hyderabad - 500007, Telangana, India; babakroohollahi@gmail.com; lokenderreddyp@gmail.com Abstract Background/Objectives: The main objectives are to define the concept and application of PID control in parallel structure of PID controller and to describe implementation of the continuous PID controller in SIMATIC STEP 7. Methods/Statistical Analysis: Various designs of PID controllers in SIMATIC STEP 7 are available for different kinds of feedback control systems. Parallel structure is used in the algorithm of PID controllers in Siemens PLCs. In this study PID controller with the continuous control function block FB41 (CONT_C) is analyzed. Programming with PID controller in Siemens PLCs with continuous Manipulated Variable output and the option of influencing the Manipulated Value manually is thoroughly discussed. Findings: PID controller is the most common form of feedback control and it can be found in all the areas where control loops exist. The simplicity of understanding of the PID algorithm is one of its advantages but due to a wide range of systems and different manufacturers of control systems with various design and tuning methods of PID controllers in their products, the implementation process gets complicated. This difficulty is reduced by using several kinds of PID controllers for different types of systems in Siemens control systems. FB41 is a function block of continuous PID controller which was designed for Siemens PLCs to provide control performance with analog signals; it can function both in a manual and automatic mode.The most important part of FB41 functioning is addressing of the analog Input and Output in this function block. The results of P, I, D, PI, PD and PID controller implementation in FB41 have been compared. Applications/ Improvements: This continuous control function block can be used in different kinds of control loop systems where ­analog input is sensed and analog output is required. Keywords: Analog Signal, Continuous PID Controller, Control System, FB41 (CONT_C), Feedback Control, Siemens PLCs 1. Introduction A control system is a combination of components which senses, manages and regulates the behavior of another system to produce the desired output. Automation is the process where different methods or control systems are used to manage a process. In industrial control, Programmable Logic Controller (PLC) has the extremely wide range of applications. PLC and PLC based controllers are the most important and useful control systems. Since these successful and beneficial control systems are produced, the PID control methodology has been extensively studied by researchers and well understood *Author for correspondence by practitioners. Most of PID controllers have been ­developed on the state-space model with this assumption that all state variables are measurable or on the inputoutput model for a linear system1. PID controllers have been widely used in many industrial processes because they have only three control parameters and we can easily understand their physical meanings. There are many classical techniques for designing and tuning PID controller parameters (KP, KI, KD) which can be easily understood and applied2,3. By adjusting these three gain values, the settling time, overshoot and rise time of the system can be controlled in order to obtain a desired system output. Even though many control systems using PID control have Concept and Application of PID Control and Implementation of Continuous PID Controller in Siemens PLCs proved satisfactory, it still has a wide range of ­applications in industrial control4. PID controllers in Siemens PLCs are exclusively ­professional. They are distinguished by their classification for using in different kinds of control systems. In step 7 Siemens PLC programming software different function blocks of PID are designed for various kinds of systems. These function blocks are compatible with their own control systems. In the following parts of this paper continuous PID control with FB41 (CONT_C) function block, its implementation and performance will be ­discussed. 2. Control System Control systems are used to minimize the consequences of process variations and environmental influences on the quality of process control. Sometimes these variations and influences are so significant that the conventional linear controllers with constant parameters fail to perform successfully. The primary functions of controllers are controlling equipment or machines and maintaining stability of their performances5. Among different brands of control systems, Siemens control systems being professional have an essential role in this industry. There are different kinds of industrial control systems and one of them is Programmable Logic Controller (PLC). Improvements of microelectronics and application of mathematical methods in control theory contributed to control systems development. One of these modern control techniques and mathematical based control methods is Advanced Process Control (APC) technique which is used in control systems and offered by all the PLC manufacturers.To increase the process capacity, efficiency, quality of products and costs savings in APC technique different kinds of tools for self-tuning, manufacturing costs and energy savings optimizationare designed. While some of the APC techniques are installed directly in the PLC, most of them are implemented as supervisory functions on higher level of the control system6. Due to the usage of APC and microelectronics in PLCs many components, which were applied in relay logic systems are out of use now and are replaced by function block diagrams in PLCs. in a process produce the output. In closed loop control system which is also called a feedback control system the output is analyzed and corrected based on feedback. Feedback is a process in which the past information influences the present or future. In a feedback control system information about performance is measured by sensors. The comparison of this information with setpoint is used in control algorithms to control the actuators and correct the performance of the system. 3. PID Control PID controllers which are applied in around 90% of industrial loops are the most often used controllers. It is beneficial because of their simplicity, robust nature, ease of implementation and design and less number of tuning parameters7,8. P, I and D are three parameters which have to be tuned manually or by some tuning techniques to design a PID controller. The proportional value defines the reaction of the current error, the integral value defines the reaction based on the sum of recent errors and the derivative value defines the reaction based on the rate at which the error has been changing the weighted sum of these three actions that is used to adjust the process via the final control element9. Due to successful implementation, wide accessibility and use of intelligibility PID control became an essential tool to control difficult processes. PID controller controls the process successfully even with the increased ­complexity10. These values have been adjusted in order to achieve a desired constant output from the system. The PID controller algorithm that operates as a position algorithm is shown in Figure 1. The PID algorithm can function under three basic modes, the Proportional mode, Integral mode and the Derivative mode. It is necessary to determine which 2.1 Feedback Control System Control systems are classified into two main types: open loop and closed loop. In open loop control system inputs 2 Vol 8(35) December 2015 | www.indjst.org Figure 1. PID controller Indian Journal of Science and Technology Babak Rooholahi and P. Lokender Reddy controller has to be used for the process, before ­applying the algorithm in the system11. Then the parameters or settings which are used for each mode can be finalized11. Sometimes only one or two parameters should be used to obtain the proper system control which can be achieved by deactivating the other parameters (setting them to zero); in these cases it will be a P, I, PI, PD and PID ­controller. The Process Variable (PV) is measured by the sensors from the field; the desired value is called SetPoint (SP) and determined manually set by the operator; the input to the process and the output of the PID controller are called Manipulated Variable (MV), Control Variable (CV) or control signal u (t); the difference between the Process Variable (PV) and the SetPoint (SP) is the error (e(t)) that is continuously calculated by a PID controller. PID controller by adjusting the error itself, integral of the error and the derivative of the error as Control Variable (CV) tries to minimize the error. 3.1 Standard Structures of PID Controllers Parallel structure, three-term functionality and a typical structure of a PID control system are shown in Figure 2. A mathematical description of the PID controller is shown in the following Equations (1, 2): ∫ (1) or t u (t ) = K P e (t ) + K I e (t ) dt + K D de (t ) ∫ 0 dt , • Rise time – the time it takes for the Process Variable (PV) to rise above 90% of the SetPoint (SP) for the first time, • Overshoot – the maximum swing above the SetPoint (SP), • Settling time – the time it takes for the Process Variable (PV) to settle to its steady state, • Steady-state error – the difference between the ­steady-state variable and the SetPoint (SP). By tuning the PID gain values, these characteristics can be controlled and optimized to achieve a desired ­system output. The Laplace transfer function of a PID controller is expressed in the Equation 3: GPID ( s ) = U (s ) 1 = K P 1 + + TD s , E (s ) TI s (3) Where U(s) is the control signal, E(s) is the error signal, s is the variable of Laplace transfer function, KP is the proportional gain, TI and TD are the integral and derivative time constants respectively. The PID control signal is a sum of three terms 4: U ( s ) = K P E ( s ) + K I 1 E ( s ) + K D sE ( s ) = U P ( s ) + U I ( s ) + U D ( s ) ,(4) s t de (t ) 1 , u (t ) = K P e ( t ) + e (t ) dt + TD dt TI 0 Four main features of the closed-loop step response are: (2) where u(t) is the control signal and e(t) is the error signal. The reference value is called the SetPoint. The difference between the Process Variable (PV) and the SetPoint (SP) is the error signal e(t) : e(t) = PV– SP4. , Kp, KI and KD are the proportional gain, the integral gain and the derivative gain respectively. Where K I = K P / TI (5) is the integral gain and K D = K PTD (6) is the d ­ erivative gain. The three-term functionalities include: 3.1.1 Proportional Term The proportional term provide an overall control action proportional to the error signal through the all pass gain factor. Increasing the proportional gain is the cause of decreasing the error and increasing the oscillation of the system. Tuning theory and practical implementation show that the proportional term should influence the output. 3.1.2 Integral Term Figure 2. A typical PID control structure. Vol 8(35) December 2015 | www.indjst.org The integral term reduces steady-state errors through ­low-frequency compensation. Integral term is proportional to the integral of the error. As it integrates the error over the time, it can cause the overshoot of present value to the SetPoint value. Indian Journal of Science and Technology 3 Concept and Application of PID Control and Implementation of Continuous PID Controller in Siemens PLCs 3.1.3 Derivative Term The derivative term improves transient response through high-frequency compensation. The rate of error changes is the contribution of the derivative term. It gives an additional control by predicting errors and future behavior of the system. Due to its variable impact on system stability, ­derivative action is rarely used in practice. The pure derivative action is never used because of the derivative kick produced in the control signal for a step input and to the undesirable noise amplification. It is usually replaced by a first-order low pass filter4,12. 3.2 Design and Tuning of PID Controller Designing and tuning of a PID controller is not easy when stability and short transient of the system are desirable. Repeated changes of initial designs through computer simulation need to be done to achieve a desired performance of the system. Control parameters (KP, KI or TI, KD, or TD) must be tuned jointly to the optimum values for the desired control response. Although there are individual effects of these three parameters on the closed loop performance of stable plants which are summarized in Table 1. For example, while KI and KD are fixed, increasing KP alone can rise time, increase overshoot, slightly increase settling time, decrease the steady-state error and decrease stability ­margins12. For manual tuning in online system one of the ­methods is first setting all gains to zero. Increase the KP value until the constant oscillation of the output is obtained, then the KP should be set to approximately half of that value for a quarter amplitude decay type response. After that increase KI to minimize the P term offset in a particular time for the process considering that too much KI can be a cause of instability. Finally, increase KD, if required, until the system becomes acceptably quick to reach the SetPoint and 4 Rise Time Overshoot Settling Steady- Time State Error Stability 4.1 Analog Signals Increasing Decrease KP Increase Small Increase Decrease Degrade Increasing Small KI Decrease Increase Increase Large Decrease Degrade Increasing Small KD Decrease Decrease Decrease Minor Change Improve Vol 8(35) December 2015 | www.indjst.org 4. PID Control in Siemens PLCs The Function Blocks (FBs) of the PID control ­package consist of controller blocks for Continuous Control FB41 (CONT_C), for step control FB42 (CONT_S), for Pulse Duration Modulation FB43 (PULSEGEN), for continuous temperature control FB58 (TCONT_CP) and for temperature step control FB59 (TCONT_S). A controller created with the FBs consists of a series of sub functions that you can activate or deactivate. Apart from the actual controller with its PID algorithm, integrated functions can also be used for processing the setpoint, process variable and adapting the calculated manipulated variable. Both slow processes (temperatures, tank levels etc.) and very fast processes (flow rate, motor speed etc.) can be controlled without any restrictionin terms of the type of process. Good control quality can be achieved only if the controller type suits your situation and adapts it to the time response of the process13. Table 1. Effects of independent P, I and D tuning on closed-loop response. Parameter decrease the oscillation. However, too much KD will lead to overshoot in the system. A quick PID controller loop normally has a little overshoots to achieve the desired value very fast; but in some systems cannot receive overshoot. In these systems a KP should be set remarkably less than half of the KP setting which provoked oscillation, to make over-damped in the closed-loop system. Design and tuning of the controller and selecting of its static (P component) and dynamic (I and D component) parameters are dependent on the static behavior (gain) and the dynamic characteristics (time lag, dead time, reset time etc.) of the process13. Different methods of PID controller design and tuning are applied for ­different types of continuous systems. The modified auto-tuning PID controller was ­implemented in a SIEMENS PLC, product family SIMATIC S7-300 and S7-400. FB50 is a PID Self Tuner in Step 7 TunPID Library by Siemens which can be used for tuning parameters of PI/PID regulators in function blocks FB41, FB42, software packages Standard PID Control, Modular PID control and function modules FM 355C6. Continuous signals have an infinite number of states. These variable signals received from different filed devices (sensors) need to be converted to digital signals by an Analog to Digital converter (A/D) before CPU ­processing. This Indian Journal of Science and Technology Babak Rooholahi and P. Lokender Reddy digitization is performed inside an analog input interface within the Input/Output (I/O) module. The analog device’s current output is often transformed to a voltage by a built‐in resistor. A common standard used in representing analog signals is when 4mA corresponds to the minimum signal level (1V) and 20mA the maximum (5V). Digitized values corresponding to the continuous values between 1‐5V are rated by the PLC’s CPU, values ranging above or below are discarded by the CPU. A value < 0,296V is used for detecting cable failure. Table 2 shows Siemens STEP7 format14,15. The CPU makes decisions and executes control instructions based on program instructions in memory to determine what the PLC will do for a specific input. Control instructions from the CPU are converted into a Digital or Analog signals by output modules to control different field devices (actuators). This data transformation is performed by a Digital‐to‐Analog (D/A) converter. It is the exact opposite of the transformation in an analog input interface. An analog output interface within the I/O module is used to address devices controlled by a ­continuous voltage or current. 4.2 Continuous PID Control with FB41 “CONT_C” FB41 (CONT_C) is used to implement the PID ­controller with continuous analog input and output on SIMATIC Table 2. SIMATIC STEP7 format, measuring range 1‐5V. Measuring range 1-5 V Decimal (value seen from the CPU Point of view) Range >5,704 32767 Overflow 5,704 . . 5,00014 32511 . . 27649 Over range 5,000 4,000 . . 1,000 27648 20736 . . 0 Rated range (normal operation range) 0,99986 . . 0,296 -1 . . -4864 Undershoot range <0,296 -32768 Underflow Vol 8(35) December 2015 | www.indjst.org STEP7. By activating or deactivating the PID parameters and process variable and adjusting the proper value for it, the desired PID controller for different kinds of systems can be set. Apart from this capability, there is an option for FB41 to provide continuous manipulated variable output in PID controller process ormanually forcing the ­manipulated value by the operator13,16. The FB41 (CONT_C) block ­diagram, input default mode, number, name and description of each parameter are shown in Figure 3. 4.2.1 Process Variable Section The Process Variable can be given in PV_IN manually to the PID controller when PVPER_ON is in default mode (deactivated). If PVPER_ON is set, the Process Variable must be read from the PV_PER which is connected to peripheral I/O. The choice between Process Variable IN (PV_IN) and Process Variable Peripheral (PV_PER) is determined by PVPER_ON. The function which converts the PV_PER to the floating-point format of -100 to +100 % is CRP_IN and it has calculated by 7: Output of CRP_IN = PV_PER ∗ 100 27648 (7) The output of CRP_IN is normalizedby the following formula ): Output of PV_NORM = (output of CRP_IN) * PV_FAC + PV_OFF (8) PV_FAC and PV_OFF are initiallyset to 1 and 0 respectively. 4.2. Manipulated Value Section It is possible to switch over between Manual and Automatic Mode (MAN and Manipulated Value (LMN)) by setting/ resetting the Manual Value On (MAN_ON) (if it is set, the manual value is set as the output in manipulated value). In the manual mode, the Manipulated Variable (MV) is adjusted to a selected value manually. It means there are no any sudden changes in the Manipulated Value due to a switchover from the manual mode to the automatic mode. The Manipulated Value is always limited to an upper and lower limit (LMN_HLM and LMN_LLM). “High Limit of Manipulated Value Reached” or “Low Limit of Manipulated Value Reached” (QLMN_HLM and QLMN_LLM) indicate when the upper or lower limit of the Manipulated Value (LMN_HLM and LMN_LLM) has been exceeded. Indian Journal of Science and Technology 5 Concept and Application of PID Control and Implementation of Continuous PID Controller in Siemens PLCs Figure 3. Continuous PID control block FB41 (CONT_C). 6 Vol 8(35) December 2015 | www.indjst.org Indian Journal of Science and Technology Babak Rooholahi and P. Lokender Reddy LMNLIMIT can be normalized by LMN_NORM function according to the following formula 9: LMN = (output of LMNLIMIT) *LMN_FAC + LMN_OFF (9) LMN_FAC and LMN_OFF have the default 1 and 0 respectively. LMN_PER is the manipulated value in the peripheral format. It is converted from the floating-point value format (LMN) to the peripheral value format (LMN_PER) by the CRP_OUT function 10: LMN_PER = LMN ∗ 27648 100 (10) 4.3 Inputting/Outputting Analog Values in STEP 7 Integer and Real types of data have an important function in process analog signals for SIMATIC S7. Analog inputs are received as real numbers in the format INT for analog values processing. Because of rounding variables by INT, for an accurate further processing the REAL numbers are considered. Analog values are inputted as WORD with the integer (INT) data type format in the PLC. The address of these WORD values are accessible with the ­following instruction17: L PIW x T PQW x for ‘Load analog Input Word’ for ‘Transfer analog Output Word’ The addressing of the input/output WORDs depends on the start address of the module. For the module installed in slot 4 the default start address will be 256. For further analog modules default start address of each slot will increase by 16. This address can be checked in hardware configuration table for each slot. The address of the first analog input on slot 6 is PIW 288, the second analog input is PIW 290 and the first analog output is PQW 288 etc.17. 4.4 Case Study and Experimental Results The system consisting of PLC SIMATIC300 with CPU 315-2 PN/DP, digital inputs module DI SM321, digital outputs module DO SM322 and analog Input-Output modules AI/AO SM334 is used to evaluate PID controller in this study. STEP7 is the Siemens PLCs programming software; the Ethernet connection is the connection type between PC and PLC which is provided by this PLC model. Vol 8(35) December 2015 | www.indjst.org The first step of the programming in STEP7 is Hardware Configuration (HW Config). It is required to determine the hardware which consists of power supply, PLC CPU model number, all the modules used in the control system and the network connection type between PC and PLC in HW Config. The programming will start by opening the first Operation Block (OB1) in the SIMATIC Manager window. The PID block FB41 CONT_C can be found in the program “elements libraries”. It is necessary to determine the proper addresses or correct values of 26 inputs and 9 ­outputs in PID block FB41 to implement it in the program. Addressing for each parameter of the block should include digital input, digital output, Memory Double word (MD) or Periphery Input and Output Word (PIW/ PQW) addresses. VAT (Variable Access Table) should be made to monitor the word format parameters and to put the addresses with their values, modify them in the RUN mode and specify the values of Display format. VAT can specify the address of each value and display the Status Value and Modify Value as it is shown in Figure 4. Figure 5 shows the performance of P controller in online mode where PV_PER is received from the field and PVPER_ON is set. Here. kp=1. Implementation of PID controlleris done by ­activating the P, I and D parameters. Figure 6 shows PID controller performance in offline mode where PVPER_ON is FALSE, MAN_ON is TRUE and PV_IN has the value of 20. Comparing the output of P, I, D, PI, PD and PID controllers and analysis of their response speed to the variation of process variable show that P controller has the minimum speed and very slow with the specific ­offset and I, PI, PD, PID and D controllers respectively have the minimum to maximum speed of response to reach the maximum manipulated value: D > PID > PD > PI > I > P. Usually Proportional Integral (PI) controllers required to meeting the optimal response in linear systems and PID controllers are required to meet desired response in nonlinear systems18. 5. Discussion and Conclusions PID control remains a widely applicable and significant control technique due to successful implementation, simplicity in use and understanding. Combination of these reasons explain why PID control cannot be replaced by another higher order controllers. PID control advantages and successful results can be obtained by ­understanding Indian Journal of Science and Technology 7 Concept and Application of PID Control and Implementation of Continuous PID Controller in Siemens PLCs Figure 4. VAT (Variable Access Table). Figure 5. Performance of P controller in online mode. Figure 6. PID controller performance in offline. 8 Vol 8(35) December 2015 | www.indjst.org Indian Journal of Science and Technology Babak Rooholahi and P. Lokender Reddy the nature of a particular system and choosing the proper design and tuning of the PID controller. Tuning and design of PID control, which depend on the nature of each system, will vary according to the system characteristics. PID controllers in Siemens PLCs are very efficient and widely used in industry. They are also common in complicated and professional systems. PID controller in Siemens PLCs has different function blocks such as continuous control FB41 (CONT_C), step control FB42 (CONT_S), continuous temperature control FB58 (TCONT_CP) and temperature step control FB59 (TCONT_S) to control different kinds of systems. In this paper PID function block with continuous control FB41 (CONT_C) has been discussed as the major concept of PID controller function block in Siemens PLCs which can be used for all kinds of systems by implementing the correct design and tune. To implement FB41 specifying the proper addressing and correct values of 26 inputs and 9 outputs is essential. As the result of applying the standard structure of PID controller in Siemens PLCs by FB41 in online and offline mode, the speed of response to reach the maximum manipulated value has been studied. 6. References 1.Cho J, Kwag DG, Kim BS. Control of chaotic resonance phenomena using prototypes in manifold forms. Indian Journal of Science and Technology. 2015 Oct; 8(26):1–7. 2.Sabir MM, Khan JA. Optimal design of PID controller for the speed control of DC motor by using metaheuristic techniques. Advances in Artificial Neural Systems. 2014, 126317. 3.Namba R, Yamamoto T, Kaneda M. Robust PID controller and its application. Proceedings of the 1997 IEEE International Conference on Systems, Man and Cybernetics, Computational Cybernetics and Simulation; Orlando FL. 1997. p. 3636–41. 4.Xue D, Chen YQ, Atherton DP. Linear feedback control analysis and design with MATLAB. London, UK: SpringerVerlag; 2002. 5.Peric N, Branica I, Petrovic I. Modification and application of autotuning PID controller. Proceedings of the 8th IEEE Vol 8(35) December 2015 | www.indjst.org Mediterranean Conference on Control and Automation (MED 2000); Rio Patras, Greece. 2000 Jan. 6.Kocian J, Koziorek J. Self tuning techniques on PLC ­background and control systems with self tuning methods design. Advances in Electrical and Electronic Engineering. 2010 Jun; 8(2):40– 7. 7.Er MJ, Lei Y. Hybrid fuzzy proportional – integral plus conventional derivative control of linear and nonlinear systems. IEEE Transactions on Industrial Electronics. 2002 Jan; 48(6):1109–17. 8.Lakshmi Narayana K, Naveen Kumar V, Dhivya M, Prejila Raj R. Application of ant colony optimization in tuning a PID controller to a conical tank. Indian Journal of Science and Technology. 2015 Jan; 8(S2):217–23. 9.Sethuramalingam TK, Nagaraj B. PID controller tuning using soft computing methodologies for industrial process - A comparative approach. Indian Journal of Science and Technology. 2014; 7(S7):140–5. 10.Meena AR, Senthil Kumar S. Design of GA tuned two-degree freedom of PID controller for an interconnected three area automatic generation control system. Indian Journal of Science and Technology. 2015 Jun; 8(12):1–10. 11.Pamela D, Premi MSG. TCP/IP based control and automation of temperature process. Indian Journal of Science and Technology. 2015 Jun; 8(11):1–6. 12.Li Y, Ang KH, Chong GCY. PID control system analysis and design. IEEE Control Systems Magazine. 2006 Feb; 26(1):32–41. 13.Siemens, SIMATIC, Standard PID Control; 2003. p. 1–256. 14.Al Hadawi E. Development of a Continuous Blending System (Controlling a blending system). Division of Industrial Electrical Engineering and Automation (IEA): Lund University, Sweden; 2011. p. 1–60. 15.Siemens, SIMATIC, Distributed I/O System’ ET 200S, 2005. p. 1–274. 16.Training document for comprehensive automation solutions. Totally Integrated Automation (TIA), MODULE B3, Control Engineering with STEP 7; 2008. p. 1–64. 17.Training document for the company-wide automation solution. Totally Integrated Automation (TIA), MODULE B2, Analog value processing; 2002 p. 1–14. 18.Chakravarthi MK, Vinay PK, Venkatesan N. Design and simulation of internal model controller for a real time nonlinear process. Indian Journal of Science and Technology. 2015 Aug; 8(19):1–6. Indian Journal of Science and Technology 9