ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 14.06.2025
Просмотров: 1804
Скачиваний: 0
Experiment #6: Proportional – Integral – Derivative Control
Proportional Band = |
1 |
*100% = |
1 |
*100% = 50% |
|
Proportaional Gain |
2 |
||||
What if we wanted a slower responding system? We can define that the full range of drive will be over temperatures greater than the allowable range. If 100% drive were to cover twice as much as the allowable range:
Gain(Kp) = ∆∆OutputInput = 100200%% = 0.5
Calculate the Proportional band: ________
Graph the Drive vs. Temperature for this gain:
Temperature vs. Drive
PWM Drive %
100 |
|||||||||||||||||||||||||||||||||||
90 |
|||||||||||||||||||||||||||||||||||
80 |
|||||||||||||||||||||||||||||||||||
70 |
|||||||||||||||||||||||||||||||||||
60 |
|||||||||||||||||||||||||||||||||||
50 |
% Drive |
||||||||||||||||||||||||||||||||||
40 |
|||||||||||||||||||||||||||||||||||
30 |
|||||||||||||||||||||||||||||||||||
20 |
|||||||||||||||||||||||||||||||||||
10 |
|||||||||||||||||||||||||||||||||||
0 |
|||||||||||||||||||||||||||||||||||
100 |
100.5 |
101 |
101.5 |
102 |
102.5 |
103 |
|||||||||||||||||||||||||||||
Temperature
Calculate the following for a temperature of 101.7F:
Error = |
_________ |
%Error = |
_________ (Hint: The allowable band is still 1.0) |
Proportional Drive = |
_________ |
Total Drive = |
_________. |
Page 162 •Industrial Control Version 1.1
Experiment #6: Proportional – Integral – Derivative Control
Controlling the Incubator:
Theory is nice, but now we need to deal with the temperature inside our actual canister using proportional control and some limitations we’ll need to work with.
1)The bias temperature at 50% bias drive will not be 101.5F. The 50% bias temperature for your incubator was found in Exercise #1 of this experiment. If need be, repeat that portion to find the current bias temperature. This should be done if you think conditions in or around the canister are different. For instance if the room temperature is now higher than it was before, your stable temperature at 50% bias will stabilize at a higher value.
2)The BASIC Stamp works in integer math. Our temperatures are in tenths of degree (101.5=1015), and we will want to work with gain settings that are less than 1.
3)The resolution of the A/D is 0.19 degrees, which would not provide very fine control with an allowable temperature band of 101.0 – 102.0. For these experiments we will increase the allowable band to +/- 1.0F or 100.5F – 102.5F for a range of 2.0F.
In performing these experiments, the general sequence will be to allow the incubator to stabilize at the bias temperature. Once stable, the PID program with the appropriate settings will be downloaded. After 1 minute the fan positioned approximately 1 inch from the canister will be energized manually by connecting the positive lead to the Vin supply for 10 seconds.
Figure 6.7 is the flowchart for the error calculations and proportional drive. Notice in the code for the proportional calculations the result is divided by 10 to scale our Kp value down from tenths.
Industrial Control Version 1.1 •Page 163
Experiment #6: Proportional – Integral – Derivative Control
Figure 6.7: Error and Proportional Calculations
'********** Calculate %Error - Sign adjusted |
||
ErrorCalc: |
(SP - Temp) |
'Calculate temperature error |
Err = |
||
Sign = Err |
||
GOSUB |
SetSign |
'Calculate % error |
Err = |
ABS Err*100/Range |
|
Err = |
Err * Sign |
|
Return |
||
'*********** Proportional Drive - Sign adjusted |
||
PropCalc: |
||
Sign = Err |
||
GOSUB |
SetSign |
'Prop err = %Err * Kp /10 to scale |
P = ABS Err * KP/10 |
||
P = P |
* Sign |
|
RETURN |
||
Page 164 •Industrial Control Version 1.1
Experiment #6: Proportional – Integral – Derivative Control
PID Control: 100% Proportional Band, Proportional Gain = 1
1)Find the 50% drive bias temperature if needed. Allow the temperature to stabilize at the bias temperature.
2)Set the PID Control settings program 6.1 accordingly, setting the value of SP to your bias temperature in tenths and the value of Kp to 10 for a gain of 1.
3)Disconnect on SPL, download the BS2 program, close the debug window, reconnect on SPL and reset your BS2.
4)Monitor temperature on SPL. When 1 minute (60 seconds) has passed, energize the fan for 10 seconds.
5)Monitor the incubator’s response to the disturbance.
Figure 6.8a: Response with Kp = 1, 100% Band
Note how the temperature overshoots the setpoint then turns, goes down, overshoots, and goes up again. This is termed hunting. Drive is added and removed based on the response of the system to finally settle at
Industrial Control Version 1.1 •Page 165
Experiment #6: Proportional – Integral – Derivative Control
the setpoint value. Depending on the needs of your system, PID may be tuned to prevent hunting. The cruise control in our cars might make for an interesting drive if the speed hunting around the setpoint speed!
The user status box at the top of the plot shows the current settings for PID control. The message window displays the setpoint and current temperatures, %Error, and the amount of drive from each evaluation along with the total drive.
Let’s do the math to analyze some of these values. The setpoint is 970 or 97.0F, the bias temperature for our testing. At a temperature of 962 (96.2F) the total drive was 90% with 50% from the Bias drive and 40% from the proportional drive.
Error = Setpoint – Temperature = 97.0F-96.2F=0.8F %Error = Error/Range * 100 = 0.8F/2F * 100 = 40%
%DrivePROP = Kd*E = 1*40% = 40%
%DriveINT and DriveDERIV will be 0 since their gains are 0. %DriveTotal = %DriveBIAS + %DrivePROP + %DriveINT + %DriveDERIV =
= 50% + 40% + 0% + 0% = 90%
The calculations worked!
Using the alternative line for the message file logging in the Display routine, the data saved to the message file may be imported into a spreadsheet, such as Excel, for analysis. It is a simple coma-separated version of the message window data suitable for importation and graphing.
'** Comma-seperated message output for import into spreadsheet
'DEBUG ",",DEC Temp,",",SDEC Err,",",SDEC P,",",SDEC I,",",SDEC D,",",SDEC Drive,CR
Figure 6.8b is the message data imported into Excel will show the error, proportional drive and total drive.
Page 166 •Industrial Control Version 1.1
Experiment #6: Proportional – Integral – Derivative Control |
|||||||||||||||||||
Figure 6.8b: Message file plotted in Excel |
|||||||||||||||||||
Drive with Kp=1 |
|||||||||||||||||||
120 |
|||||||||||||||||||
100 |
|||||||||||||||||||
80 |
|||||||||||||||||||
60 |
%Err |
||||||||||||||||||
|
%Drive |
40 |
||||||||||||||||||
20 |
%P |
||||||||||||||||||
0 |
0.44 |
21.1 |
41.8 |
62.5 |
83.1 |
104 |
124 |
145 |
166 |
186 |
207 |
228 |
248 |
269 |
290 |
310 |
331 |
%Drive |
|
-20 |
352 |
||||||||||||||||||
-40 |
|||||||||||||||||||
-60 |
|||||||||||||||||||
-80 |
|||||||||||||||||||
Seconds |
|||||||||||||||||||
Note that with a proportional gain of 1, the %Error line is barely seen because the %P (Proportional Error) exactly overlaps it. %DrivePROP = %Error. The amount of proportional error is added to the bias drive of 50% and follows the error.
PID Control: 50% Proportional Band, Proportional Gain = 2
Repeat the experiment for a proportional band of 50% at a gain setting of 2. Change Kp = 20 in the control settings and run the program.
Industrial Control Version 1.1 •Page 167
Experiment #6: Proportional – Integral – Derivative Control
Figure 6.9a: Response with Gain = 2, 50% Band
With a gain of 2, note that the response time is slightly faster though there is greater hunting.
Page 168 •Industrial Control Version 1.1
Experiment #6: Proportional – Integral – Derivative Control
Figure 6.9b: Data File Plotted in Excel
Drive with Kp=2 |
||||||||||||||||||||
200 |
||||||||||||||||||||
150 |
||||||||||||||||||||
100 |
||||||||||||||||||||
|
%Drive |
50 |
%Err |
||||||||||||||||||
%P |
||||||||||||||||||||
0 |
||||||||||||||||||||
|
44.0 |
1.21 |
7.41 |
4.62 |
1.83 |
104 |
124 |
145 |
186 166 |
207 |
228 |
248 |
269 |
290 |
310 |
331 |
352 |
%Drive |
|||
-50 |
||||||||||||||||||||
-100 |
||||||||||||||||||||
-150 |
||||||||||||||||||||
Seconds |
||||||||||||||||||||
From Figure 6.9b note that at this gain setting the amount of proportional drive (%P) is twice as much as the error (%Err).
Verify the drive amounts shown in the message window of Figure 6.7a at 96.7F:
Error = |
__________ |
%Error = |
__________ |
%DrivePROP = |
__________ |
%DriveTOTAL = |
__________ |
PID Control: 20% Proportional Band, Proportional Gain = 5
Too much gain can be unsuitable for control. Repeat the experiment for a proportional band of 20% at a gain setting of 5. Kp = 50 in the control settings. Figure 6.10 is our SPL result.
Industrial Control Version 1.1 •Page 169