If the incubator were able to stabilize at the setpoint, the error would be 0, providing 0% drive from proportional and only bias drive that is insufficient to maintain the temperature c
Trang 1Figure 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
Trang 2Figure 6.9b: Data File Plotted in Excel
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
Trang 3Figure 6.10: Response with Gain = 5, 20% Band
Note that the response time of the system is again slightly faster, but there is much more hunting and
continued instability in the system
As a final experiment, set the setpoint (SP) temperature substantially higher than the bias temperature, but within a controllable temperature range with a proportional gain of 1 (Kp=10) We tested at 10F above the bias temperature (107F) Plot the results Figure 6.11 is the result of our tests
Trang 4Figure 6.11: Setpoint 10F (107F) above Bias Temperature
While trying awfully hard, the temperature is not stabilizing at 107 degrees If 107F is an achievable temperature for the system, why doesn’t it stabilize there? Remember that for our system 50% drive stabilized around 97F Additional drive is added because an error exists If the incubator were able to stabilize at the setpoint, the error would be 0, providing 0% drive from proportional and only bias drive that
is insufficient to maintain the temperature creating an error
%DriveTOTAL = %DriveBIAS + %DrivePROP
%DrivePROP = Kp*E If E = 0 then %DrivePROP = 0%
%DriveTOTAL = 50% + 0%
If the setpoint temperature is not the bias temperature, some error MUST exist to provide additional drive from the proportional control The higher the proportional gain, the smaller the remaining error In the next section, we will see how Integral Error may be used to drive away this remaining error
Trang 5Challenge!
1 If the proportional gain were set to 5 (Kp=50), what type of response would you expect from the system? Why?
2 If the temperature is 0.6F below your setpoint, what would the total drive be?
3 Confirm your theory
Exercise #3: Proportional+Integral Control
∫
+ +
= ( Kp * E ) ( Ki * Et )
Copid B
%DriveTotal = %DriveBIAS + %DrivePROP + %DriveINT
So far we’ve looked at what occurs when quick disturbances occur to our system in equilibrium Proportional control may be used to drive the temperature back to the desired setpoint But what happens when the disturbance affects the equilibrium of our system over a long period of time? At the end of the last experiment it was seen what occurs when the bias drive is not sufficient to make-up for average losses Because some error must exist for proportional drive, the setpoint temperature cannot be maintained Integral control can be used to drive-away error remaining due to long lasting disturbances in the system These may be from additional losses or gains of energy that remain for a long period of time Consider our incubator We found a bias temperature at which a 50% bias drive was sufficient to make up for the losses in the system maintaining it in equilibrium
But what would happen if the fan were continuously pointed at the incubator? Continuous system losses would be higher The 50% bias drive will be insufficient to maintain the temperature and proportional drive will respond to the error in an attempt to drive the system back toward to the setpoint But as we’ve seen, because some error must remain, the setpoint is not maintained The system will stabilize at a temperature below the desired setpoint
Over time, integral drive can be used to drive away this error, allowing the temperature to reach the setpoint Integral drive is also used when a slow approach with long stabilization times are needed to ensure no overshoot Consider the example of cooking soup After cooking a bit, you taste, add an amount of salt you feel appropriate for what you would like the final taste to be Do you taste immediately and add more? No, you wait a while to allow the salt to blend in, then taste, and add a bit more until you finally reach your desired taste What if too much salt is added? Cutting back is a bit more difficult!
Trang 6An industrial example may be that of adding pigment to paint for a desired color Electronic circuitry monitors paint color and gradually add pigment until the desired color is reached
In integral drive the amount of error is integrated over time The larger the error and the longer it lasts, the greater the integral drive will be
As seen from figure 6.12, the amount of error under the curve is added together to find the integrated error The longer the error exists, the higher integrated total error (ET) will be
Figure 6.12: Integrating Error
4
E3
Time T
Trang 7Figure 6.13: Integral Flowchart
Code to accompany chart above:
'********** Integral Drive - Sign Adjusted
IntCalc:
Ei = Ei + Err 'Accumulate %err each time
IntCount = IntCount + 1 'Add to counter for reset time
IF IntCount < Ti Then IntDone 'Not at reset count? done
Gosub SetSign
Ei = ABS Ei / Ti 'Find average error over time
Ei = Ei * Ki + 5 /10 'Int err = int err * Ki
Trang 8Controlling the Incubator
In this exercise, the fan will be used to produce a long lasting disturbance to the system The fan should be placed approximately 6 inches from the incubator It will be powered from Vdd (5V – Pin 20 or from the Vdd terminal on top of the breadboard) to provide a ‘gentle’ cooling to the canister (you may have to ‘kick-start’ the fan to start it turning) This will produce a long-term disturbance to the system instead of the strong 10 second disturbances used in the proportional testing
For proportional gain we will use a very small value to prevent hunting and provide a large error from the setpoint The integral update time, or reset time, of the integral drive will be approximately 120 seconds (450 seconds would be more appropriate to allow full stabilization, but that’s a long time to plot!) Integral gain will be set in tenths
1) Setup Program 6.1 for a 1000% Proportional Band, Gain of 0.1 (Kp=1) and Integral gain of 0(Ki=0) and derivative of 0 (Kd=0)
2) Point the fan at the incubator from a distance of about 6 inches (if you see no response after 30 seconds, move it closer in one-inch increments and try again)
3) Energize the fan from Pin 20 (5V) and ground Push-start the fan if needed
4) Allow the system to stabilize with this new system loss
5) Change the integral gain to 1 (Ki=1), Ti = 24
6) Download and plot at the new settings
Figure 6.14a shows our results of this test with a bias setpoint of 97.0 F and Figure 6.14b is an Excel plot of captured data
Trang 9Figure 6.14a: Long-Term Disturbance Effects
Note that with a bias setpoint of 97.0F and the disturbance of the fan, the initial stable temperature was 94.8F Over time the drive, and hence the temperature, was slowly bumped up until the actual temperature was at the setpoint
Trang 10Figure 6.14b: Data Plotted in Excel
4 103.
8 129.
6 155.
5 181.
3 207.
2 233 258.
8 284.
6 310.
4 336.
3 362.
1 387.
Note that the initial error (%Err) was 11% at a stable temperature of 94.8F
%DriveTotal = %DriveBIAS + %DrivePROP + %DriveINT
%DrivePROP = 11% still since the temperature is still 95.8F
%DrivePROP = Kp * ET = 1 * (11%+11%+11%….[24 of them!])/24 = 11%
%DriveTotal = 50% + 11% + %11% = 72%
Note that with the higher total drive (%Drive), temperature eventually begins to increase, error decreases, and proportional drive decreased Integral remains constant until the next reset time around 240 seconds when it bumps up based on the average of the errors since the last reset time
Eventually, temperature returns to the setpoint, the error is driven away, proportional drive is virtually gone and integral drive plus the bias drive are maintaining the temperature
Trang 11%DriveTotal = %DriveBIAS + %DrivePROP + %DriveINT
%DriveTotal = 50% -1% + 21% = 70%
But what happens when the long lasting disturbance leaves?
1) De-energize the fan
Figure 6.15: Temperature Following the Removal of a Disturbance
Figure 6.15 shows what happens when the disturbance is removed The additional drive from integral drive must be slowly integrated away again
Integral wind-up can occur if the addition of integral drive is insufficient to force the system back to the
setpoint Integral drive would continually be added This would mean that an error would constantly persist and the output would ‘wind-up’ to an abnormally high values leading to an unresponsive system If our program allowed integral drive to wind-up to 20000%, how long would it take to drive it away once a
Trang 12disturbance is removed providing an error of 10%? It is wise to make a provision in your program to limit the cumulative integral drive to less than 100%
Challenge!
1 What would the system response be if Integral gain were 1 (Ki=10) and the reset time were 60 seconds (Ki=12)? Why?
2 Test and confirm your theory
Exercise #3: Proportional-Derivative Control
)
* ( )
* (
t
E Kd E
Kp
Copid B
∆
∆ +
+
=
%DriveTOTAL = %DriveBIAS + %DrivePROP + %DriveDERIV
Derivative control responds to a CHANGE in the error The fundamental premise determining derivative drive assumes the present rate of change in the error signal will continue into the future unless action is taken Derivative drive, when properly tuned, allows a system to rapidly respond to sudden changes and react accordingly
Figure 6.16 illustrates how we would evaluate the slope of an error signal Finding the difference between error samples taken at regular time intervals reflects the rate at which the process variable is changing The greater the difference, the greater the slope and therefore the greater the derivative drive necessary to counteract the change
Trang 13Figure 6.16: Derivative Error
2}
Trang 14Figure 6.17: Flowchart and Code for Derivative Control
Code for this flowchart:
'*********** DERIVATIVE DRIVE
DerivCalc:
D = (Err-LastErr) * KD ' Calculate amount of derivative drive
' based on the difference of last error DerivDone
LastErr = Err ' Store current error for next deriv calc
RETURN
In this experiment, we will repeat the disturbances on a system with a proportional gain of 2 from Exercise #2 Only this time derivative drive will be used in conjunction with proportional The fan will once again be supplied power from Vin (pin 19) for 10 seconds at 1 inch Figure 6.18a is the results of our testing Figure 6.18b is an Excel graph of the data
1) Settings: Proportional gain of 2 (Kp=20), Ki=0, derivative gain of 1 (Kd=2)
2) Allow temperature to stabilize on SPL
3) Energize the fan for 10 seconds
(For this test, our bias temperature was 99.0F)
Trang 15Figure 6.18a: Disturbance Response with Proportional Gain of 2 and Derivative Gain of 2
Compare this with Figure 6.9a using only proportional drive Note that the system stabilizes much faster with fewer oscillations and overshoot In the message section, there are 2 consecutive reading of 99.0F First had
a %D drive of 40% since there was a 20% error change (.4F) between the previous and current The second resulted in a %D of 0% because 2 consecutive readings of 99.0F represents no change in error and a slope of zero
Trang 16Figure 6.18b: Graph of Data
Let’s work a little math for a temperature change between samples of 99.4 to 99.0 with the setpoint at 99.0F:
%DriveTOTAL = %DriveBIAS + %DrivePROP + %DriveDERIV
At the time of the first sample, T=99.4:
Error = setpoint – actual = 99.0F-99.4F = -4F
%Error = Error/Range * 100 = -.4F/2F * 100 = -20%
Temperature dropped to 99.0F at the time of the second sample:
Error = setpoint – actual = 99.0F-99.0F = 0F
%Error = Error/Range * 100 = 0F/2F * 100 = 0%
%DrivePROP = %Error * Kp = 0% * 2 = 0%
%DriveDERIV = (This %Error – Last %Error) * Kd= (0%-20%) * 1 = 40%
Trang 17%DriveTOTAL = %DriveBIAS + %DrivePROP + %DriveDERIV =
50%+0%+40% = 90%
Even though temperature returned to the setpoint providing a 0% drive from proportional, the temperature dropped from the last reading Derivative control took action based on the change in error in an effort to stop the dropping temperature by adding drive
If the next temperature reading was 99.2%, what would the final drive be?
1 What would system response be with a derivative gain of 5? Why?
2 With a -0.3 change in temperature from the setpoint, what would total drive be?
3 Test and confirm your theory
Proportional-Integral-Derivative Summary
With PID control, 3 separate drive evaluations are performed to calculate the final drive to the control element Bias drive is used to estimate the drive needed to sustain a setpoint under nominal conditions Proportional drive acts by adding an amount of drive in proportion to the amount of error that exists between the setpoint and the actual value The higher the proportional gain the greater the controller’s response, though overshoot and oscillations are more likely Some error must exist for proportional drive to act, often resulting in a stable but offset condition
Integral drive acts by integrating a long error over time and taking action based on the total error Integral is used to drive away error conditions that persist over a period of time Integral control is also a good choice for a very slow approach to a setpoint when long system settling times are needed and overshoot is undesirable
Trang 18Derivative control acts by taking action based on a change of error, often from one reading to the next It evaluates the slope of the changing output and acts in opposition to the change Derivative control can prevent hunting and oscillations, but too much drive can send a system into wild oscillations
Each control mode has its own unique characteristic response to maintaining the desired output to it, such as response time Volumes have been written on the subject of PID control and tuning Tuning a PID system involves adjusting the software parameters for each factor The goal of tuning the system is to adjust the gains so the loop will have optimal performance under dynamic conditions As mentioned earlier, tuning is as much of an art as it is a science The basic procedures for tuning a PID controller are as follows This procedure assumes you can provide or simulate a quickstep change in the error signal:
1 Turn all gains to 0
2 Begin turning up the proportional gain until the system begins to oscillate
3 Reduce the proportional gain until the oscillations stop, and then drop it by about 20 % more
4 Increase the derivative term to improve response time and system stability
5 Next, increase the integral term until the system reaches the point of instability, and then back it off slightly
As you gain experience in embedded control, you will see that the characteristics of the process will determine how you should react to error Consider the following three real-world applications
What are the important characteristics of these processes that will determine the suitable control scheme? What mode(s) of control do you feel would work the best?
1) Similar to our incubator system, the first application is a home project that uses the LM34 to measure the temperature of a 20-gallon aquarium Water temperature is maintained within + 1 degree of 80 oF by varying the duty cycle of a 200-watt heater Room temperature varies from 65
to 75 degrees
2) The second application controls the acidity (pH) in the production of a cola soft drink The plant’s water supply has a pH of 7.2 to 7.4 The flow stream of water into a batch of soda must be maintained at a pH of 6.8 An upstream valve is opened accordingly to release phosphoric acid into the stream The pH sensor is relatively slow The amount of acid needed varies with incoming
pH and water flow rate
3) In a plant science research facility at San Diego State University, the surface temperature of a plant’s leaf must be held constant The plant is contained in a small (shoebox sized) greenhouse A