Table of Contents Previous Chapter Chapter 25: pid - PID Control

Chapter 25: pid - PID Control

1. Introduction

The pid record type provides a Proportional, Integral, and Derivative (PID) control algorithm. A discrete form of the PID algorithm is:

Mn = KP * (Eν + KI * ΣϒMι (Eι*δTι)) + KΔ * (Eν - Eν-1)/δTν + Mρ

Where:

Taking the first difference yields:

delM(n) = KP * ((Eν-Eν-1) + Eν * δTν * KI + KΔ * ((Eν -Eν-1)/δTν - (Eν-1 -Eν-2)/δTν-1))

For this record:

2. Field Summary

--------------------------------------------------------------
Field  Type       DCT  Initial  Access  Modify  Rec Proc   PP   
                                                Monitor         
--------------------------------------------------------------
VAL    FLOAT      No   0        Yes     Yes     Yes        Yes  
CVL    INLINK     Yes  0        No      No      N/A        No   
STPL   INLINK     Yes  0        No      No      N/A        No   
SMSL   GBLCHOICE  Yes  0        Yes     Yes     No         No   
PREC   SHORT      Yes  0        Yes     Yes     No         No   
MDT    FLOAT      Yes  0        Yes     Yes     No         No   
KP     FLOAT      Yes  0        Yes     Yes     No         No   
KI     FLOAT      Yes  0        Yes     Yes     No         No   
KD     FLOAT      Yes  0        Yes     Yes     No         No   
EGU    STRING     Yes  Null     Yes     Yes     No         No   
HOPR   FLOAT      Yes  0        Yes     Yes     No         No   
LOPR   FLOAT      Yes  0        Yes     Yes     No         No   
HIHI   FLOAT      Yes  0        Yes     Yes     No         No   
LOLO   FLOAT      Yes  0        Yes     Yes     No         No   
HIGH   FLOAT      Yes  0        Yes     Yes     No         No   
LOW    FLOAT      Yes  0        Yes     Yes     No         No   
HHSV   GBLCHOICE  Yes  0        Yes     Yes     No         No   
LLSV   GBLCHOICE  Yes  0        Yes     Yes     No         No   
HSV    GBLCHOICE  Yes  0        Yes     Yes     No         No   
LSV    GBLCHOICE  Yes  0        Yes     Yes     No         No   
HYST   FLOAT      Yes  0        Yes     Yes     No         No   
ADEL   FLOAT      Yes  0        Yes     Yes     No         No   
MDEL   FLOAT      Yes  0        Yes     Yes     No         No   
ODEL   FLOAT      Yes  0        Yes     Yes     No         No   
CVAL   FLOAT      No   0        Yes     Yes     No         No   
DM     FLOAT      No   0        Yes     No      Yes        No   
ODM    FLOAT      No   0        Yes     No      Yes        No   
P      FLOAT      No   0        Yes     No      Yes        No   
I      FLOAT      No   0        Yes     No      Yes        No   
D      FLOAT      No   0        Yes     No      Yes        No   
CT     ULONG      No   0        Yes     No      Yes        No   
DT     FLOAT      No   0        Yes     No      Yes        No   
ERR    FLOAT      No   0        Yes     No      Yes        No   
DERR   FLOAT      No   0        Yes     No      Yes        No   
LALM   FLOAT      No   0        Yes     No      No         No   
ALST   FLOAT      No   0        Yes     No      No         No   
MLST   FLOAT      No   0        Yes     No      No         No   
--------------------------------------------------------------

3. Field Descriptions

----------------------------------------------------------------------------------------
Name  Summary               Description                                                   
----------------------------------------------------------------------------------------
VAL   Setpoint Value, in    This is the value that the control algorithm attempts to      
      engineering units     achieve.                                                      
CVL   Controlled Value      This is a link specifying the location of the controlled      
      Location (input       variable. This must be a database link. Each time the         
      link)                 record is processed the current value referenced by CVL is    
                            read into CVAL.                                               
STPL  Setpoint Location     If STPL is a database or channel access link and SMSL is      
      (input link)          CLOSED_LOOP, then VAL is read from STPL. STPL and             
                            SMSL act just like DOL and OMSL.                              
SMSL  Setpoint Mode         This is SUPERVISORY or CLOSED_LOOP. VAL is                    
      Select                obtained from STPL only when this is CLOSED_LOOP.             
                            By setting this field, the record can be switched between     
                            supervisory and closed loop. Note that closed loop is         
                            useful for cascaded control records.                          
PREC  Display Precision     Precision with which to display VAL.  This field is used by   
                            record support to supply a value when get_precision           
                            is called.                                                    
MDT   Minimum Delta         Minimum time difference between processing in seconds.        
      Time, in seconds      If this is zero, the minimum time is one clock tick.          
KP    Proportional Gain                                                                   
KI    Integral Gain, in     The number of times per minute that the integral              
      repeats per minute    contribution repeats the proportional contribution.           
KD    Derivative Gain, in   The number of minutes until the derivative contribution       
      minutes per repeat    repeats the proportional contribution.                        
EGU   Engineering Units     ASCII string describing Engineering units.  This field is     
                            used by record to supply a units description string when      
                            get_units is called.                                          
HOPR  High Operating        These fields determine the upper and lower display limits     
      Range                 for graphics displays and the upper and lower control         
                            limits for control displays. The fields are used by record    
                            support to honor calls to get_graphic_double or               
                            get_control_double.                                           
LOPR  Low Operating                                                                       
      Range                                                                               
HIHI  Hihi Alarm Limit      These fields specify the alarm limits and severities.         
HIGH  High Alarm Limit                                                                    
LOW   Low Alarm Limit                                                                     
LOLO  Lolo Alarm Limit                                                                    
HHSV  Severity for a Hihi                                                                 
      Alarm                                                                               
HSV   Severity for a High                                                                 
      Alarm                                                                               
LSV   Severity for a Low                                                                  
      Alarm                                                                               
LLSV  Severity for a Lolo                                                                 
      Alarm                                                                               
HYST  Alarm Deadband        These parameters specify hysteresis factors for triggering    
                            monitor callbacks, i.e. monitors specified by calls to        
                            caAddEvent or dbAddEvent. A monitor will not be               
                            triggered until VAL changes by more than the specified        
                            amount.                                                       
ADEL  Archive Deadband                                                                    
MDEL  Monitor, i.e. value                                                                 
      change, Deadband                                                                    
ODEL  Output Delta          This parameter specifies a hysteresis factor for triggering   
                            monitor callbacks for DM, P, I, D, CT, DT, ERR, and DERR.     
                            It refers to the change in DM. Whenever monitors are          
                            triggered for DM, monitors for the other fields are also      
                            triggered.                                                    
CVAL  Value of Controlled   This value is obtained from CVL each time the record is       
      Variable, in          processed.                                                    
      engineering units                                                                   
DM    Change in             This is the value computed by the pid algorithm. It is an     
      Manipulated           increment to be added to the controller output. Note that     
      Variable              in most cases this will be read via the DOL field of an       
                            analog output record. The analog output record will be        
                            configured with OIF set to incremental.                       
ODM   Old DM                ODM is used to decide if monitors should be triggered for     
                            DM.                                                           
P     Proportional          Proportional contribution to DM, in engineering units.        
      contribution                                                                        
I     Integral              The number of times per minute that the integral              
      contribution to       contribution repeats the proportional contribution.           
      DM, in repeats per                                                                  
      minute                                                                              
D     Derivative            The number of minutes until the derivative contribtuion       
      contribution to       repeats the proportional contribution.                        
      DM, in minutes                                                                      
CT    Clocks Ticks          Clock ticks when previous process occurred.                   
DT    Time difference       Time difference in seconds between processing steps.          
ERR   Error                 Current error (VAL - CVAL).                                   
DERR  Delta Error           Change in error since last time step.                         
LALM  Value when last       These fields are used to implement the hysteresis factors     
      monitors for alarm    for monitors.                                                 
      were triggered                                                                      
ALST  Value when last                                                                     
      monitors for                                                                        
      archiver were                                                                       
      triggered                                                                           
MLST  Value when last                                                                     
      monitors for value                                                                  
      changes were                                                                        
      triggered                                                                           
----------------------------------------------------------------------------------------

4. Record Support Routines

init_record

This routine initializes VAL with the value of STPL and sets UDF to FALSE if STPL type is CONSTANT link or creates a channel access link if STPL type is PV_LINK.

process

See next section.

get_value

Fills in the values of struct valueDes so that they refer to VAL.

get_units

Retrieves EGU.

get_precision

Retrieves PREC.

get_graphic_double

Sets the upper display and lower display limits for a field. If the field is P, I, D, CVAL, VAL, HIHI, HIGH, LOW, or LOLO, the limits are set to HOPR and LOPR, else if the field has upper and lower limits defined they will be used, else the upper and lower maximum values for the field type will be used.

get_control_double

Sets the upper control and the lower control limits for a field. If the field is P, I, D, CVAL, VAL, HIHI, HIGH, LOW, or LOLO, the limits are set to HOPR and LOPR, else if the field has upper and lower limits defined they will be used, else the upper and lower maximum values for the field type will be used.

get_alarm_double

Sets the following values:

  upper_alarm_limit = HIHI
  upper_warning_limit = HIGH
  lower_warning_limit = LOW
  lower_alarm_limit = LOLO

5. Record Processing

Routine process implements the following algorithm:

  1. If CVL is not a database link, a major alarm is declared and the algorithm completes.
  2. The current value of CVAL is obtained from CVL.
  3. If STPL is a database or channel access link and SMSL is CLOSED_LOOP, then VAL is obtained from STPL and UDF is set to FALSE.
  4. The time difference since the last time step is calculated. If it is less than MDT or if no ticks have occurred since the last time the algorithm was executed, process just completes without raising any alarms, checking monitors, or scanning the forward link.
  5. The new values of P, I, D, OUT, CT, DT, ERR, and DERR are computed.
  6. Check alarms. This routine checks to see if the new VAL causes the alarm status and severity to change. If so, NSEV, NSTA and LALM are set. It also honors the alarm hysteresis factor (HYST). Thus the value must change by more than HYST before the alarm status and severity is lowered.
  7. Check to see if monitors should be invoked.
  8. Scan forward link if necessary, set PACT FALSE, and return.
 
Table of Contents Next Chapter