The text of a manual · part 41 of 55
Hand-Held Terminal (Catalog Number 1747-PT1) User Manual: 26 - PID Instruction, pages 353 to 360
Pages 353 to 360 of 486, from Hand-Held Terminal (Catalog Number 1747-PT1) User Manual
The original document is the PDF (1.5 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Allen-Bradley 1747-PT1
Page 353
Chapter 26 PID Instruction
Control Block Layout 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 EN
DN PV SP LL UL DB
TF SC
OL CM AM TM
Word 0
PID Sub Error Code (MSbyte)*
1
Setpoint SP *
2
Gain KC *
3
Reset Ti *
4
Rate Td *
5
Feed Forward Bias*
6
Setpoint Max (Smax) *
7
Setpoint Min (Smin) *
8
Deadband *
9
INTERNAL USE
DO NOT CHANGE
OL, CM, AM, TM *
10
Output Max % *
11
Output Min % *
12
Loop Update *
13
Scaled Process Variable
14
Scaled Error SE
15
Control Output Percent CO (0–100%)
16
LSW Integral Sum
17
MSW Integral Sum
18 19
INTERNAL USE DO NOT CHANGE
20 21 22
* You may alter the state of these values with your ladder program.
! PID Instruction Flags
ATTENTION: Do not alter the state of any PID control block value unless you fully understand its function and related effect on your process.
Instruction flags are in the first word of the control block. They include: • Time mode bit TM (word 0, bit 0) – This bit specifies the PID mode. It is set when the TIMED mode is in effect. It is cleared when the STI mode is in effect. This bit can be set or cleared by instructions in your ladder program. • Auto/manual bit AM (word 0, bit 1) – This bit specifies automatic operation when it is cleared and manual operation when it is set. This bit can be set or cleared by instructions in your ladder program. • Control mode bit CM (word 0, bit 2) – This bit is cleared if the control is E=SP–PV (reverse). It is set if the control is E=PV–SP (forward). This bit can be set or cleared by instructions in your ladder program. 26–9
Page 354
Chapter 26 PID Instruction
• Output limiting enabled bit OL (word 0, bit 3) – This bit is set when you have selected to limit the control variable. This bit can be set or cleared by instructions in your ladder program. • Scale setpoint flag SC (word 0, bit 5) – This bit is cleared when setpoint scaling values have been specified. • Loop update time too fast TF (word 0, bit 6) – This bit is set by the PID algorithm if the loop update time you have specified cannot be achieved by the given program (because of scan time limitations). If this bit is set, try to correct the problem by updating your PID loop at a slower rate or move the PID instruction to an STI interrupt routine. Reset and rate gains will be in error if the instruction operates with this bit set.
• deadband range DB (word 0, bit 8) – This bit is set when the process • • • • • •
26–10 variable or error is within the deadband range. Output alarm, upper limit UL (word 0, bit 9) – This bit is set when the calculated control output CV exceeds the upper CV limit. Output alarm, lower limit LL (word 0, bit 10) – This bit is set when the calculated control output CV is less than the lower CV limit. Setpoint out of range SP (word 0, bit 11) – This bit is set when the setpoint exceeds the maximum scaled value or is less than the minimum scaled value. Process var out of range PV (word 0, bit 12) – This bit is set when the unscaled (or raw) process variable exceeds 16383 or is less than zero. PID done DN (word 0, bit 13) – This bit is set on scans where the PID algorithm is computed. (It is computed at the loop update rate.) PID enabled EN (word 0, bit 15) – This bit is set while the rung of the PID instruction is enabled.
Page 355
Chapter 26 PID Instruction
Runtime Errors
Error Code (Decimal)
Error Code (Hex)
4352
Error code 0036 appears in the status file (S:6) when a PID instruction runtime error occurs. Code 0036 covers the following PID error conditions, each of which has been assigned a unique single byte code value that appears in the MSbyte (most significant byte or upper 8 bits) of the second word (word 1) of the PID control block.
Description of Error Condition or Conditions
Corrective Action
11H
1) Loop update time Dt > 255, or 2) Loop update time Dt = 0
Change loop update time Dt to 0 < Dt < 255
4608
12H
1) Proportional gain Kc > 255, or 2) Proportional gain Kc = 0
Change proportional gain Kc to 0 < Kc < 255
4864
13H
Integral gain (reset) Ti > 255
Change integral gain (rate) Ti to 0 < Ti < 255
5120
14H
Derivative gain (rate) Td > 255
Change derivative gain (rate) Td to 0 < Td < 255
8448
21H
1) Scaled setpoint max Smax > 16383, or 2) Scaled setpoint max Smax < –16383
Change scaled setpoint max Smax to –16383 < Smax < 16383
8704
22H
1) Scaled setpoint min Smin > 16383, or 2) Scaled setpoint min Smin < –16383
Change scaled setpoint min Smin to –16383 < Smin < Smax < 16383
8960
23H
Scaled setpoint min Smin > Scaled setpoint max Smax
Change scaled setpoint min Smin to –16383 < Smin < Smax < 16383
12544
31H
If you are using setpoint scaling and Smin > setpoint SP > Smax, or
If you are using setpoint scaling, then change the setpoint SP to Smin < SP < Smax, or
If you are not using setpoint scaling and 0 > setpoint SP > 16383,
If you are not using setpoint scaling, then change the setpoint SP to 0 < SP < 16383.
then during the initial execution of the PID loop, this error occurs and bit 11 of word 0 of the control block is set. However, during subsequent execution of the PID loop if an invalid loop setpoint is entered, the PID loop continues to execute using the old setpoint, and bit 11 of word 0 of the control block is set. 16640
41H
Scaling Selected
Scaling Deselected
Scaling Selected
Scaling Deselected
1) Deadband < 0, or 2) Deadband > (Smax - Smin), or 3) Deadband > 16383
1) Deadband < 0, or 2) Deadband > 16383
Change deadband to 0 < deadband < (Smax – Smin) < 16383
Change deadband to 0 < deadband < 16383
20736
51H
1) Output high limit < 0, or 2) Output high limit > 100
Change output high limit to 0 < output high limit < 100
20992
52H
1) Output low limit < 0, or 2) Output low limit > 100
Change output low limit to 0 < output low limit < output high limit < 100
21248
53H
Output low limit > output high limit
Change output low limit to 0 < output low limit < output high limit < 100
24576
60H
PID is being entered for the second time. (PID loop was inter- You have at least three PID loops in your program: One in the rupted by an I/O interrupt, which is then interrupted by the PID STI main program or subroutine file, one in an I/O interrupt file, and interrupt.) one in the STI subroutine file. You must alter your ladder program and eliminate the potential nesting of PID loops.
26–11
Page 356
Chapter 26 PID Instruction
PID and Analog I/O Scaling
For the SLC 500 PID instruction, the numerical scale for both the process variable (PV) and the control variable (CV) is 0 to 16383. To use engineering units, such as PSI or degrees, you must first scale your analog I/O ranges within the above numerical scale. To do this, use the Scale (SCL) instruction and follow the steps described below. Refer to the Analog I/O Modules User Manual, catalog number 1746–NM003 for more information. Scale your analog input by calculating the slope (or rate) of the analog input range to the PV range (0 to 16383.) For example, an analog input with a range of 4 to 20mA has a decimal range of 3277 to 16384. The decimal range must be scaled across the range of 0 to 16383 for use as PV. Scale the CV to span evenly across your analog output range. For example, an analog output which is scaled at 4 to 20mA has a decimal range of 6242 to 31208. In this case, 0 to 16383 must be scaled across the range of 6242 to 31208. Once you have scaled your analog I/O ranges to/from the PID instruction, you can enter the minimum and maximum engineering units that apply to your application. For example, if the 4 to 20mA analog input range represents 0 to 300 PSI, you can enter 0 and 300 as the minimum (Smin) and maximum (Smax) parameters respectively. The Process Variable, Error, Setpoint, and Deadband will be displayed in engineering units in the PID Data Monitor screen. Setpoint and Deadband can be entered into the PID instruction using engineering units. The following equations show the linear relationship between the input value and the resulting scaled value. Scaled value = (input value x slope) + offset Slope = (scaled max. – scaled min.) / (input max. – input min) Offset = scaled min. – (input min. x slope)
Use the following values in an SCL instruction to scale common analog input ranges to PID process variables. 4 to 20mA
0 to 5V
0 to 10V
Rate/10,000
Parameter
12,499
10,000
5,000
Offset
–4096
0
0
Use the following values in an SCL instruction to scale control variables to common analog outputs. Parameter
26–12
4 to 20mA
0 to 5V
0 to 10V
Rate/10,000
15,239
10,000
19,999
Offset
6242
0
0
Page 357
Chapter 26 PID Instruction
The following ladder diagram shows a typical PID loop that is programmed in the STI mode. This example (in APS format) is provided primarily to show the proper scaling techniques. It shows a 4 to 20mA analog input and a 4 to 20mA analog output. This rung immediately updates the analog input used for PV. IIM IMMEDIATE IN w MASK Slot I:1.0 Mask FFFF
Rung 3:0
Rung 3:1
These two rungs ensure the analog input value to be scaled remains within the limits of 3277 to 16384. This is necessary to prevent “out of range” conversion errors in both the SCL and PID instructions. The latch bits can be used elsewhere in your program to identify the particular out of range condition that occurred. Under range LES B3 LESS THAN (L) Source A I:1.0 0 Source B
0 3277
MOV MOVE Source Dest
I:1.0 0
Over range B3 (L) 1
GRT Rung 3:2
3277
GREATER THAN Source A I:1.0 0 Source B 16384
MOV MOVE Source Dest
16384 I:1.0 0
The source to be scaled is the input I:1 and its destination is the process variable of the PID instruction. These values are calculated knowing that the input range is 3277 to 16384, while the scaled range (PV) is 0 to 16383. SCL SCALE Source
Rung 3:3
Rate [/10000]
I:1.0 0 12499
Offset
–4096
Dest
N10:28 0
PID Rung 3:4
PID Control Block N10:0 Process Variable N10:28 Control Variable N10:29 Control Block Length 23
26–13
Page 358
Chapter 26 PID Instruction
Rung 3:5
The PID control variable is the input for the scale instruction. The PID instruction guarantees that the CV remains within the range of 0 to 16383. This value is to be scaled to the range of 6242 to 31208, which represents the numeric range that is needed to produce 4 to 20mA analog output signal. SCL SCALE Source
N10:29 0 Rate [/10000] 15239 Offset
6242
Dest
O:1.0 0
This rung immediately updates the analog output card that is driven by the PID control variable value. IOM IMMEDIATE OUT w MASK Slot O:1.0 Mask FFFF
Rung 3:6
END
Online Data Changes
You can monitor PID parameters and status bits when you are online under the monitor function. You can also change data in any processor mode. The following displays appear when you press the Zoom key with the cursor on the PID instruction while monitoring online. Note that in the first display you can change the mode from auto to manual and vice versa. In the auto mode, you can also change the gain parameter: ZOOM on PID –(PID)– 1/2 2.0.0.0.1 NAME: PROP INT DERIV MODE: AUTO GAIN: 25 [/10] OUT LIM: 5% ,95% RESET: 10 [/10 M/R] DEADBND: 5 RATE: 1 [/100 MIN] OUTPUT: 0% SETPOINT: 500 PROCESS: 0 ENTER GAIN: 25 PRG NEXT PG MANUAL F1
F2
F3
F4
F5
In the manual mode, you can change the maximum output percent: ZOOM on PID –(PID)– 1/2 NAME: PROP INT DERIV MODE: PROCESS: 0 SETPOINT: 500 OUTPUT: 95% MIN OUT: 5% MAX OUT: 95% ENTER OUTPUT PCT: 95 NEXT PG AUTO F1
26–14
F2
F3
2.0.0.0.1 MANUAL
PRG F4
F5
Page 359
Chapter 26 PID Instruction
The second display shows the status bits discussed in the last section: ZOOM on PID –(PID)– 2/2 2.0.0.0.1 NAME: PROP INT DERIV MODE: MANUAL LOOP UPDATE: 50 [x10ms] SET PT RANGE: –100 1000 EN DN PV SP LL UL DB TF SC OL CM AM TM 0 0 0 0 0 0 0 0 0 1 1 1 1 PRG PREV PG F1
F2
F3
F4
F5
Using Scaled Values If you are using scaled values with the PID instruction, note that the HHT Zoom display in the monitor mode indicates the unscaled value of the Process Variable PV (PROCESS in the figures above). To display the process variable in its scaled form, view the control block of the PID instruction (shown on page 26–8). Word 14 contains the scaled value of the Process Variable PV. To view the scaled error, view the control block of the PID instruction. Word 15 contains the scaled error.
Changing Values in the Manual Mode In the manual mode the Zoom display allows you to change only the OUTPUT % value:
Only the Output % can be changed at this display.
ZOOM on PID –(PID)– 1/2 NAME: PROP INT DERIV MODE: PROCESS: 0 SETPOINT: 500 OUTPUT: 95% MIN OUT: 5% MAX OUT: 95% ENTER OUTPUT PCT: 95 NEXT PG AUTO F1
F2
F3
2.0.0.0.1 MANUAL
PRG F4
F5
You can change the Setpoint, Deadband, Gain, Reset, Rate, Output min %, and Output max % parameters by writing to the appropriate word within the control block of the PID. The control block is shown on page 26–9.
26–15
Page 360
Chapter 26 PID Instruction
Normally, when the (CV) Output % is changed, the scaled value in the “Output” location is changed. This value is a number from 0 to 16383 corresponding to the (CV) Output % of 0 to 100. Although the (CV) Output % is displayed in the control block (word 16), modifying this word in the manual mode has no effect on the “Output” value. When you are in the manual mode, the scaled value in the “Output” location can be changed in either of two ways: • Use the Zoom display to change the (CV) Output % in the Run mode, or • Write a ladder program that will convert the (CV) Output % to an analog value and place it into the “Output” (or “Control Variable”) location. An example of this is shown on page 26–20.
Application Notes
The following paragraphs discuss: • Input/Output Ranges • Scaling to Engineering Units • Zero-crossing Deadband • Output Alarms • Output Limiting with Anti-reset Windup • The Manual Mode • Feed Forward • Time Proportioning Outputs
Input/Output Ranges The input module measuring the process variable (PV) must have a full scale binary range of 0 to 16383. If this value is less than 0 (bit 15 set), then a value of zero will be used for PV and the “Process var out of range” bit will be set (bit 12 of word 0 in the control block). If the process variable is > 16383 (bit 14 set), then a value of 16383 is used for PV and the “Process var out of range” bit is set. The Control Variable, calculated by the PID instruction, has the same range of 0 to 16383. The Control Output (word 16 of the control block) has the range of 0 to 100%. You can set lower and upper limits for the instruction’s calculated output values (where an upper limit of 100% corresponds to a Control Variable limit of 16383).
Scaling to Engineering Units Scaling lets you enter the setpoint and zero-crossing deadband values in engineering units, and to display the process variable and error values in the same engineering units. Remember, the process variable PV must still be within the range 0 to 16383.
26–16