Manual Instrucao PID
Manual Instrucao PID
In this chapter, we mainly introduce the applications of PID instructions for XD, XL
series, including: call the instructions, set the parameters, items to notice, sample
programs etc.
7-1.PID Introduction
PID instruction and auto tune function are added into XD/XL series PLC basic units.
Via auto tune method, users can get the best sampling time and PID parameters and
improve the control precision.
PID instruction has brought many facilities to the users.
Output can be data form D, HD, and on-off quantity Y, user can choose them freely
when programming.
Via auto tune, users can get the best sampling time and PID parameters and improve
the control precision.
User can choose positive or negative action via software setting. Positive action is
used for heating control; negative action is used for cooling control.
PID control separates the basic units with the expansions, which improves the flexibility
of this function.
XD/XL series PLC have two methods for auto tune, step response method and critical
oscillation method.
For temperature control object:
Step response method: the PID auto tune will start when current temperature of object
controlled is equal to ambient temperature.
Critical oscillation method: the PID auto tune can start at any temperature.
7-2.Instruction Form
Brief Introduction of the Instructions
Execute PID control instructions with the data in specified registers.
PID control [PID]
16 bits PID 32 bits -
instruction instruction
277
Executing Normally ON/normally Suitable XD/XL
condition closed coil trigger models
Hardware - Software V3.2
requirement requirement
Operands
Operands Function Type
S1 set the address of the target value (SV) 16bits, BIN
S2 set the address of the tested value (PV) 16 bits, BIN
S3 set the start address of the control parameters 16 bits, BIN
D the address of the operation result (MV) or 16 bits, BIN; bit
output port
Suitable soft components
Operands System
Bit
X Y M* S* T* C* Dn.m
D ● ● ● ● ●
*Note: D includes D, HD; TD includes TD, HTD; CD includes CD, HCD, HSCD, HSD;
DM includes DM, DHM; DS includes DS, DHS.
M includes M, HM, SM; S includes S and HS; T includes T and HT; C includes C and
HC.
S3~ S3+ 69 will be occupied by this instruction, so please don’t use them as the
common data registers.
This instruction executes when each sampling time interval comes.
For the operation result, data registers are used to store PID output values; the output
points are used to output the occupy duty ratio in the form of ON/OFF.
PID control rules are shown as below:
P: proportion, I: integral, D: differential
278
+
P
r(t) + e(t) u(t) c(t)
+ Controlled
I
object
-
D +
e(t) = r (t ) –c ( t ) (1-1)
u(t) = Kp [ e(t) + 1/Ti ∫ e(t)dt + TD de(t)/dt] (1-2)
Here, e(t) is offset value, r ( t ) is the setting value, c ( t ) is actual output value and the
u(t) is the control value;
In function (1-2), Kp is the proportion coefficient, Ti is the integration time coefficient,
and TD is the differential time coefficient.
The result of the operation:
1.Analog output: digital form of MV = u(t), the default range is 0~4095.
2.Digital output: Y = T * [MV / PID output upper limit]. Y is the outputs activate time
within the control cycle. T is the control cycle, equals to the sampling time. PID output
upper limit default value is 4095.
7-3.Parameters setting
Users can call PID in XDP Pro software directly and set the parameters in the window
(see graph below), for the details please refer to XDP Pro user manual. Users can also
write the parameters into the specified registers by MOV instructions before PID
operation.
279
Auto tune mode:
280
V3.2 and higher version software can choose auto tune mode: step response or critical
oscillation.
281
bit11~bit12:not useful
bit13 ~ bit14 auto tune PID
mode (valid in critical
oscillation mode)
00:PID control
01:PI control
10:P control
bit15:
0:regular mode;
1:advanced mode;
S3+3 Proportion Gain (Kp) Range:1~32767[%]
S3+4 Integration time (TI) 0~32767[unit: 100ms] 0 is taken as no
integral.
S3+5 Differential time ( TD) 0~32767[unit: 10ms] 0 is taken as no
differential.
S3+6 PID operation zone 0~32767 PID adjustment
band width value
S3+7 Control death zone 0~32767 PID output value
will not change in
death zone
S3+8 Sampling temperature 0~100[%] Filter the input
filter coefficient sampling
temperature in
advanced mode, 0
is no input filter
S3+9 Differential gain( KD) 0~100[%] Only for advanced
mode (normal
mode default value
is 50%), 0 is no
differential gain
S3+1 Upper limit value of 0~32767
0 output
S3+1 Lower limit value of 0~32767
1 output
S3+1 Change of Unit full scale AD value * 16-bit no sign, only
2 Temperature (0.3~1%) for step PID
Corresponds to Change default value is 10
of AD Value
S3+1 PID auto tune overshoot 0:enable overshoot only for step PID
3 1 : not overshoot ( try to
reduce the overshoot)
S3+1 Current target value Cannot adjust 16-bit no sign, only
4 adjusting percentage for step PID
every time in auto tune
end transition stage
S3+1 Number of times only for step PID,
5 exceeding the target default value is 15
value in auto tune end
transition stage when
limiting the overshoot
S3+1 PID type and status Bit0~bit1: Internal use
6 00: manual mode parameters of the
282
01: step mode system for
10: Critical oscillation mode monitoring
Bit8: purposes only
0: manual control status
1: auto tune end, enter
manual control status
S3+1 PID max output 0~32767 Internal use
7 parameters of the
system for
monitoring
purposes only
S3+1 PID min output 0~32767 Internal use
8 parameters of the
system for
monitoring
purposes only
S3+1 Last time sampling time 0~sampling time (unit: ms) 16-bit no sign,
9 Internal use
parameters of the
system for
monitoring
purposes only
S3+2 Actual sampling time The value is around the 32-bit no sign,
0 space sampling time Internal use
parameters of the
system for
monitoring
purposes only
S3+2 Last time user set target The value before changing Internal use
2 temperature the target temperature parameters of the
system for
monitoring
purposes only
S3+2 - - Parameter is
3 reserved
The following is the joint address (divided into step setting, critical oscillation
setting and manual control)
Step part (read only parameters, only for monitoring)
S3+24 Actual sampling 0~4294967296 (unit: ms) Internal usage
space parameters of the
system
S3+26 Operating segment of 0: Preparation stage Internal usage
auto-tuning PID 1 ~ 2: auto tune parameter parameters of the
collection system
3: calculate PID parameters
S3+28 Duration of auto- 0~4294967296 (unit: ms) Internal usage
tuning PID operating parameters of the
parameters system
S3+30 Real-time Clear and recalculate the time Internal usage
accumulation of two when reaching the inflection parameters of the
inflection points point 0~4294967296 (unit: ms) system
283
S3+32 Sampling variation of Sampling difference between Internal usage
inflection point two inflection points parameters of the
-2147483648~2147483647 system
S3+34 Sampling interval 0~4294967296 (unit: ms) Internal usage
time of inflection point parameters of the
EK system
S3+36 Time from auto-tuning 0~4294967296 (unit: ms) Internal usage
PID to inflection point parameters of the
system
S3+38 Last sampling -32767~32767 Internal usage
temperature parameters of the
system
S3+39 The time from auto- -32767~32767 (unit: ms) Internal usage
tuning PID operation parameters of the
to inflection point system
S3+40 Starting sampling -32767~32767 Internal usage
value of auto-tuning parameters of the
PID operation system
S3+41 Number of times at 0~65535 Internal usage
inflection point during parameters of the
auto-tuning system
S3+42 Useless time 0~4294967296 (unit: ms) Internal usage
parameters of the
system
S3+44 Stop temperature Temperature at the end of auto- Internal usage
tuning parameters of the
Range: -32767~32767 system
Critical oscillation part (read only parameters, only for monitoring)
S3+24 PID control mode 0: PID control 16-bit no sign,
1: PI control internal usage
2: P control parameters of the
system
S3+25 Current auto-tuning 0: Preparation stage 16-bit no sign,
segment 1: start to auto tune internal usage
2 ~ 3: auto-tuning parameter parameters of the
collection system
4: calculation of PID
parameters
S3+26 The auto-tuning 0: first peak 16-bit no sign,
temperature is 1: second peak internal usage
located at the number parameters of the
of peaks system
S3+27 The lowest sampling -32767~32767 Internal usage
temperature parameters of the
system
S3+28 The highest sampling -32767~32767 Internal usage
temperature parameters of the
system
S3+30 sampling time of the 0~4294967296 (unit: ms) Internal usage
lowest sampling parameters of the
temperature system
S3+32 sampling time of the 0~4294967296 (unit: ms) Internal usage
highest sampling parameters of the
temperature system
284
S3+34 auto-tuning time 0~4294967296 (unit: ms) Internal usage
cumulative parameters of the
system
Manual control part (read only parameters, only for monitoring)
S3+24 current target -32767~32767 Internal usage
temperature parameters of the
system
S3+25 Need to update target 0: no need 16-bit no sign,
temperature 1: need internal usage
parameters of the
system
S3+26 Number of times to 0~65535 Internal usage
reach target parameters of the
temperature system
S3+27 PID upper limit of -32767~32767 Internal usage
operational range parameters of the
system
S3+28 PID lower limit of -32767~32767 Internal usage
operational range parameters of the
system
S3+30 High voltage time 0~4294967296 (unit: ms) Internal usage
when PID uses Y to parameters of the
output system
S3+32 Sampling The filtered temperature Floating point,
temperature after last acquired in the last sampling internal usage
filtering time (the input filter constant in parameters of the
the advanced mode needs to system
be set first)
S3+34 Last temperature Floating point,
deviation internal usage
parameters of the
system
S3+36 Value of last integral digital value corresponding to Floating point,
term Ui of the last sampling time internal usage
parameters of the
system
S3+38 Value of last digital value corresponding to Floating point,
differential term Ud of the last sampling time internal usage
parameters of the
system
S3+40 Last PID output Floating point,
internal usage
parameters of the
system
Note: When the auto-tuning mode is changed to manual control, the value in the
original address of S3+24~S3+40 will be overwritten by the value in manual control
mode.
285
7-3-2.Parameters Description
Movement direction:
Positive movement: the output value MV will increase with the increasing of the
measured value PV, usually used for cooling control.
Negative movement: the output value MV will decrease with the increasing of the
measured value PV, usually used for heating control.
Mode setting
Common Mode:
Parameters register range: S3~S3+69, and S3~S3+7 need to be set by users;
S3+8~S3+69 are occupied by system, users can’t use them.
Advanced Mode
Parameters register range: S3~S3+69, among them S3~S3+7 and S3+8~S3+11
need to be set by users; S3+16~S3+69 are occupied by system, users can’t use them.
Sample time[S3]
The system samples the current values according to some certain interval and
compares them with the output value. This time interval is the sample time T. There is
no requirement for T during DA output; T should be larger than one PLC scan period
during port output. T value should be chosen among 100~1000 times of PLC scan
periods.
If the target value is 100, PID operation zone is 10, and then the real PID’s operation
zone is from 90~110.
286
Death Region [S3+7]
If the measured value changed slightly for a long time, and PID control is still in working
mode, then it belongs to meaningless control. Via setting the control death region, we
can overcome this situation. See graph below:
Suppose: we see the death region value to be 10. Then in the above graph, the
difference is only 2 comparing the current value with the last value. It will not do PID
control; the difference is 13 (more than death region 10) comparing the current value
with the next value, this difference value is larger than control death region value. it will
do the PID control with 135.
Auto tune mode is suitable for these controlled objects: temperature, pressure; not
suitable for liquid level and flow.
287
For step response method: Users can set the sampling cycle to be 0 at the beginning
of the auto tune process then modify the value manually in terms of practical needs
after the auto tune process is completed.
For step response method: Before doing auto tune, the system should be under the
non-control steady state. Take the temperature for example: the measured
temperature should be the same to the environment temperature.
For critical oscillation method: user needs to set the sampling time at the beginning of
the auto tune process. For slow response system, 1000ms. For fast response system,
10-100ms.
For critical oscillation method: the system can start the auto tune at any state. For
object temperature, the current temperature doesn’t need to be same to ambient
temperature.
output
D0
+DIFF
D0
Setting value
D0
-DIFF
Output
D0
+DIFF
D0
Setting value
D0
-DIFF
To enter the auto tune mode, please set bit7 of (S3+ 2) to be 1 and turn on PID working
condition. If bit8 of (S3+ 2) turn to 1, it means the auto tune is successful.
288
PID auto tune period value [S3+12]
Set this value in S3+12 during auto tune. This value decides the auto tune performance,
in a general way, set this value to be AD result corresponding to one standard tested
unit. The default value is 10. The suggested setting range: fall-scale AD result×0.3~1%.
User doesn’t need to change this value. However, if the system is interfered greatly by
outside, this value should be increased modestly to avoid wrong judgment of positive
and negative movement. If this value is too large, the PID control period (sampling time)
got from the auto tune process will be too long. As the result do not set this value too
large.
※1:If users have no experience, please use the default value 10, set PID sampling
time (control period) to be 0msthen start the auto tune.
Every adjustment percent of current target value in auto tune end transition
stage [S3+14]
This parameter is effective only when [S3+13] is 1.
If doing PID control after auto tune, small range of overshooting may be occurred. It is
better to decrease this parameter to control the overshooting. But response delay may
occur if this value is too small. The defaulted value is 100% which means the
parameter is not effective. The recommended range is 50~80%.
Cutline Explanation:
Current target value adjustment percent is 2/3 ( S3 + 14 = 67%), the original
temperature of the system is 0 ºC, target temperature is 100 ºC, and the current target
temperature adjustment situation is shown as below:
Next current target value = current target value + (final target value – current target
value) × 2/3;
So the changing sequence of current target is 66 ºC, 88 ºC, 96 ºC, 98 ºC, 99 ºC, 100
ºC.
289
℃
100 Target value
96 Current target 3
88
Current target 2
66
Current target 1
Over target value times in auto-tuning end transition stage when limiting the
overshoot [S3+15]
This parameter is valid only when [S3+13] is 1;
If entering into PID control directly after auto tune, small range of overshoot may occur.
It is good to prevent the overshoot if increasing this parameter properly. But it will cause
response lag if this value is too large. The default value is 15 times. The recommended
range is from 5 to 20.
7-5.Advanced Mode
Users can set some parameters in advanced mode in order to get better PID control
effect. Enter into the advanced mode, please set [S3+2] bit 15 to be 1, or set it in the
XDP Pro software.
Differential Gain[S3+9]
The low pass filtering process will relax the sharp change of the output value. The
default value is 50%; the relaxing effect will be more obviously if increasing this value.
Users do not need to change it.
290
Upper-limit and lower-limit value [S3+10], [S3+11]
Users can choose the analog output range via setting this value.
Default value: lower-limit output =0
Upper-limit =4095
7-6.Application outlines
Under the circumstances of continuous output, the system whose effect ability will die
down with the change of the feedback value can do auto tune, such as temperature or
pressure. It is not suitable for flux or liquid level.
Under the condition of overshooting permission, the system will get the optimal PID
parameters from auto tuning.
Under the condition that overshoot not allowed, the PID parameters got from auto tune
is up to the target value, it means that different target value will produce different PID
parameters which are not the optimal parameters of the system and for reference only.
If the auto tune is not available, users can set the PID parameters according to practical
experience. Users need to modify the parameters when debugging. Below are some
experience values of the control system for your reference:
291
7-7.Application
Example 1:
PID control program is shown below:
SM0
MOV ID100 D10 // Move ID100 content into D10
M1 HD2.7
( S ) // auto tune mode, or set to autotune mode
after auto tune end
M2
M2
HD2.8 HD09 K0 M1
( R ) // if auto tune is successful, and overshoot is
permitted, close auto tune control bit, auto
HD2.8 HD09 K1 tune will finish;
If auto tune turns to be manual mode, and
overshoot is not permitted, close auto
tune control bit.
Soft element function comments:
HD2.7: Auto tune bit
HD2.8: Successful flag of auto tune
M0: Normal PID control
M1: Auto tune control
M2: Enter PID control after auto tune
Operation steps:
1. Send the actual temperature to PID collection register
2. Set probably value for P, I, D, sampling period
3. Set ON auto tune control bit M1 to startup PID auto tune
4. M1 will be reset after the auto tune is finished
5. Set ON M0, use the PID parameters getting from auto tune
6. If the PID effect is not good by using the auto tune PID parameters, user can adjust
the PID parameters to get good effect.
Note: This PLC temperature PID control program is applicable to almost all
temperature control projects.
292
Example 2:
To control the target temperature 60℃ in step response mode.
Overshoot is permitted:
1. The target temperature 60℃ (600)
2. Parameters setting
293
Explanation:
The target temperature is 60 degree, PID calculation range is 10 degree, PID control
dead area is 0.2 degree, auto tune period changing value is 10. When the PID control
works in normal atmospheric temperature, the PID output terminal will heat the
temperature from 28 to 100 degree, then the output stops, the temperature keeps
increasing to 110 degree (max temperature) as the remaining warmth. Then the
temperature keeps decreasing to 60 degree, the output starts to heat again to 70
degree and stops. The temperature increases a little then decreases again. This
process will repeat. Finally, the temperature will fluctuate close the target temperature.
Note:
1. When the temperature reaches 100 degree and stops heating, the PID start bit
D4002.7 will not reset at once, it has delay before reset.
2. When the temperature reaches 100 degree and stops heating, the PID auto tune
success bit D4002.8 will be ON at once.
3. When it starts PID calculation, the PLC will auto set a sampling time (about 2500).
This parameter will be replaced by the PID best sampling time after stoping heating at
100 degree.
4. When it starts PID calculation, the PLC will auto set the PID parameters (P=4454,
I=926, D=2317). These parameters will be replaced by the best PID value after stoping
heating at 100 degree.
5. When the temperature reaches 100 degree and stops heating, the PID start bit
D4002.7 will not reset at once, it has delay before reset. At this time, the sampling
temperature is higher than target temperature. If user sets ON the PID auto tune again,
PLC will get all the PID parameters as 0. Please set ON the PID after the temperature
decreases under the normal atmospheric temperature.
6. If PID auto tune start bit and auto tune success bit are power-off retentive, please
set or reset them propably to avoid calculation error when starting the PLC next time.
294
7. The final heating temperature will up to 110 degree when the overshoot is permitted.
It is over the target temperature by 50 degree, the overshoot amount is too large.
8. When the PID starts to work, the output will heat the object from 28 degree to 60
degree, then the output is forced to stop heating to avoid overshoot, but this will
interrupt the PID auto tune process.
9. To enlarge the PID calculation range can suppress the heating overshoot.
295
Explanation:
The target temperature is 60 degree, PID calculation range is 10 degree, PID control
dead area is 0.2 degree, auto tune period changing value is 10. When the PID control
works in normal atmospheric temperature, the PID output terminal will heat the
temperature from 28 to 48 degree, then the output stops, the temperature keeps
increasing to 70 degree (max temperature) as the remaining warmth. Then the
temperature keeps decreasing to 60 degree, the output starts to heat again to 62
degree and stops. The temperature increases a little (about 64 degree) then decreases
again. This process will repeat. Finally, the temperature will fluctuate close the target
temperature. The precision is + 0.25 degree.
Note:
1. When the temperature reaches 48 degree and stops heating, the PID start bit
D4002.7 will not reset at once, it has delay before reset.
2. When the temperature reaches 48 degree and stops heating, the PID auto tune
success bit D4002.8 will not be ON at once. It hasn’t set ON even when the auto tune
succeeded.
3. When it starts PID calculation, the PLC will auto set a sampling time (about 2500).
This parameter will be replaced by the PID best sampling time after stoping heating at
48 degree.
4. When it starts PID calculation, the PLC will auto set the PID parameters (P=4454,
I=926, D=2317). These parameters will be replaced by the best PID value after stoping
heating at 48 degree.
5. When the temperature reaches 48 degree and stops heating, the PID start bit
D4002.7 will not reset at once, it has delay before reset. At this time, the sampling
temperature is higher than target temperature. If user sets ON the PID auto tune again,
296
PLC will get all the PID parameters as 0. Please set ON the PID after the temperature
decreases under the normal atmospheric temperature.
6. If PID auto tune start bit and auto tune success bit are power-off retentive, please
set or reset them propably to avoid calculation error when starting the PLC next time.
7. The final heating temperature will up to 70 degree when the overshoot is permitted.
It is over the target temperature by 10 degree, the overshoot amount is small.
8. To enlarge the PID calculation range can suppress the heating overshoot.
8-1.Summary
XD, XL supports almost all C language function in XDPPro software (also supports
global variable). Users can call the function at many places and call different functions,
which greatly increase program security and programmer’s efficiency.
8-2.Instruction Format
1. Instruction Summary
Call the C language Function Block at the specified place.
Call the C language function block [NAME_C]
16 bits NAME_C 32 bits -
instruction Instruction
Execution Normally ON/OFF, Suitable XD, XL
condition Rising/Falling Edge activation Models
Hardware Software
2. Operands
Operand Function Type
s
S1 Name of C Function Block, defined by the String
user
S2 Corresponding start ID of word W in C 16 bits, BIN
language function
S3 Corresponding start ID of word B in C bit, BIN
language function
297