• No results found

PID Application Example

In document ACE3600 STS Advanced Features (Page 168-181)

General

This application is used to control water flow by changing the position of a regulating valve. The flow is measured by an Analog Input (range: 0-15000 liter/hour). The valve position is controlled by an Analog Output (range: 0-100%).

The database used in this example is described below. Each table in the database is shown as it appears in the application. Each variable used in the tables is described. Finally the application process rungs are described as they have been implemented in the sample project.

Glossary

CV - Controlled Value: The measured or calculated process input SP - Process SetPoint value

Err - Process error = SP - CV

AO - Process Analog Output: Sets the position of the controlled element

PID control function

A PID control function is used to set an analog output as a function of a process setpoint and a feedback analog signal of the controlled value. The function include three

adjustments, each of which is represented in the PID table by a variable:

 Proportional (pidK variable)

 Integral (pidKi variable)

 Derivative (pidKd variable)

The application includes additional features, such as:

 Operation Mode – Manual (set by operator) or Automatic (PID) mode.

 Validity Check - The process variables are to be within a predefined valid range.

 Cycle time - Time interval between consecutive calculations of PID function The impact of the three adjustments of the PID is as follows:

1. The proportional part of the PID function contributes to its output the result of

(PidK) * (Err). That means that AO increases when Err increases, and AO decreases when Err decreases, by the proportional gain PidK.

The PID function does not put a limit to the proportional part. In certain cases, when Err is large, it may cause the AO to be changed by large steps and to reach its limits. This may cause fluctuations in analog output and unstable condition of the controlled process. In order to prevent this problem, the application reduces the PidK when Err is large. Thus the Integral action is dominant when Err is large, and the Proportional action is more dominant when Err is small.

PID LOOP - Proportional Integral Derivative

Note: Setting the PID function parameters requires some knowledge about tuning PID loops. The current version of PID function and the application example described below, does not include 'self tuning' feature. The user has to set them manually, write additional application or use external PC based software for this purpose.

2. The integral part of the PID contributes to its output the result of

[(PidK*PidKi) * Integral of (Err)], where the summation is performed every time the PID calculation is performed. That means that AO increases as long as Err is positive, and AO decreases as long as Err is negative. The summation result is stored in the PidInt variable, where it can be set by the application too.

The PID function does not put a limit to the integral part. In certain cases, this may cause the AO to reach its low or high limits. The application, as explained later, has to deal with such situations.

3. The derivative part of the PID contributes to its output the result of

(PidK*PidKd) * (Err rate of change). That means that AO increases as long as Err rate of change is positive, and AO decreases as long as Err rate of change is negative. If Err is constant the derivative portion of the PID function equals to zero.

In the described example the derivative factor was set to zero, since its action is not required for flow control.

Operation Mode

A PID loop can be either in Auto mode or in Manual mode. In Auto mode, the operator can set the required flow and the PID function sets the AO according to process conditions.

In Manual mode, the operator can set the position of the regulating valve directly, and the PID function results are ignored.

The ACE3600 application handles the transition from one operation mode to the other.

Validity Check

The controlled value of a loop is usually an analog input. The application in the following example also supports the validity check of the CV, in order to prevent loop malfunction.

The PID setpoint is also checked to be within predefined limits. If it exceeds these limits, it is operates according to the minimum or maximum setpoint range accordingly.

Moreover, the resulting AO of the PID function is also checked for validity before updating the physical analog output.

The PID application, described in this section, uses the built in PID table, with additional User tables and process, to control the CV (e.g. pipe flow) by setting the position of the AO (e.g. regulating valve). The inputs of the function are the required flow (SP) and the

measured flow (CV).

Database Tables

The database tables are shown below. Each variable used in the tables is described.

PID LOOP - Proportional Integral Derivative

Operator Interface Table

This table contains the variables that can be set by the operator who controls the process via an HMI station:

CV_Set - Controlled Value setting for PID loop in Auto mode AO_Set - Analog Output setting for PID loop in Manual mode ModSet - Setting of PID loop Operation mode (1 = Auto, 0 = Manual)

PID Table

The PID function runs according to the following variables:

pidIN - PID controlled value input. - Represents the controlled value (CV). This value is not linked directly to the analog input and is updated by application. The scaling of the input can be defined in this column, by setting the EGU Zero and EGU High accordingly.

PID LOOP - Proportional Integral Derivative

pidSP - Represents the process setpoint (SP)

pidK - Proportional gain factor. A default value is defined in the table. Application changes the value according to Err value, as explained later.

pidKd - Differential factor. Equals zero. Not used for flow control process.

pidKi - Integral factor. A default value for the integral part mutiplier is defined in the table.

However, application changes this value when the relevant pidK is changed, as explained later

pidInt - Accumulated (calculated) integral part.

pidDb - PID Process output deadband sets the minimum step of change in the PID function output. In the application example it is set to zero. For fast response process this value should be kept to a minimum.

pidOUT - PID function output. This value is not linked directly to the analog output. The scaling of the output can be defined in this column, by setting the EGU Zero and EGU High accordingly. For the process in this example the output range is defined as 0 - 100 (%). Its value is checked to be in a certain range before updating the analog output variable.

PID I/O Table

This table is used to link the process CV analog input and AO analog output. The values are scaled to 0 - 100 percent.

Table name: PID I/O COS name:

Table symbol: Last index (Ind): 0

Last index name:

Ind Pid_AI (sAI)

Pid_AO (sAO) 0

Ind Pid_AI EGU Zero (%) EGU Zero EGU High 100%=Full Scale

0 20%=Live Zero 0.0 100.0

Ind Pid_AO EGU Zero (%) EGU Zero EGU High 100%=Full Scale

0 20%=Live Zero 0.0 100.0

Pid_AI - PID loop controlled value analog input (linked to an AI module) Pid_AO - PID loop analog output (linked to an AO module)

EGU Zero–used to define the scaling of the PID controlled value input pidIN

PID LOOP - Proportional Integral Derivative

EGU High –used to define the scaling of the PID controlled value input pidIN

PID P & I Parameters Table

These parameters are used to define the basic proportional and integral factors.

Table name: PID P & I Parameters COS name:

Table symbol: Last index (Ind): 0

Last index name:

Ind PID_P (rprm)

PID_I (rprm) 0 3.0-4 10.0

PID_P - Proportional factor (also multiplies the Integral part) PID_I - Integration factor

PID Parameters Table

This table includes user definable parameters that are used to check validity of input (CV) or output (AO) of the PID function.

Table name: PID Parameters COS name:

Table symbol: Last index (Ind): 0

Last index name:

Ind AlrDB (rprm)

AlrTim Mn:Sc

CV_Min (rprm)

CV_Max (rprm)

AO_Min (rprm)

AO_Max (rprm)

0 5.0 05:00 0.0 15000.0 0.0 100.0

AlrDB - PID alarm dead band (percent of full scale)

AlrTim - Time delay to set the PID alarm flag. This alarm indicates that the PID process value did not reach the setpoint within the AlrDB range within this time delay.

CV_Min - Minimum value of CV (controlled value) CV_Max - Maximum value of CV (controlled value) AO_Min - Minimum value of AO (analog output) AO_Max - Maximum value of AO (analog output)

PID LOOP - Proportional Integral Derivative

PID Flags Table

The variables of this table are used for checking the existing error (SP-CV) of the PID loop.

Table name: PID Flags COS name:

Table symbol: Last index (Ind): 0

Last index name:

Ind PidDif (real)

DifTmp (real)

RTemp (real)

O_Max (bit)

O_Min (bit)

PidAlr (bit) 0

PidDif - Difference (Err) between setpoint (SP) and process controlled value(CV) DifTmp – Process error in CV engineering units

RTemp - Process error in percents of CV full scale

O_Max - Temporary bit. Indicates that output has reached its maximum position (AO_Max)

O_Min - Temporary bit. Indicates that output has reached its minimum position (AO_Min) PidAlr - Pid loop alarm flag. This alarm indicates that the PID process value did not reach its setpoint (including the AlrDB deadband) within the predefined time (AlrTim)

Second Timers Table

Table name: Second Timers COS name:

Table symbol: Last index (Ind): 0

Data type: Timers Second (Sc:Ms)

Ind Name Value

0 TPID 01:00

TPID - PID calculation time interval (multiplied by 10 ms). The timer preset value is set by PtPID.

User Flags Table

Table name: User Flags COS name:

Table symbol: Last index (Ind): 0

Data type: Discrete (bit)

Ind Name Value

0 BTemp

Btemp - Temporary flag

PID LOOP - Proportional Integral Derivative

User Parameters Table

Table name: User Parameters COS name:

Table symbol: Last index (Ind): 0

Data type: Integer Parameter (iprm)

Ind Name Value

0 PtPID 100

PtPID - A parameter to set PID calculation time interval (10msec resolution). The minimum setting for running 8 PID loops is 100 (1 second).

Constants

The application uses the following constants:

Integer Constants - Manual = 0, Auto = 1 Real Constants - R0 = 0.0, R100 = 100,0

Programming Process Rungs

The chart below lists the rungs which have been programmed for application.

Rung Description

P05 Scan PID AI

P10 Reset Index p

PL10 Local Setpoints

PL12 Local Setpoints

P18 Manual mode limits

P20 Manual Mode

P21 Jmp P50 if no TPID

P25 Auto Mode

P30 Check Input range P50 Increment Index p P60 Check Index p

P90 Run PID Calc

M91 Jmp P200 if no TPID P100 Reset Index p P110 Check Output range P112 Calc PID loop error P113 Set PI factors

PID LOOP - Proportional Integral Derivative

P114 Set O_Max flag P115 Set O_Min flag P130 Increment Index p P140 Check Index p P200 Scan analog output P210 Run PID Timer

The following are the actual rungs of the application.

Rung P05: Scan the analog input (CV) of the PID loop.

Pid_AI (SCAN) P05

Rung P10: The number of PID loops which are controlled by the application is set by the number of rows in the PID Table. The same application with an index 'p' handles all loops.

This rung resets 'p' index to run the first PID loop.

p ( RST ) P10

Rung PL12: In Auto mode, the Pid_AO is always copied to AO_Set. This enables smooth transition to Manual mode without a step change in the loop SP.

ModSet,p

Rung P18: In Manual mode, the AO_Set value is checked to be within a predefined range (AO_Min and AO_Max). If it exceeds these limits, the output is set to the relevant limit.

ModSet,p

Rung P20: In Manual mode, the Pid_AI is checked to be within a predefined range (CV_Min and CV_Max) and copied to CV_Set. This enables smooth transition to Auto mode without a step change in the loop PidSp.

PID LOOP - Proportional Integral Derivative

In addition, the AO_Set value is checked to be within a predefined range (AO_Min and AO_Max) and is copied to Pid_AO, and PidInt. Updating the latter variable is also important to keep the AO in the last position when loop mode is changed to Auto, while there is no change in the setpoint.

Pid_AI,p

Rung P21: Skips the next two rungs when PID loop is not calculated.

TPID /

P50 ( JMP ) P21

Rung P25: In Auto mode, the CV_Set (set by the operator) is checked to be within a predefined range (CV_Min and CV_Max) and copied to PidSp. In addition the AO_Set value is updated by the Pid_AO.

CV_Set,p

PID LOOP - Proportional Integral Derivative

Rung P30: In Auto mode, the Pid_AI is checked to be within a predefined range (CV_Min and CV_Max) and copied to PidIn accordingly.

Pid_AI,p

Rung P50: Counts up (increments) the index counter (to execute the next loop).

p

P50 ( CTU )

Rung P60: Checks the index counter.

PL10

Rung P90: Runs the PID calculation on all loops every TPID interval.

TPID P90

P.I.D.

( CALL )

Rung M91: Skips the next rungs, which check the PID function results, if PID function was not performed.

TPID M91 /

P200 ( JMP )

PID LOOP - Proportional Integral Derivative

Rung P100: Resets a new index.

p ( RST ) P100

Rung P110: Checks the PidOut (PID function output) to be within a predefined range (AO_Min and AO_Max), and copies it to Pid_AO accordingly.

ModSet,p

Rung P112: PID loop performance is checked. If the output fails to be within a predefined range (PidSp +/- AlrDB) for longer than AlrTim, an alarm flag (PidAlr) is set.

ModSet,p RTemp,p = DifTmp,p/(CV_Max,p - CV_Min,p) * (R100)

PID LOOP - Proportional Integral Derivative

Rung P113: In order to prevent large fluctuations in output when Rtemp (process error in percents) is greater than AlrDb (user defined parameter), the application divides the PidK by a constant 100. In order to keep the integral factor unchanged, it is multiplied by the same constant. Thus, the Integral action is dominant when process error is large, and the Proportional action is more dominant when process error is small.

ModSet,p

Note: The constant is used for the example only. For a practical PID loop, the proper constant (or other type of handling these factors) must be implemented.

Rung P114: In Auto mode, when PidOut exceeds AO_Max, it is kept at that level. The first time the process error becomes negative, the AO_Max is copied to PidInt. This operation eliminates the effect of positive accumulated value of the Integral portion when AO is in its maximum position.

PID LOOP - Proportional Integral Derivative

Rung P115: In Auto mode, when PidOut exceeds AO_Min, it is kept at that level. The first time the process error becomes positive, the AO_Min is copied to PidInt. This operation eliminates the effect of negative accumulated value of Integral portion when AO is in its minimum position.

Rung P130: Counts up (increments) the index counter (to execute the next loop).

p ( CTU ) P130

Rung P140: Checks the index counter.

p

Rung P200: Writes the resulting analog output to Pid_AO by Scan operation.

Pid_AO ( SCAN ) P200

Rung P210: Sets and runs the TPID timer.

TPID

In document ACE3600 STS Advanced Features (Page 168-181)