STEP 7 PID Temperature Control
STEP 7 PID Temperature Control
STEP 7 PID Temperature Control
2001
19.11.2001
19.11.2001
Preface, Contents
Introduction 1
Continuous Temperature
SIMATIC Controller FB 58 "TCONT_CP" 2
Controller Tuning in FB 58
"TCONT_CP" 3
PID Temperature Control Temperature Step Controller
4
FB59 "TCONT_S"
Getting Started 5
Manual Examples for the Temperature
Controllers 6
Appendix A
Edition 11/2001
A5E00125039-01
26.11.2001
19.11.2001
19.11.2001
Safety Guidelines
This manual contains notices intended to ensure personal safety, as well as to protect the products and
connected equipment against damage. These notices are highlighted by the symbols shown below and
graded according to severity by the following texts:
Danger
! indicates that death, severe personal injury or substantial property damage will result if proper
precautions are not taken.
Warning
! indicates that death, severe personal injury or substantial property damage can result if proper
precautions are not taken.
Caution
! indicates that minor personal injury can result if proper precautions are not taken.
Caution
indicates that property damage can result if proper precautions are not taken.
Notice
draws your attention to particularly important information on the product, handling the product, or to a
particular part of the documentation.
Qualified Personnel
Only qualified personnel should be allowed to install and work on this equipment. Qualified persons are
defined as persons who are authorized to commission, to ground and to tag circuits, equipment, and
systems in accordance with established safety practices and standards.
Correct Usage
Warning
! This device and its components may only be used for the applications described in the catalog or the
technical description, and only in connection with devices or components from other manufacturers
which have been approved or recommended by Siemens.
This product can only function correctly and safely if it is transported, stored, set up, and installed
correctly, and operated and maintained as recommended.
Trademarks
SIMATIC®, SIMATIC HMI® and SIMATIC NET® are registered trademarks of SIEMENS AG.
Third parties using for their own purposes any other names in this document which refer to trademarks might
infringe upon the rights of the trademark owners.
Siemens AG
Bereich Automatisierungs- und Antriebstechnik
Geschaeftsgebiet Industrie-Automatisierungssysteme ©Siemens AG 2001
Postfach 4848, D- 90327 Nuernberg Technical data subject to change.
Siemens Aktiengesellschaft A5E00125039
26.11.2001
19.11.2001
19.11.2001
Preface
Preface
Preface
Further Support
If you have questions about using the products described in the manual and you
cannot find the answers here, please contact your local Siemens representative.
http://www.ad.siemens.de/partner
Training Centers
Courses are available to help you become familiar with the SIMATIC S7
automation system and programmable controllers. Please contact your regional
training center or the central training center in D 90327 Nuremberg.
Phone: +49 (911) 895-3200.
http://www.sitrain.com
Preface
Nuremberg
Johnson City
Singapore
SIMATIC Hotline
Preface
Preface
Contents
1 Introduction
1.1 FB 58 "TCONT_CP"..........................................................................................1-3
1.2 FB59 "TCONT_S" .............................................................................................1-4
2 Continuous Temperature Controller FB 58 "TCONT_CP"
2.1 Controller Section..............................................................................................2-1
2.1.1 Forming the Error ..............................................................................................2-1
2.1.2 PID Algorithm ....................................................................................................2-4
2.1.3 Calculating the Manipulated Variable ...............................................................2-6
2.1.4 Saving and Reloading Controller Parameters...................................................2-9
2.2 Pulse Generator PULSEGEN (PULSE_ON)...................................................2-11
2.3 Block Diagram .................................................................................................2-13
2.4 Including the Function Block in the User Program..........................................2-14
2.4.1 Calling the Controller Block.............................................................................2-14
2.4.2 Call without Pulse Generator (continuous controller) .....................................2-15
2.4.3 Call with Pulse Generator (pulse controller) ...................................................2-15
2.4.4 Initialization......................................................................................................2-18
3 Controller Tuning in FB 58 "TCONT_CP"
3.1 Introduction........................................................................................................3-1
3.2 Process Types...................................................................................................3-2
3.3 Area of Application ............................................................................................3-3
3.4 The Phases of Controller Tuning ......................................................................3-4
3.5 Preparations ......................................................................................................3-6
3.6 Starting Tuning (Phase 1 -> 2)..........................................................................3-8
3.7 Searching for the Point of Inflection (Phase 2) and Calculating the Control
Parameters (Phase 3, 4, 5) .............................................................................3-10
3.8 Checking the Process Type (Phase 7) ...........................................................3-10
3.9 Result of the Tuning ........................................................................................3-11
3.10 Tuning Stopped by the Operator.....................................................................3-11
3.11 Error Situations and Remedies .......................................................................3-12
3.12 Manual Fine Tuning in Control Mode..............................................................3-16
3.13 Parallel Tuning of Control Channels ...............................................................3-18
4 Temperature Step Controller FB59 "TCONT_S"
4.1 Controller Section..............................................................................................4-1
4.1.1 Forming the Error ..............................................................................................4-1
4.1.2 PI Step Controller Algorithm..............................................................................4-4
4.2 Block Diagram ...................................................................................................4-5
4.3 Including the Function Block in the User Program............................................4-6
4.3.1 Calling the Controller Block...............................................................................4-6
4.3.2 Sampling Time ..................................................................................................4-7
4.3.3 Initialization........................................................................................................4-7
Contents
5 Getting Started
Index
Online help
After you have installed STEP 7, the various parts of STEP 7 PID Temperature
Control are located in the following folders:
• SIEMENS\STEP7\S7LIBS\: FBs
• SIEMENS\STEP7\S7WRT\: parameter assignment user interface, readme,
online help
• SIEMENS\STEP7\EXAMPLES\: sample programs
• SIEMENS\STEP7\MANUAL\: manual
Function Blocks
The "Standard Library PID Control" contains two temperature controllers:
1. FB 58 "TCONT_CP":
Temperature controller for actuators with a continuous or pulsed input signal.
This controller block also includes a self-tuning function for the PI/PID
parameters.
2. FB 59 "TCONT_S":
Temperature step controller for actuators with an integral component such as a
positioning motor.
The control blocks are purely software controllers in which a block includes the
entire functionality of the controller. The data required for cyclic calculation are
stored in the corresponding instance data blocks.
Online Help
You will find a description of the parameter assignment user interface and the
function blocks in the online help systems.
1.1 FB 58 "TCONT_CP"
FB 58 "TCONT_CP" is used to control temperature processes with continuous or
pulsed control signals. You can set parameters to enable or disable subfunctions of
the PID controller and adapt it to the process. These settings can be made simply
with the parameter assignment tool. You start this within a project by double-
clicking on the instance DB in the SIMATIC Manager. You can open the electronic
manual as follows:
Start > Simatic > Documentation > English > PID Temperature Control.
Application
The functionality is based on the PID control algorithm with additional functions for
temperature processes. The controller supplies analog manipulated values and
pulse-duration modulated actuating signals. The controller outputs signals to one
actuator; in other words, with one controller, you can either heat or cool but not
both.
Process value
PV_PER Controller tuning
PV_IN PI/PID parameters
• Control zone width
Sampling time
Description
Apart from the functions in the setpoint and process value branches, the FB
implements a complete PID temperature controller with a continuous and binary
manipulated variable output. To improve the control response with temperature
processes, the block includes a control zone and reduction of the P-action if there
is a setpoint step change.
The block can set the PI/PID parameters itself using the controller tuning function.
Application
The functionality is based on the PI control algorithm of the sampling controller.
This is supplemented by the functions for generating the binary output signal from
the analog actuating signal.
You can also use the controller in a cascade control as a secondary position
controller. You specify the actuator position via the setpoint input SP_INT. In this
case, you must set the process value input and the parameter TI (integral time) to
zero. An application might be, for example, temperature control with heating power
control using pulse-break activation and cooling control using a butterfly valve. To
close the valve completely, the manipulated variable (ER*GAIN) should be
negative.
Description
Apart from the functions in the process variable branch, FB 59 "TCONT_S"
implements a complete PI controller with binary manipulated value output and the
option of influencing the controller output signals manually. The step controller
operates without a position feedback signal.
The schematic below is a block diagram illustrating how the error is formed:
SP_INT
PVPER_ON
PV_IN DEADBAND
0 +
CRP_IN PV_NORM ER
0
*0,1 C
0
*0,01 C 1 DEADB_W
PV_PER
%
PV
PER_MODE PV_FAC,
PV_OFFS
Parameter assignment user interface
FB call interface
Parameter assignment u ser interface, FB call interface
Setpoint Branch
The setpoint is entered at input SP_INT in floating-point format as a physical value
or percentage. The setpoint and process value used to form the error must have
the same unit.
With the default values (PV_FAC = 1.0 and PV_OFFS = 0.0), normalization is
disabled. The effective process value is output at the PV output.
Note
With pulse control, the process value must be transferred to the block in the fast
pulse call (reason: mean value filtering). Otherwise, the control quality can
deteriorate.
PV_NORM [%]
100
75
PV_FAC = 100/(85-(-20))
50 = 0.9524
25
PV_OFFS = 0-0.9524*(-20)
= 19.05
-20
20 40 60 80 85 CRP_IN [°c]
Deadband (DEADB_W)
To suppress a small constant oscillation due to the manipulated variable
quantization (for example in pulse duration modulation with PULSEGEN) a
deadband (DEADBAND) is applied to the error. If DEADB_W = 0.0, the deadband
is deactivated. The effective error is indicated by the ER parameter.
ER
ER = (SP_INT - PV) + DEAD_W ER = (SP_INT - PV) - DEAD_W
SP_INT - PV
DEADB_W
LMN_P
SP_INT
f()
ER
LMN_Sum
GAIN * ER (0)
ER (t)
GAIN * ER (0)
t
TD / D_F
TI
The schematic below is the block diagram of the manipulated variable calculation:
QLMN_HLM
QLMN_LLM
MAN MAN_ON LMN
CONZONE LMNLIMIT LMN_NORM
CRP_OUT
LMN_Sum 1
% LMN_PER
ER 0 LmnN
CONZ_ON, LMN_HLM LMN_FAC,
CON_ZONE LMN_LLM LMN_OFFS
PULSEGEN
Note
The changeover from controlled closed-loop to automatic closed-loop control
takes into account a hysteresis of 20% of the control zone.
Temperature
SP_INT + CON_ZONE
SP_INT
SP_INT - CON_ZONE
Note
Before activating the control zone manually, make sure that the control zone
band is not too narrow. If the control zone band is too small, oscillations will occur
in the manipulated variable and process variable.
Note
During tuning, the MAN_ON parameter is not effective.
MAN_ON
MAN_ON &
& SAVE_PAR UNDO_PAR
PID_ON LOAD_PID PFAC_SP,
PID_CON PFAC_SP,
1 GAIN, 0 0 GAIN,
0
GAIN, TI, TI,
PI_CON PAR_SAVE PAR_SAVE
TI, TD, 1 1 TD,
1
0 TD, D_F, D_F,
CONZONE CONZ_ON, CONZ_ON,
CONZONE CONZONE
Note
• The controller parameters are only written back to the controller with
UNDO_PAR or LOAD_PID when the controller gain is not 0:
LOAD_PID copies the parameters only if the relevant GAIN is <> 0 (either of
the PI or PID parameters). This strategy takes into account the situation that
no tuning has yet been made or that PID parameters are missing. If
PID_ON = TRUE and PID.GAIN = FALSE were set, PID_ON will be set to
FALSE and the PI parameters copied.
• D_F, PFAC_SP are set to default values by the tuning. These can then be
modified by the user. LOAD_PID does not change these parameters.
• With LOAD_PID, the control zone is always recalculated
(CON_ZONE = 250/GAIN) even when CONZ_ON = FALSE is set.
100
(LmnN) 80
50
50
30
0 t
QPULSE
1
0 t
P_B_TM
0.0 % 100.0 %
Minimum Minimum
on time off time
P_B_TM P_B_TM
PER_TM PER_TM PER_TM
GAIN
PV_IN DEADBAND
0
+ X
CRP_IN PV_NORM -
0
C 1
PV_PER DEADB_W
%
PV ER
PER_MODE PV_FAC,
PV_OFFS
LMN_P
SP_INT
f()
DISV
PFAC_SP
INT LMN_Sum
+ + PFAC_SP,
PID_TUNER
INT_HPOS GAIN, TI,
TD, D_F,
INT_HNEG PV
LMN_I CONZ_ON,
TI, I_ITL_ON, PID
LmnN CONZONE
I_ITLVAL
TUN_ON,
DIF TUN_ST bzw. SP_INT,
PID_ON,
LMN_D TUN_DLMN
TD, D_F
QLMN_HLM
QLMN_LLM
MAN MAN_ON LMNLIMIT LMN
CONZONE
LMN_NORM
1 CRP_OUT
LMN_PER
%
ER 0 LmnN
QPULSE
PULSE_ON,
PER_TM,
BREAK_TM
MAN_ON
MAN_ON &
& SAVE_PAR UNDO_PAR
PID_ON LOAD_PID
PID_CON PFAC_SP, PFAC_SP,
1 GAIN, 0 0 GAIN,
0
GAIN, TI, TI,
PI_CON PAR_SAVE PAR_SAVE
TI, TD, 1 1 TD,
1
0 TD, D_F, D_F,
CONZONE CONZ_ON, CONZ_ON,
CONZONE CONZONE
"TCONT_CP"
EN
PV_IN
PV_PER
DISV
INT_HPOS
INT_HNEG PV
SELECT LMN
CYCLE LMN_PER
CYCLE_P QPULSE
SP_INT QLMN_HLM
MAN QLMN_LLM
COM_RST QC_ACT
MAN_ON ENO
Controller Sampling Time CYCLE and Sampling Time of the Pulse Generator
CYCLE_P
If you have activated the pulse generator stage (PULSE_ON = TRUE), you must
enter two sampling times.
• Enter the sampling time of the pulse generator at the CYCLE_P input. This
must match the clock rate of the calling cyclic interrupt OB. The duration of the
generated pulse is always a whole multiple of this value.
• At the CYCLE input, you specify the sampling time for the other control
functions of FB 58 "TCONT_CP".
During controller tuning, the block measures the times between the calls and
enters these in CYCLE or CYCLE_P. If you supply values for the CYCLE and
CYCLE_P parameters via the call interface, the values measured following tuning
have no effect.
FB 58 "TCONT_CP" calculates the scan rate and processes the control functions
at the CYCLE sampling rate. Make sure that CYCLE is a whole multiple of
CYCLE_P.
You can select a value for CYCLE that is lower than the pulse repetition period
PER_TM. This can be useful when you require as high a pulse repetition period as
possible to reduce wear on the actuators but when the sampling time needs to be
low due to a fast process.
Note
If you implement the processing of controller functions and pulse generator with
two block calls, note the following:
• The process value (PV_IN or PV_PER) must be supplied with a value when
the pulse generator is called. All other formal operands can be supplied with
values when the controller functions are called.
• The SELECT parameter must be supplied with a value at every call.
• If you locate the call in OB1 with SELECT = 1, you implement the conditional
call in the example "pulse controller, OB 35, OB 1".
Numeric Examples
2.4.4 Initialization
3.1 Introduction
With controller tuning in FB 58 "TCONT_CP", the PI/PID controller parameters are
set automatically. There are two ways of tuning:
• Tuning by approaching the operating point with a setpoint step change
• Tuning at the operating point by setting a start bit
In both cases, the process is excited by a selectable manipulated variable step
change. After detecting a point of inflection, the PI/PID controller parameters are
available and the controller switches to automatic mode and continues to control
with these parameters.
You can also tune your controller using the wizard in the parameter assignment
user interface.
Process Types
Apart from the process gain GAIN_P, the parameters shown in the schematic
below, lag time TU and process time constant TA are characteristic parameters of
a process.
Process responce to a
manipulated variable
step change
Point of inflection
t
TU TA
The table below lists the various processes with which you can use
FB 58 "TCONT_CP":
Transient Response
The process must have a stable, asymptotic transient response with time lag.
After a step change in the manipulated variable, the process variable must change
to a steady state. This therefore excludes processes that have an oscillating
response without control and processes that are not self-regulating (integrator in
the process).
PHASE Description
0 No tuning; automatic or manual mode
1 Ready to start tuning; check parameters, wait for excitation, measure the
sampling times
2 Actual tuning: Wait to detect point of inflection at a constant controller output
value. Entry of the sampling time in the instance DB.
3 (1 cycle) Calculation of the process parameters. The controller parameters valid prior
to tuning are saved.
4 (1 cycle) Controller design
5 (1 cycle) Bring the controller to the new manipulated variable
7 Check the process type if process II or III was detected.
The schematic below illustrates the phases of tuning as a result of a setpoint step
change from the ambient temperature to the operating point:
Warm process
state
(Operating point)
TUN_DLMN PV
LMN
Point of inflection
Cold process
state
t
TUN_ON: Reset by Block
The schematic below illustrates the phases of tuning at the operating point started
with TUN_ST = TRUE:
Temperature PHASE = 3, 4, 5
(one cycle)
PHASE = 0 PHASE = 1 PHASE PHASE = 0 with typical PHASE = 0
=2 temperature process or
PHASE = 7 with
process type II or III
Point of inflection
Time
Reset by Block
TUN_ON
TUN_ST
At the end of the tuning (see Section 3.9, Page 3-11), when the block returns to
Phase 0 and TUN_ON = FALSE is set, you can recognize whether or not the
tuning was error free by the STATUS_H parameter.
3.5 Preparations
Warning
! Death, serious injury, or considerable damage to property may occur.
During tuning, the MAN_ON parameter is not effective. As a result, the
manipulated variable or process value can achieve unacceptable, extreme
values.
The manipulated variable is set by the tuning functions. To stop the tuning, you
must first set TUN_ON = FALSE. MAN_ON is then effective again.
Note
You should avoid changing the manipulated variable shortly before starting the
tuning. A change in the manipulated variable can also be brought about
accidentally when setting up the conditions required for tuning
(for example closing a furnace door)! If this does happen, wait at least until the
process variable begins to settle asymptotically towards the steady state. You
will, however achieve better controller parameters if you wait until the transients
have decayed completely.
Manipulated variable
PV
Actuating pulse
LMN
Time
In Phase 1, the time prior to making the manipulated variable step change is used
by FB 58 "TCONT_CP" to calculate the process variable noise NOISE_PV, the
initial rise PVDT0 and the mean value of the manipulated variable (initial value of
the manipulated variable LMN0).
Note
You should only wait to excite the process in Phase 1 until the block has
determined the mean value of the manipulated variable and the initial rise of the
process variable (typically: 1 minute).
In Phase 1, both the controller sampling time CYCLE and the pulse generator
sampling time CYCLE_P are measured and written to the relevant in/out
parameters at the beginning of Phase 2. In the control mode without the pulse
generator, CYCLE_P = CYCLE.
Note
If you call the pulse controller using SELECT = 0 or 1, you must specify the
required ratio CYCLE/CYCLE_P with the parameters CYCLE and CYCLE_P
before setting TUN_ON.
Note
With extremely sluggish processes, it is advisable to set a somewhat lower target
setpoint than the desired operating point during tuning and to monitor the status
bits and PV (risk of overshoot).
Tuning only in the linear range:
Certain controlled processes (for example zinc and magnesium smelters) have a
non-linear range shortly before the operating point (change in the state of the
material).
By selecting a suitable setpoint step change, the tuning can be limited to the
linear range. When the process variable has passed 75% of the setpoint step
change (SP_INT-PV0), tuning is terminated.
At the same time, TUN_DLMN should be reduced so that the point of inflection is
guaranteed to be found before reaching 75% of the setpoint step change.
Caution!
If you excite the process with TUN_ST, there is no safety turn off at 75%. Tuning
is terminated when the point of inflection is reached. In noisy processes, the point
of inflection can, however, be significantly exceeded.
Note
When exciting the process using a setpoint step change, the tuning is terminated
at the latest when the process variable exceeds 75% of the setpoint step change
(SP_INT-PV0) (see below).
Phases 3, 4 and 5 are then run through once. The tuning mode is then terminated
and FB 58 "TCONT_CP" is once again in Phase 0. The controller now always
starts in the automatic mode with LMN = LMN0 + 0.75*TUN_DLMN (even if you
were controlling in manual mode prior to the tuning).
Note
If Phase 7 is aborted by TUN_ON=FALSE, the controller parameters that have
already been obtained are retained!
STATUS_H Result:
0 Default or no new controller parameters have been found (yet).
10000 Suitable control parameters found
2xxxx Control parameters found using estimated values; check the control
response or check the STATUS_H diagnostic message and repeat the
controller tuning.
3xxxx Operator input error occurred; check the STATUS_H diagnostic
message and repeat the controller tuning.
Point of inflection not reached (only with excitation by setpoint step change)
Tuning is terminated at the latest when the process value has exceeded 75% of
the setpoint step change (SP-INT-PV0). This is signaled by "inflection point not
reached" in STATUS_H (2xx2x).
The currently valid setpoint always applies. By reducing the setpoint, it is possible
to achieve an earlier termination of the tuning function.
In typical temperature processes, terminating the tuning at 75% of the setpoint step
change is normally adequate to prevent overshoot. In processes with a greater lag
(TU/TA > 0.1, process type III) caution is advised. If the excitation of the
manipulated variable is too high compared with the setpoint step change, the
process variable can overshoot considerably (up to factor 3).
In higher order processes, if the point of inflection is still a long way off after
reaching 75% of the setpoint step change, there will be significant overshoot. In
addition to this, the control parameters are too aggressive. You should then
weaken the controller parameters and repeat the attempt.
The schematic below illustrates the overshoot of the process variable when the
excitation is too strong (process type III):
PV
have r esulted
LMN Point of inflection from unchanged
TUN_DLMN LMN
PV
75 % SP
Cold process state LMN
t
TUN_ON
Note
The special situation of a purely PT1 process is also indicated by STATUS_H =
2x1xx (TU <= 3*CYCLE). It is then not necessary to repeat the experiment.
Weaken the controller parameters if the control oscillates.
Overshoot
Overshoot can occur in the following situations:
Note
Activating the control zone with higher order processes (process type III) does not
normally bring any benefit since the control zone is then larger than the control
range that can be achieved with a 100% manipulated variable. There is also no
advantage in activating the control zone for PI controllers.
Before you activate the control zone manually, make sure that the control zone
width is not too small. If the control zone band is too small, oscillations will occur
in the manipulated variable and process variable.
Controller parameters:
• GAIN = 1.45
• TI = 19.6 s
Process value
Setpoint
Process value
Manip. variable
The figure below shows three attempts each with a setpoint step change from 0 to
60:
If two or more controllers control the temperature, for example, on a plate (in other
words, there are two heaters and two measured process values with strong heat
coupling ), follow the steps outlined below:
1. OR the two outputs QTUN_RUN.
2. Interconnect the two TUN_KEEP inputs with the output of the OR element.
3. Start both controllers by setting a setpoint step change at the same time or by
setting TUN_ST at the same time.
TCONT_CP, DB1_TCONT_CP
TUN_KEEP
QTUN_RUN
TCONT_CP, DB2_TCONT_CP ≥1
TUN_KEEP
QTUN_RUN
Advantage:
Both controllers output LMN0 + TUN_DLMN until both controllers have left Phase
2. This avoids that the controller that completes tuning first falsifies the tuning result
of the other controller due to the change in its manipulated variable.
Caution!
Reaching 75% of the setpoint step change means that the tuning leaves Phase 2
and that the output QTUN_RUN is reset. Automatic mode starts, however only
when TUN_KEEP also changes to 0.
Block Diagram
SP_INT
PVPER_ON
PV_IN DEADBAND
0 +
CRP_IN PV_NORM ER
0
*0,1 C
0
*0,01 C 1 DEADB_W
PV_PER
%
PV
PER_MODE PV_FAC,
PV_OFFS
Parameter assignment user interface
FB call interface
Parameter assignment user interface, FB call interface
Setpoint Branch
The setpoint is entered at input SP_INT in floating-point format as a physical value
or percentage. The setpoint and process value used to form the error must have
the same unit.
PV_NORM [%]
100
75
PV_FAC = 100/(85-(-20))
50 = 0.9524
25
PV_OFFS = 0-0.9524*(-20)
= 19.05
-20
20 40 60 80 85 CRP_IN [°c]
Deadband (DEADB_W)
To suppress a small constant oscillation due to the manipulated variable
quantization (for example in pulse duration modulation with PULSEGEN) a
deadband (DEADBAND) is applied to the error. If DEADB_W = 0.0, the deadband
is deactivated.
ER
ER = (SP_INT - PV) + DEAD_W ER = (SP_INT - PV) - DEAD_W
SP_INT - PV
DEADB_W
Feedforward Control
A feedforward variable can be added at the DISV input.
PV_IN DEADBAND
0
+ X
CRP_IN PV_NORM -
0 1
PV_PER C DEADB_W
% PV
ER
PER_MODE PV_FAC,
PV_OFFS
SP_INT
f()
PFAC_SP
LMNR_HS
LMNR_LS
LMNUP
LMNDN
LMNS_ON
QLMNUP
1 PULSEOUT
DISV THREE_ST AND
0 AND
adaptiv
QLMNDN
+ 1
AND
- AND
1
0 PULSE_TM, 100.0
MTR_TM
BREAK_TM 0.0
0
+
-100.0 1
0.0
0
LMNS_ON OR X
1/MTR_TM
1 0.0 INT +
1/TI 0
0.0
1 -
X
0
“TCONT_S”
EN
CYCLE
SP_INT
PV_IN
PV_PER
DISV
LMNR_HS
LMNR_LS QLMNUP
LMNS_ON QLMNDN
LMNUP PV
LMNDN ER
COM_RST ENO
You specify the sampling time at the CYCLE parameter. You can also enter the
sampling time using the parameter assignment tool. The sampling time CYCLE
must match the time difference between two calls (cycle time of the cyclic OB
including scan rates).
Numeric Example
4.3.3 Initialization
Aims
Based on the following simple example, "zEn01_13_STEP7__PID-Temp -> Pulse
Controller", you will learn to control the simulated temperature process with the FB
58 "TCONT_CP" temperature controller and to obtain the PID controller
parameters online.
Requirements
The following requirements must be met:
• You are using an S7-300/400 station consisting of a power supply and a CPU.
• STEP 7 (≥ V5.1 SP3) is installed on your programming device.
• The programming device is connected to the CPU.
1 Create a project in the SIMATIC Manager The project window appears in the SIMATIC
with File->New... Manager.
2 Insert a SIMATIC 300 or 400 station to match
your hardware configuration.
3 Configure your station in HW Config and set
the cycle time of the cyclic interrupt priority
class of OB35 to 20 ms.
4 Copy the pulse controller program from the The program is ready for downloading to the
sample project zEn01_13_STEP7__PID- CPU.
Temp to your station.
5 Select your program and copy it to the CPU
with PLC -> Download.
1 Open the parameter assignment tool by The parameter assignment tool opens.
double-clicking on the instance DB
DB_TCONT_CP in the SIMATIC Manager.
2 Under Options, select the menu command The curve recorder and the first dialog of the
Controller Tuning. wizard open.
3 On the curve recorder, check that the The "Selecting the Controller Type" dialog
manipulated variable and process value have opens.
practically settled and click on Next.
4 Set "PID parameters" and click on Next. The "Selecting the Type of Process
Excitation" dialog opens.
5 Set "Tune by approaching the operating point The "Process Excitation" dialog opens.
with a setpoint step change" and click on
Next.
6 Set the operating point to 70 and the The "Status and Result of the Tuning" dialog
manipulated variable difference to 80 and opens.
click on Next.
7 When the completion of the controller tuning The wizard and curve recorder are closed.
is displayed, click on Close.
You can now test these controller parameters by applying a setpoint step change
or a disturbance load to the process.
1 Open the curve recorder in the Options menu. The curve recorder window opens.
2 Open the Commissioning dialog in the The Commissioning dialog opens.
Options menu.
3 Enter a setpoint step change to 90 for the The setpoint changes abruptly in the curve
setpoint parameter and click the Send button. recorder.
4 Observe the settling response of the process
value and manipulated variable.
Manual/Automatic Switchover
1 Switch to manual in the Commissioning dialog The value of the manipulated variable
and click the Send button. remains constant in the curve recorder.
2 Set a different value for the manual value and You can now see the new manual value set
click the Send button. for the manipulated variable.
3 Return to the automatic mode and click the Based on the value of the manipulated
Send button. variable in the curve recorder, you can see
how the controller operates again in automatic
mode.
1 Switch to manual in the Commissioning dialog The value of the manipulated variable
and click the Send button. remains constant in the curve recorder.
2 Open the VAT_StructPar variable table in the
SIMATIC Manager and click on Variable
Monitor.
3 Under "PID/PI Parameter Setting" in the In the VAT_StructPar variable table, you can
Commissioning dialog, select PI parameters see how the parameters of PI_CON were
and click the Download button. transferred to the effective parameters.
4 Under "PID/PI Parameter Setting", select PID In the VAT_StructPar variable table, you can
parameters and click the Download button. see how the parameters of PID_CON were
transferred to the effective parameters.
5 Return to the automatic mode and click the Based on the value of the manipulated
Send button. variable in the curve recorder, you can see
how the controller operates again in automatic
mode.
1 Switch to manual in the Commissioning dialog The value of the manipulated variable
and click the Send button. remains constant in the curve recorder.
2 Open the VAT_StructPar variable table in the
SIMATIC Manager and click on Variable
Monitor.
3 Click the Download button for the "Saved PID In the VAT_StructPar variable table, you can
and control zone parameters" option. see how the parameters of PAR_SAVE were
transferred to the effective parameters.
4 Change values in the effective parameters to
be able to recognize later that the values are
transferred.
5 Click the Save button for the "PID and control In the VAT_StructPar variable table, you can
zone parameters" option. see how the effective parameters are
transferred to PAR_SAVE.
6 Return to the automatic mode and click the Based on the value of the manipulated
Send button. variable in the curve recorder, you can see
how the controller operates again in automatic
mode.
6.1 Introduction
Overview
This chapter contains executable application samples for the temperature
controllers FB 58 "TCONT_CP" and FB 59 "TCONT_S" with simulation of the
process.
You will find the examples in the folder ...\STEP7\EXAMPLES.
Requirements
• You have set up and wired an S7 station consisting of a power supply and a
CPU.
• STEP 7 (>= V5.1 + Service Pack 3) is installed on your programming device.
• The programming device is connected to the CPU.
Using a Sample
The sample programs include variable declaration tables (VAT) with which you can
see and change the values. With the curve recorder in the parameter assignment
user interface, you can also check the curves.
Adapting a Sample
You can use the code of the samples directly as a user program, however, the
samples are not tuned for a real process.
Program Structure
The controller and process block are called in OB35 with a cyclic interrupt time of
20 ms. The slower controller stage operates with CYCLE = 400 ms. To achieve the
required accuracy, PER_TM > CYCLE was selected (1 s).
When OB100 starts, the restart bits of the controller and process are set.
The pulse generator for the controller is activated in OB100.
DISV AMB_TEM
HEAT_P GAIN
100
0 + + OUTV
Parameter
The controller can be changed to manual at the MAN_ON switch. The manual
value can be set at MAN.
After a warm restart on the CPU, the controller is in manual with the heating off.
If you want to tune the controller, set the TUN_ON bit and enter a setpoint at SP.
You can monitor the tuning at the PHASE parameter.
The result of the tuning can be seen at the status words STATUS_H and
STATUS_D.
zEn 13
Process value
Setpoint
Process value
Manip. variable
Zoom
This screenshot shows the controller tuning when heating from ambient
temperature 20°C to the operating point (70°C). Following this, a setpoint step
change was controlled with a control zone. At the new operating point of 90°C, the
controller was tuned again with negative manipulated variable excitation.
A "DB_TCONT_CP".QC_ACT
JCN M001
• The "pulse controller OB35, OB32" sample is suitable for S7-400 since several
cyclic interrupt levels are available.
The following figures show the block call with a short pulse generator sampling
time on an S7-400:
OB32 (e.g. 1 s) OB35 (e.g. 20 ms)
Program Structure
The controller and process block are called in OB35 with a cyclic interrupt time of
100 ms. When OB100 starts, the restart bits of the controller and process are set.
INV
+ + OUTV
Parameter
After adding the analog input signal and a load (disturbance variable) and then
multiplying with the process gain, the process values pass through three 1st order
time lags. Finally, the value of the ambient temperature is added.
If the controller is initialized with COM_RST = TRUE, the output variable is set to
OUTV = (INV + DISV) * GAIN + AMB_TEM.
The controller can be changed to manual at the MAN_ON switch. The manual
value can be set at MAN. After a warm restart on the CPU, the controller is in
manual with the heating off.
If you want to tune the controller, set the TUN_ON bit and enter a setpoint at SP.
You can monitor the tuning at the PHASE parameter.
The result of the tuning can be seen at the status words STATUS_H and
STATUS_D.
zEn 13
Process value
Setpoint
Process value
Manip. variable
Zoom
The screenshot above shows the controller tuning when heating from ambient
temperature 20°C to the operating point (60°C). Following this, a setpoint step
change from 60°C to 85°C is made within the control zone. The overshoot can be
eliminated by reducing PFAC_SP from 0.8 to 0.6.
INV_UP OUTV
SP QLMNUP
TCONT_S, PROC_S,
PV DB_TCONT_S DB_PROC_s
QLMNDN
INV_DOWN
Program Structure
The controller and process are called in OB35. When OB100 starts, the restart bits
of the controller and process are set.
The following schematic is the block diagram of the PROC_S controlled process
with actuator:
INV_UP LMNR
INV_DOWN QLMNR_HS
QLMNR_LS
MTR_TM LMNR_HLM
LMNR_LLM
+ + OUTV
Parameter
Depending on the input signals INV_UP and INV_DOWN, the position feedback
signal LMNR is calculated by an integrator. The position feedback signal is limited
to LMNR_HLM and LMNR_LLM. When the limit is reached, the limit stop signals
QLMNR_HS or QLMNR_LS are set.
After adding a disturbance variable and then multiplying by the process gain, the
process values pass through three 1st order time lag elements.
If the controller is initialized with COM_RST = TRUE, the output variable is set to
OUTV = (LMNR + DISV)*GAIN + AMB_TEM.
The controller can be changed to manual at the LMNS_ON switch. After a warm
restart on the CPU, the controller is in manual. If LMNS_ON is set, the outputs
QLMNUP or QLMNDN can be controlled at the inputs LMNUP or LMNDN in
manual mode.
zEn 13
Process value
Setpoint
Prosess value
Manip. variable
Zoom
The schematic above first shows a setpoint step change from 20°C to 36°C. The
manipulated variable limit is not reached, the temperature overshoots by
approximately 5°C (30%). With the subsequent setpoint step change from 36°C to
70°C, the upper limit of the manipulated variable is reached. This avoids overshoot
of the process variable.
If you want to avoid overshoot with small setpoint changes as well, you must
reduce PFAC_SP (for example, from 1.0 to 0.8).
A Appendix
Block Name FB No. Load Memory Req. Work Memory Req. Local Data
TCONT_CP FB 58 8992 Bytes 8156 144
TCONT_S FB 59 2282 Bytes 1966 64
Measured with:
Appendix
A.3 DB Assignment
Parameters:
Appendix
Appendix
Appendix
Internal Parameters
Appendix
Appendix
Appendix
Appendix
Appendix
Appendix
Appendix
Appendix
Parameter:
Appendix
Appendix
Internal Parameters
Appendix
Appendix
STATUS_D Description
0 No controller parameters were calculated
110 N_PTN <= 1.5 process type I fast
121 N_PTN > 1.5 process type I
122 N_PTN = 1.9 process type I after Phase 7 (previously N_PTN > 1.9)
200 N_PTN > 1.9 process type II (intermediate range)
310 N_PTN >= 2.1 process type III fast
320 N_PTN > 2.6 process type III
Note
If you stop the tuning in phase 1 or 2, STATUS_H is set to 0. STATUS_D,
however, continues to indicate the status of the last controller calculation.
The higher the value of STATUS_D, the higher the order of the controlled
process, the higher the ratio TU/TA and the softer the controller parameters.
Appendix
Abbr./Acronym Explanation
LMNR_LS Lower limit stop signal of the position feedback signal
LMNS_ON Activate manual mode for actuating signals
LMNUP Actuating signal up
LOAD_PID Load tuned PID parameters
MAN Manual value
MAN_ON Activate manual mode
MTR_TM Motor actuating time [s]
N_PTN Process order
NOI_PVDT Noise proportion in PVDT_MAX in %
NOISE_PV Absolute noise in process value
P_B_TM Minimum pulse/minimum break time [s]
P_INF Process value at point of inflection – PV0
PAR_SAVE Saved PID controller parameters
PER_MODE Periphery mode
PER_TM Pulse repetition period [s]
PFAC_SP Proportional factor for setpoint changes
PHASE Phase indicator for controller tuning
PI_CON PI controller parameter
PID_CON PID controller parameter
PID_ON Activate PID mode
POI_CMAX Maximum no. of cycles after the point of inflection
POI_CYCL Number of cycles after the point of inflection
PULSE_ON Activate pulse generator
PULSE_TM Minimum pulse time [s]
PV Actual value
PV_FAC Process value factor
PV_IN Process value input
PV_OFFS Process value offset
PV_PER Process value periphery
PV0 Process value at start of tuning
PVDT Current process value rate of rise [1/s]
PVDT_MAX Max. change of process value per second [1/s]
PVDT0 Process value rate of rise at start of tuning [1/s]
PVPER_ON Activate process value periphery
QC_ACT Continuous controller action will be processed at the next call
QLMN_HLM High limit of the manipulated variable reached
QLMN_LLM Low limit of the manipulated variable reached
Abbr./Acronym Explanation
QLMNDN Actuating signal down
QLMNUP Actuating signal up
QPULSE Pulse output
QTUN_RUN Tuning active (phase 2)
SAVE_PAR Save current controller parameters
SELECT Selection of the call for PID and pulse generator
SP_INT Internal setpoint
STATUS_D Status controller design of the controller tuning
STATUS_H Status heating of the controller tuning
T_P_INF Time to point of inflection [s]
TA Time response of the process (recovery time) [s]
TD Derivative time constant [s]
TI Integral time constant or reset time [s]
TM_LAG_P Time constant of a PTN model [s]
TU Time lag of the process (delay time) [s]
TUN_DLMN Delta manipulated variable for process excitation
TUN_KEEP Keep tuning mode
TUN_ON Activate controller tuning
TUN_ST Start controller tuning
UNDO_PAR Undo controller parameter change
Index
feedforward control .................................... 2-7
C initialization ............................ 2-15, 2-16, 2-19
instance DB ............................................... A-2
Control............................................................6-1 integrator.................................................... 2-6
Controller sampling time.............. 2-16, 2-17, 4-7 manipulated variable calculation...... 2-7, 2-10,
Controller tuning .............................................3-1 ...............................2-12, 2-13, 3-2, 3-4, 3-5
improving..................................................3-16 manipulated variable limitation................... 2-9
messages ................................................ A-17 manipulated variable normalization ........... 2-9
phases........................................................3-4 manual value processing ........................... 2-8
problems ..................................................3-12 PID algorithm ............................................. 2-5
result ........................................................3-11 preparations............................................... 3-6
starting .......................................................3-8 process value format conversion ............... 2-2
stopping....................................................3-11 process value normalization ...................... 2-2
strong heat coupling .................................3-18 process value normalization, example ....... 2-3
weak heat coupling...................................3-19 process value options ................................ 2-2
Cooling ...........................................................1-3 pulse generator........................................ 2-12
Cooling process .............................................1-3 reloading controller parameters ............... 2-10
CYCLE .........................................................2-16 sampling time of the pulse generator ....... 2-16
CYCLE_P ............................................2-16, 2-18 saving controller parameters.................... 2-10
setpoint branch .......................................... 2-1
D structure outline ......................................... 1-3
weakening the P action.............................. 2-6
Disturbances ..................................................3-3 FB 59 "TCONT_S" ......................................... 1-4
application.................................................. 1-4
E block diagram ............................................ 4-5
deadband................................................... 4-3
Example with FB 58 "TCONT_CP".................6-2
description ................................................. 1-4
error formation .................................... 4-1, 4-3
F initialization ................................................ 4-7
FB 58 "TCONT_CP" instance DB ............................................. A-13
application ..................................................1-3 PI step controller algorithm ........................ 4-4
block diagram ...........................................2-14 process value conversion .......................... 4-2
block diagram error formation ....................2-1 process value normalization ...................... 4-2
block diagram PID algorithm .... 2-4, 2-7, 2-10, process value options ................................ 4-1
.............................. 2-12, 2-13, 3-2, 3-4, 3-5 sampling time............................................. 4-7
block diagram saving and reloading controller setpoint branch .......................................... 4-1
parameters ...........................................2-10 Fine tuning in control mode ......................... 3-16
control zone................................................2-7
controller sampling time ..................2-16, 2-17 G
controller tuning..........................................3-1
Getting Started............................................... 5-1
cooling process ..........................................1-3
deadband ...................................................2-4
description..................................................1-4 I
error formation.....................................2-1, 2-3 Instance DB for FB 58 "TCONT_CP"............. A-2
example....................................... 6-2, 6-6, 6-7 Instance DB for FB 59 "TCONT_S" ............. A-13
Index
M R
Messages during tuning...............................A-17 Readme file ....................................................1-2
O S
Operating range ............................................. 3-3 Sample for FB 58 "TCONT_CP"............. 6-6, 6-7
Sample for FB 59 "TCONT_S" .....................6-11
P Sampling time of the pulse generator...........2-16
Software
PI step controller algorithm ............................ 4-4 installing .....................................................1-1
feedforward control .................................... 4-4 STATUS_H.................................................. A-17
Process type
checking................................................... 3-10
Process types ................................................ 3-2
T
Product structure............................................ 1-1 Transient response.........................................3-3