15. Handy Instruction Design Examples
15.7 PID - Oven Temperature Control (Auto-tuning for PID Temperature Control)
z Execute auto-tuning function of PID instruction to control the temperature of the oven when the oven is in unknown temperature environment. The target temperature is 80℃.
z Apply DVP04PT-S temperature module for measuring the present temperature of the oven and transferring the results to PLC. The PLC will execute parameter auto-tuning function (D204 = K3) to operate the best PID parameters and automatically change the control direction as “Exclusively for the adjusted temperature control” (D204 = K4).
z PLC outputs the operation results (adjusted parameter) in D0 to the input of GPWM instruction. Y0 will output PWM pulses (width determined by D0) to control the heater and PID temperature control is accomplished.
D0
D20 Y0
Devices:
Device Function
M1 Executing PID instruction Y0 Outputting adjustable pulses D0 Storing PID operation result D10 Storing the target temperature D11 Storing the present temperature
D20 Storing pulse output cycle of GPWM instruction D200 Storing PID sampling time parameter
Control Program:
M1002
MOV
MOV K400 K4000
D200 D20 MOV
K800 D10
TO K0 K2 K2 K1
Set cycle time of GPWM instruction: 4s
Set sampling time: 4s Set target temp: 80 ℃
Set the average time of DVP04PT Channel 1:2 times
M0
M1
GPWM PID FROM
MOV
RST M0
D0 D10
K0
K3
D20 D11 K6
D204
D0 K1
Y0 D200
D11 M1013
Store PID operation result in D200
Sample PV of the oven every 1s and store it in D11 Set the control direction
as auto-tuning temperature
Program Description:
z Format of PID instruction:
PID S1 S2 S3 D
S1 → Set value (SV) S2 → Present value (PV)
S3 → Parameter (Users need to set and adjust it. For the definition, refer to PID parameter table in the last part of this example)
D → Output value (MV) (D has to be the data register area with latched function)
z There are a lot of circumstances where PID instruction can be applied; therefore, please choose the control functions appropriately. In this example, the parameter auto-tuning for temperature is only for the temperature control, users cannot use it in a speed or pressure control environment or errors could occur.
z Generally, adjusting control parameters of PID requires experience and repetitive tests.
(except the auto-tuning function in temperature control environment) The common parameter adjusting steps are as below:
Step 1: Set KI and KD as 0 and KP as 5, 10, 20 and 40. Record the SV and PV respectively and the results are as the figure below.
1.5
1
0.5
K =40P
K =20P K =10P
SV=1
K =5P
15. Handy Instruction Design Examples
DVP-PLC Application Examples 15-24
Step 2: From the figure, we can see that when KP = 40, there will be over-reaction, so we will not select it. When KP = 20, the PV reaction curve will be close to SV and there will not be over-reaction, but due to its fast start-up with big transient MV, we will consider to put it aside. When KP = 10, the PV reaction curve will get close to SV value more smoothly, so we will use it. Finally when KP = 5, we will not consider it due to the slow reaction.
Step 3: Select KP = 10 and adjust KI from small to big (e.g. 1, 2, 4 to 8). KI should not be bigger than KP. Adjust KD from small to big (e.g. 0.01, 0.05, 0.1 and 0.2). KD should not exceed 10% of KP. Finally we obtain the figure of PV and SV below.
1.5
1
0.5
00 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
PV=SV
K =10,K =8,K =0.2P I D
Time (sec)
Note: This example is only for your reference. Please adjust your parameters to proper ones according to your actual condition of the control system.
z In the temperature control environment, Delta PLC provides auto-tuning on parameters of PID instruction, so users can get good control results without parameter adjusting steps . See below for the auto-tuning process in this example:
1. Initial adjustment. Operate the most suitable parameter for PID temperature control and store the result in D200~D219. See the reaction curve below:
Auto tuning area S +4 = K3
PID control area S +4 = k43 3
2. Use the adjusted parameter in D200~D219 to control temperature. The curve becomes as below:
From the figure above, we can see that the temperature control after auto-tuning is working fine and we use only approximately 20 minutes for the control.
z PID sampling time should be set the same with the cycle time of GPWM instruction, but its unit is 10ms, which is different from the unit 1ms of GPWM instruction.
z Sampling time of PV should be set to 2 times more than the sampling time of PID, generally between 2s ~6s.
z PID parameter table of S3 for 16-bit instruction:
Device No. Function Range Explanation
: Sampling time (TS) (unit: 10ms)
1~2,000 (unit: 10ms)
If TS is less than 1 program scan time, PID instruction will be executed for 1 program scan time. If TS= 0, PID instruction will not be enabled. The minimum TS has to be longer than the program scan time.
+1: Proportional gain
(KP) 0~30,000 (%) +2: Integral gain (KI) 0~30,000 (%) +3: Differential gain
(KD) -3,000~30,000 (%)
If SV is bigger than the max. value, the output will be the max. value.
+4: Control direction (DIR)
0: automatic control
1: forward control (E = SV - PV) 2: inverse control (E = PV - SV)
3: Auto-tuning of parameter exclusively for the temperature control. The device will automatically become K4 when the auto-tuning is completed and be filled in with the appropriate parameter KP, KI and KD (not available in the 32-bit instruction).
4: Exclusively for the adjusted temperature control (not available in the 32-bit instruction).
5: automatic control(with upper/lower bounds of integral
15. Handy Instruction Design Examples
DVP-PLC Application Examples 15-26
+5:
The range that error value (E) doesn’t work
0~32,767 Ex: when S3 +5 is set as 5, MV of E between -5 and 5 will be 0.
+6: Upper bound of
output value (MV) -32,768~ 32,767
Ex: if S3 +6 is set as 1,000, the output will be 1,000 when MV is bigger than 1,000. S3 +6 has to be bigger or equal S3 +7; otherwise the upper bound and lower bound will switch.
+7: Lower bound of
output value (MV) -32,768~ 32,767 Ex: if S3 +7 is set as -1,000, the output will be -1,000 when MV is smaller than -1,000.
+8: Upper bound of
integral value -32,768~ 32,767
Ex: if S3 +8 is set as 1,000, the output will be 1,000 when the integral value is bigger than 1,000 and the integration will stop. S3 +8 has to be bigger or equal S3 +9; otherwise the upper bound and lower bound will switch.
+9: Lower bound of
integral value -32,768~ 32,767
Ex: if S3 +9 is set as -1,000, the output will be -1,000 when the integral value is smaller than -1,000 and the integration will stop.
+10,11: Accumulated integral value
32-bit floating point
The accumulated integral value is only for reference. You can still clear or modify it (in 32-bit floating point) according to your need.
+12: The previous PV -
The previous PV is only for reference.
You can still modify it according to your need.
+13:
~
+19:
For system use only.
When parameter setting exceeds its range, the upper bound and lower bound will become the setting value. However, if the motion direction (DIR) exceeds the range, it will be set to 0.
The maximum error of sampling time TS = - (1 scan time + 1ms) ~ + (1 scan time).
When the error affects the output, please fix the scan time or execute PID instruction in the interruption subroutine of the timer.
PV of PID instruction has to be stable before the execution of PID instruction. If you are to extract the input value of DVP04AD/04DA/06XA/04PT/04TC for PID operation, please be aware of the A/D conversion time of these modules.