# PID Control in SIEMENS S7 PLC

## PID Control in SIEMENS S7 PLC

First we should know about Proportional-Integral-Derivative (PID) control is the most common control algorithm used in industry and has been universally accepted in industrial control. The popularity of PID controllers can be attributed partly to their robust performance in a wide range of operating conditions and partly to their functional simplicity, which allows engineers to operate them in a simple, straightforward manner. PID close Loop Control System
Now we will see the algorithm or equation of PID control. PID Control Equation

So in this fig we can see that PID controller is continuously calculating the error with respect to desired set point and actual process variable.
So in our PLC we have inbuilt PID control and its program block we don’t need to do extra programming we just use PID block. So before we start PID we will understand scaling for analog signal in PLC.
Analog signal is having standard 16 bit resolution for Input and Output for the PLC.
So every analog signal has standard range for measuring single for current and voltage.
Voltage Range : +- 10V
Current Range : 4 to 20ma
When PLC is taking analog signal from Sensors weather current or voltage form its converting in Digital Binary form between range 20 to 215. Total 16 bit and if we convert in decimal form then it would be as below range –  0 to 32768.
This value called as Raw Value for the PLC, but we need engineering value to understand the calibration and measurements.
Engineering Values means 0 to 100 ‘C. Temperature
0 to 10 bar Pressure
100 l/sec Flow Etc.
So we have to convert Raw value in engineering value and this procedure is called as SCALING in PLC for analog signal. And its ultimately linear graph for Engineering value Vs Raw Value.
So in S7-1200 PLC we are taking Norm X block and Scale X block for the scaling as below fig. Analog Scaling block in Siemen S7 1200  PLC
Iw64 is analog Inout and Mw20 is memory word after scaling where we will get output.
So here we have converted analog signal in our standard scaling range as per engineering value range.

This signal will work as feedback in PID block and it will compare set point and accordingly we will get output.
Now we will first take cyclic OB 30 for program the PID block because cyclic OB has the highest priority as compared to other OB so PID control function will be faster and we will get output very quickly. Then we will assign addressing to all parameters as per given fig. PID Compact Block PID Compact Block
Give Set point address and analog ip in Input PER.
Manual Enable signal give any Digital IP address. For Ex I0.0
Manual Value – Give scaling output address from Main OB.
Assign Output address and Output PER address in 32 bit double world format.
Then go for commissioning by click on commissioning Button of PID block. Commissioning window for PID block

Select the controller Type –Temperature
PID Parameter / Integral Action Time- Minimum 1 sec
Then go for simulation window by clicking button from PID block.
Start Measurement and give the set point from the PID Compact Block , now vary the analog signal and you will get output response in Simulation window as well in PID Output.
So you can see there are different parameters in PID here you can set Controller type PID. Then process value limits and advanced settings like PWM limits, Process value monitoring, Output value limits and PID parameters. After assigning this parameters just download programming in PLC. Now we will go online and will open simulation window as per below image. Simulation window for PID block
Now start the measurement and tuning mode from this window and downside you can see graph for set point, scaled input and output once you start PID compact block by clicking on that button.
If you increase analog value above set point then output response in percentage will decrease and if you decrease analog value below set point then output response will increase in percentage. Same you will get in form of graph in simulation window as below for Set point , IP and OP signal.
If you want to bypass PID then enable manual mode by giving manual digital Ip then you can get output signal response irrespective of analog signal.
We have PID Block from where we can implement PID for control the set point.
First of all make scaling in Main OB1 for manual or Open loop control.
Then take Cyclic OB30 and Take PID compact block as below.
Give Set point address and analog ip in Input PER.
Manual Enable signal give any Digital IP address. For Ex I0.0
Manual Value – Give scaling output address from Main OB.
Assign Out put address and Output PER address in 32 bit double world format.
Then go for commissioning –
Select Controller Type- Here for Example we will take Temperature
PID Parameter / Integral Action Time- Minimum 1 sec
Then go for simulation window by clicking button from PID block.
Start Measurement and give the set point from the PID Compact Block , now vary the analog signal and you will get output response in Simulation window as well in PID Output.
If you increase analog value above set point then output response in percentage will decrease and if you decrease analog value below set point then output response will increase in percentage.
Same you will get in form of graph in simulation window as below for Set point , IP and OP signal.

If you want to bypass PID then enable manual mode by giving manual digital Ip then you can get output signal response irrespective of analog signal.

Check Following Video Demostration: