SlideShare a Scribd company logo
Trimberger 1
PID Temperature Controller
Figure 1 – Photograph of Feedback Circuit.
Gerard Trimberger
In collaboration with Gabriela Patilea and Gina Tran
Section: AC
March 13, 2012
Trimberger 2
Methods and Materials
Parts, Materials, and Equipment Used:
 Breadboard & connecting wire
 One TIP121 power transistor
 One 5 Ω resistor, rated for 5 W called “low‐value resistor”
 One Thermistor: 135‐202FAG‐J01, 135‐103LAG‐J01, or similar
 Heat sink
 Two 10kΩ resistor
 Power supply
 USB‐6009 data I/O device
 Digital Computer with LabView program
Circuit schematic diagram:
Figure 2 – Circuit Schematic Diagram of System; H(s).
Trimberger 3
General Principle and Theory of PID Controller:
The general principle of any feedback control system is that the difference between the
set point and the output of the system is defined as the error. This error is then fed back into the
system in an attempt to bring the output of the system to the set point value. The simplest type of
feedback control is proportional, such that the controller output is equal to the error multiplied by
some proportional control gain constant. To improve the system’s performance, integral and
differential terms can be added. Therefore the proportional-integral-differential (PID) controller
algorithm can be written as:
where, u(t) is “controller” output, MV is a manipulated variable, kp is proportional control gain,
ki is integral control gain, kd is derivative control gain, and e(t) is the error of desired output and
measured output (or set point – process value) over time. The Laplace of u(t) (PID algorithm) is,
The transfer function of the system under control is,
where, is the natural frequency and is the damping factor. The gain of the feedback loop is,
By plugging in the previously defined functions for the Laplace of the PID algorithm and the
transfer function of the system under control, the transfer function for the entire loop is,
General Block Diagram of Feedback Control System
Figure 3 – General Block Diagram of Feedback Control System.
Trimberger 4
Supplied LabView VI’s and Their Purpose:
PWM Application Test VI:
Figure 4 – Front Panel of “PWM Application Test” VI. Figure 5 – Block Diagram of “PWM Application Test” VI.
The PWM (pulse width modulation) application test VI was used to examine the system
under control. The heating system circuit was build using the electrical components described
above (Figure 2). A constant (control) voltage was run through the system and the output was
recorded so that a data set of control voltages and measured voltages over time were created for
the thermal heating system.
PWM sub-VI:
Figure 6 – Front Panel of “PWM sub-VI.” Figure 7 – Block Diagram of “PWM sub-VI.”
The PWM sub-VI was used to create a duty cycle. A duty cycle allows the controller to
output a constant voltage of 0% or 100% max power with the percent time over which it runs at
max power being set by the error signal. In other words, instead of controlling the amount of
power output from the system, the duty cycle runs at only two power settings (on or off) and runs
for a percentage of the time based on the difference between set point and actual output. The
PWM sub-VI is called by the PWM application test VI.
Trimberger 5
Get TF from Files 2012:
Figure 8 – Front Panel of “Get TF from Files 2012” VI.
Figure 9 – Block Diagram of “Get TF from Files 2012” VI.
Once a data set of measured and control voltages over time were created using the PWM
application test VI, they were imported into the Get TF from files 2012 VI. This VI solved for
the transfer function of the system based on the values imported.
Trimberger 6
PID Closed Loop Step Response:
Figure 10 – Front Panel of “PID Closed Loop Step Response” VI.
Figure 11 – Block Diagram of “PID Closed Loop Step Response” VI.
Using the transfer function created in the Get TF from files 2012 VI, various parameters
( , , and ) were determined based on the analytical solution of the transfer function described
above. These parameters remained constant when plugged into the overall transfer function of
Trimberger 7
the system. This overall transfer function also included the PID control gains which were
variable based on the desired control system. The PID closed loop step response VI allowed the
user to vary these PID control gains and visualize their effect on the system’s control.
Selecting PID Gain Values:
Figure 12 – PID Closed Loop Step Response with PID Gains: kp=550, ki=2, and kd=8.
After spending significant time varying the PID control gains, a consensus was made on
using the gains of kp = 550, ki = 2, and kd = 8 because it produced a system response with
minimal overshoot, initial heating time, and oscillations during settling time.
Figure 13 – PID Closed Loop Step Response with PID Gains: kp=200, ki=2, and kd=8.
Trimberger 8
Figure 14 – PID Closed Loop Step Response with PID Gains: kp=900, ki=2, and kd=8.
Decreasing the kp gain value while keeping the other parameters constant resulted in an
increase in initial heating time and a minor decrease in overshoot (Figure 13). Increasing the kp
value resulted in a slight decrease in the initial heating time but also produced a significant
increase in overshoot (Figure 14).
Figure 15 – PID Closed Loop Step Response with PID Gains: kp=550, ki=300, and kd=8.
Increasing the ki value, while keeping the other constant, resulted in an increase in the
overshoot and an increase in settling time.
Trimberger 9
Figure 16 – PID Closed Loop Step Response with PID Gains: kp=550, ki=2, and kd=30.
Increasing kd resulted in an decrease in the initial heating time but also increased settling
time.
Figure 17 – PID Closed Loop Step Response with PID Gains: kp=550, ki=2, and kd=2.
Decreasing kd resulted in a decrease in the initial heating time but also decreased the
settling time
Trimberger 10
Figure 18 – PID Closed Loop Step Response with PID Gains: kp=550, ki=0, and kd=0.
Examining a system with only proportional control, it can be seen that the initial heating
time and settling time is significantly longer, however there is minimal overshoot.
Figure 19 – PID Closed Loop Step Response with PID Gains: kp=550, ki=0, and kd=8.
Trimberger 11
Examining a system without integral control, it can be seen that the initial heating time is
significantly longer, but there is minimal overshoot and a short settling time.
Figure 20 – PID Closed Loop Step Response with PID Gains: kp=550, ki=2, and kd=0.
Examining a system without differential control, it can be seen that the initial heating
time is shorter but there is significant overshoot and an increase in settling time.
Therefore, in general, the kp value determines the initial heating time and the length of
the settling time. This type of control is required in all system which means that it cannot be
avoided. To solve the problems created by this type of control, integral and differential control
must be added. In general, the ki value decreases the initial heating time but also increases the
overshoot of the system. This seems logically sound because integral control sums up past errors
and fixes until there is absolutely no error. A common problem with proportional control is that
it rarely reaches the desired set point. Adding integral control solves this problem by ensuring a
steady state eventually; however it creates its own problem of overshooting and increasing the
settling time. Differential control is added to solve the problems created by integral control. In
general, it appears to decrease the overshoot of the system and decrease the settling time. This
argument is also logically sound because differential control examines the rate of change and
when this value gets too large, it is decreased so as not to overshoot the desired value.
Trimberger 12
Results:
Flow Chart for Complete PID Controller:
Figure 21 – Flow Chart for Complete PID Controller.
LabView Front Panel and Associated Block Diagram of Complete PID Controller VI:
Figure 22 – Front Panel of Complete PID Controller VI. Figure 23 – Block Diagram of Complete
PID Controller VI.
Convert User’s Input
Temperature to Voltage
= Set Point (Vset)
Calculate Error:
e(t)=Vset - Vmeasured
Implement
PID Algorithm
(kp, ki, kd)
Calculate u(t):
Sum of
Correcting Terms
Convert to Duty
Cycle (% time on)
to Correct for Error
DAQ Output
Regulation; Input
to “System” Stage
H(s) System
Breadboard,
Heater, etc.
Measure Voltage,
Vmeasured
(Corresponds to Tsystem)
-
Trimberger 13
Results of PID Controller Implementation:
Figure 24 – Temp. Profile w/ Gains: kp=550, ki=2, kd=8. Figure 25 – Temp. Profile w/ Gains: kp=200, ki=2, kd=8.
Figure 26 – Temp. Profile w/ Gains: kp=900, ki=2, kd=8. Figure 27 – Temp. Profile w/ Gains: kp=550, ki=300, kd=8.
Figure 28 – Temp. Profile w/ Gains: kp=550, ki=2, kd=30. Figure 29 – Temp. Profile w/ Gains: kp=550, ki=2, kd=2.
0 20 40 60 80 100 120
295
300
305
310
315
320
Temperature Profile over Time of System w/ PID Gains: kp
=550, ki
=2, kd
=8
Time (sec)
Temperature(o
Kelvin)
Experimental Data
Set Point (315 o
K)
0 20 40 60 80 100 120
295
300
305
310
315
320
325
Temperature Profile over Time of System w/ PID Gains: kp
=200, ki
=2, kd
=8
Time (sec)
Temperature(o
Kelvin)
Experimental Data
Set Point (315 o
K)
0 20 40 60 80 100 120
295
300
305
310
315
320
Temperature Profile over Time of System w/ PID Gains: kp
=900, ki
=2, kd
=8
Time (sec)
Temperature(o
Kelvin)
Experimental Data
Set Point (315 o
K)
0 20 40 60 80 100 120 140 160 180
295
300
305
310
315
320
325
330
Temperature Profile over Time of System w/ PID Gains: kp
=550, ki
=300, kd
=8
Time (sec)
Temperature(o
Kelvin)
Experimental Data
Set Point (315 o
K)
0 20 40 60 80 100 120
295
300
305
310
315
320
Temperature Profile over Time of System w/ PID Gains: kp
=550, ki
=2, kd
=30
Time (sec)
Temperature(o
Kelvin)
Experimental Data
Set Point (315 o
K)
0 20 40 60 80 100 120
290
295
300
305
310
315
320
Temperature Profile over Time of System w/ PID Gains: kp
=550, ki
=2, kd
=2
Time (sec)
Temperature(o
Kelvin)
Experimental Data
Set Point (315 o
K)
Trimberger 14
Figure 30 – Temp. Profile w/ Gains: kp=550, ki=0, kd=0. Figure 31 – Temp. Profile w/ Gains: kp=550, ki=2, kd=0.
Figure 32 – Temp. Profile w/ Gains: kp=550, ki=0, kd=8.
Discussion:
As seen from the results of the experiment, the kp, ki, and kd values appear to effect the
system as described in “Selecting PID gain values” section. The proportional control effects the
initial heating time but has difficulty reaching a steady state value (Figure 30). The addition of
integral control results in a definite steady state with the trade off of overshoot and increased
settling time oscillations (Figure 31). The additional of differential control returns the initial
heating time to its original value, while decreasing the overshoot and oscillations during settling
time (Figure 24). The other figures included in this section serve to solidify this conclusion.
Overall, the experiment went fairly well. There were slight difficulties in figuring out
where to start but once a flow chart was created, the rest was fairly simple. The only major
difficulty faced was that the output of the controller was resulting in a value so large that it was
running multiple duty cycle before rechecking the error. This logically makes sense because
0 20 40 60 80 100 120
290
295
300
305
310
315
320
Temperature Profile over Time of System w/ PID Gains: kp
=550, ki
=0, kd
=0
Time (sec)
Temperature(o
Kelvin)
Experimental Data
Set Point (315 o
K)
0 20 40 60 80 100 120
290
295
300
305
310
315
320
Temperature Profile over Time of System w/ PID Gains: kp
=550, ki
=2, kd
=0
Time (sec)
Temperature(o
Kelvin)
Experimental Data
Set Point (315 o
K)
0 20 40 60 80 100 120
290
295
300
305
310
315
320
Temperature Profile over Time of System w/ PID Gains: kp
=550, ki
=0, kd
=8
Time (sec)
Temperature(o
Kelvin)
Experimental Data
Set Point (315 o
K)
Trimberger 15
when the system is first heating, the duty cycle should be constant running. However, this is not
ideal when attempting to get a continuous plot. To solve this issue, a scaling algorithm was
implemented after the controller output to make the maximum controller output equal to the
maximum value of the duty cycle. This easily solved the problem because no matter how large
the error was the duty cycle would only run one time for 100% of the time and then recheck the
error. Also, towards the end of data collection, the epoxy holding the thermistor to the resistor
came undone. This was unfortunate but did not have a significant impact on the data collection.
Appendix:
MATLAB Code for Temperature Profile Plotting:
clear all; close all; clc;
% imports experimental data from .txt files %
data1 = load('C:UsersGerardDesktopBioen337 Lab4Data
FilesTemp_550_2_8.txt');
data2 = load('C:UsersGerardDesktopBioen337 Lab4Data
FilesTemp_200_2_8.txt');
data3 = load('C:UsersGerardDesktopBioen337 Lab4Data
FilesTemp_900_2_8.txt');
data4 = load('C:UsersGerardDesktopBioen337 Lab4Data
FilesTemp_550_300_8.txt');
data5 = load('C:UsersGerardDesktopBioen337 Lab4Data
FilesTemp_550_2_30.txt');
data6 = load('C:UsersGerardDesktopBioen337 Lab4Data
FilesTemp_550_2_2.txt');
data7 = load('C:UsersGerardDesktopBioen337 Lab4Data
FilesTemp_550_0_0.txt');
data8 = load('C:UsersGerardDesktopBioen337 Lab4Data
FilesTemp_550_2_0.txt');
data9 = load('C:UsersGerardDesktopBioen337 Lab4Data
FilesTemp_550_0_8.txt');
% sets PID gain values for use in for loop %
param1 = [550 2 8];
param2 = [200 2 8];
param3 = [900 2 8];
param4 = [550 300 8];
param5 = [550 2 30];
param6 = [550 2 2];
param7 = [550 0 0];
param8 = [550 2 0];
param9 = [550 0 8];
for i = 1:9
% creates a time span for each data set %
eval(['time = 1:length([data' num2str(i) '])']);
% creates a set point temperature for each time span %
eval(['setpnt = ones(1,length([data' num2str(i) ']))*315']);
figure
hold on
% plots the experimental temperature versus time graphs %
Trimberger 16
eval(['plot(time, [data' num2str(i) '])']);
% plots the set point temperature over time %
plot(time, setpnt, '--r')
% creates plot title, x axis label, y axis label, and legend %
eval(['param = [param' num2str(i) ']']);
title(['Temperature Profile over Time of System w/ PID Gains: k_p='
num2str(param(1)) ', k_i=' num2str(param(2)) ', k_d=' num2str(param(3))]);
xlabel('Time (sec)')
ylabel('Temperature ( ^o Kelvin)')
legend('Experimental Data', 'Set Point (315 ^o K)', 'Location', 'Best');
hold off
end

More Related Content

PID Temperature Controller

  • 1. Trimberger 1 PID Temperature Controller Figure 1 – Photograph of Feedback Circuit. Gerard Trimberger In collaboration with Gabriela Patilea and Gina Tran Section: AC March 13, 2012
  • 2. Trimberger 2 Methods and Materials Parts, Materials, and Equipment Used:  Breadboard & connecting wire  One TIP121 power transistor  One 5 Ω resistor, rated for 5 W called “low‐value resistor”  One Thermistor: 135‐202FAG‐J01, 135‐103LAG‐J01, or similar  Heat sink  Two 10kΩ resistor  Power supply  USB‐6009 data I/O device  Digital Computer with LabView program Circuit schematic diagram: Figure 2 – Circuit Schematic Diagram of System; H(s).
  • 3. Trimberger 3 General Principle and Theory of PID Controller: The general principle of any feedback control system is that the difference between the set point and the output of the system is defined as the error. This error is then fed back into the system in an attempt to bring the output of the system to the set point value. The simplest type of feedback control is proportional, such that the controller output is equal to the error multiplied by some proportional control gain constant. To improve the system’s performance, integral and differential terms can be added. Therefore the proportional-integral-differential (PID) controller algorithm can be written as: where, u(t) is “controller” output, MV is a manipulated variable, kp is proportional control gain, ki is integral control gain, kd is derivative control gain, and e(t) is the error of desired output and measured output (or set point – process value) over time. The Laplace of u(t) (PID algorithm) is, The transfer function of the system under control is, where, is the natural frequency and is the damping factor. The gain of the feedback loop is, By plugging in the previously defined functions for the Laplace of the PID algorithm and the transfer function of the system under control, the transfer function for the entire loop is, General Block Diagram of Feedback Control System Figure 3 – General Block Diagram of Feedback Control System.
  • 4. Trimberger 4 Supplied LabView VI’s and Their Purpose: PWM Application Test VI: Figure 4 – Front Panel of “PWM Application Test” VI. Figure 5 – Block Diagram of “PWM Application Test” VI. The PWM (pulse width modulation) application test VI was used to examine the system under control. The heating system circuit was build using the electrical components described above (Figure 2). A constant (control) voltage was run through the system and the output was recorded so that a data set of control voltages and measured voltages over time were created for the thermal heating system. PWM sub-VI: Figure 6 – Front Panel of “PWM sub-VI.” Figure 7 – Block Diagram of “PWM sub-VI.” The PWM sub-VI was used to create a duty cycle. A duty cycle allows the controller to output a constant voltage of 0% or 100% max power with the percent time over which it runs at max power being set by the error signal. In other words, instead of controlling the amount of power output from the system, the duty cycle runs at only two power settings (on or off) and runs for a percentage of the time based on the difference between set point and actual output. The PWM sub-VI is called by the PWM application test VI.
  • 5. Trimberger 5 Get TF from Files 2012: Figure 8 – Front Panel of “Get TF from Files 2012” VI. Figure 9 – Block Diagram of “Get TF from Files 2012” VI. Once a data set of measured and control voltages over time were created using the PWM application test VI, they were imported into the Get TF from files 2012 VI. This VI solved for the transfer function of the system based on the values imported.
  • 6. Trimberger 6 PID Closed Loop Step Response: Figure 10 – Front Panel of “PID Closed Loop Step Response” VI. Figure 11 – Block Diagram of “PID Closed Loop Step Response” VI. Using the transfer function created in the Get TF from files 2012 VI, various parameters ( , , and ) were determined based on the analytical solution of the transfer function described above. These parameters remained constant when plugged into the overall transfer function of
  • 7. Trimberger 7 the system. This overall transfer function also included the PID control gains which were variable based on the desired control system. The PID closed loop step response VI allowed the user to vary these PID control gains and visualize their effect on the system’s control. Selecting PID Gain Values: Figure 12 – PID Closed Loop Step Response with PID Gains: kp=550, ki=2, and kd=8. After spending significant time varying the PID control gains, a consensus was made on using the gains of kp = 550, ki = 2, and kd = 8 because it produced a system response with minimal overshoot, initial heating time, and oscillations during settling time. Figure 13 – PID Closed Loop Step Response with PID Gains: kp=200, ki=2, and kd=8.
  • 8. Trimberger 8 Figure 14 – PID Closed Loop Step Response with PID Gains: kp=900, ki=2, and kd=8. Decreasing the kp gain value while keeping the other parameters constant resulted in an increase in initial heating time and a minor decrease in overshoot (Figure 13). Increasing the kp value resulted in a slight decrease in the initial heating time but also produced a significant increase in overshoot (Figure 14). Figure 15 – PID Closed Loop Step Response with PID Gains: kp=550, ki=300, and kd=8. Increasing the ki value, while keeping the other constant, resulted in an increase in the overshoot and an increase in settling time.
  • 9. Trimberger 9 Figure 16 – PID Closed Loop Step Response with PID Gains: kp=550, ki=2, and kd=30. Increasing kd resulted in an decrease in the initial heating time but also increased settling time. Figure 17 – PID Closed Loop Step Response with PID Gains: kp=550, ki=2, and kd=2. Decreasing kd resulted in a decrease in the initial heating time but also decreased the settling time
  • 10. Trimberger 10 Figure 18 – PID Closed Loop Step Response with PID Gains: kp=550, ki=0, and kd=0. Examining a system with only proportional control, it can be seen that the initial heating time and settling time is significantly longer, however there is minimal overshoot. Figure 19 – PID Closed Loop Step Response with PID Gains: kp=550, ki=0, and kd=8.
  • 11. Trimberger 11 Examining a system without integral control, it can be seen that the initial heating time is significantly longer, but there is minimal overshoot and a short settling time. Figure 20 – PID Closed Loop Step Response with PID Gains: kp=550, ki=2, and kd=0. Examining a system without differential control, it can be seen that the initial heating time is shorter but there is significant overshoot and an increase in settling time. Therefore, in general, the kp value determines the initial heating time and the length of the settling time. This type of control is required in all system which means that it cannot be avoided. To solve the problems created by this type of control, integral and differential control must be added. In general, the ki value decreases the initial heating time but also increases the overshoot of the system. This seems logically sound because integral control sums up past errors and fixes until there is absolutely no error. A common problem with proportional control is that it rarely reaches the desired set point. Adding integral control solves this problem by ensuring a steady state eventually; however it creates its own problem of overshooting and increasing the settling time. Differential control is added to solve the problems created by integral control. In general, it appears to decrease the overshoot of the system and decrease the settling time. This argument is also logically sound because differential control examines the rate of change and when this value gets too large, it is decreased so as not to overshoot the desired value.
  • 12. Trimberger 12 Results: Flow Chart for Complete PID Controller: Figure 21 – Flow Chart for Complete PID Controller. LabView Front Panel and Associated Block Diagram of Complete PID Controller VI: Figure 22 – Front Panel of Complete PID Controller VI. Figure 23 – Block Diagram of Complete PID Controller VI. Convert User’s Input Temperature to Voltage = Set Point (Vset) Calculate Error: e(t)=Vset - Vmeasured Implement PID Algorithm (kp, ki, kd) Calculate u(t): Sum of Correcting Terms Convert to Duty Cycle (% time on) to Correct for Error DAQ Output Regulation; Input to “System” Stage H(s) System Breadboard, Heater, etc. Measure Voltage, Vmeasured (Corresponds to Tsystem) -
  • 13. Trimberger 13 Results of PID Controller Implementation: Figure 24 – Temp. Profile w/ Gains: kp=550, ki=2, kd=8. Figure 25 – Temp. Profile w/ Gains: kp=200, ki=2, kd=8. Figure 26 – Temp. Profile w/ Gains: kp=900, ki=2, kd=8. Figure 27 – Temp. Profile w/ Gains: kp=550, ki=300, kd=8. Figure 28 – Temp. Profile w/ Gains: kp=550, ki=2, kd=30. Figure 29 – Temp. Profile w/ Gains: kp=550, ki=2, kd=2. 0 20 40 60 80 100 120 295 300 305 310 315 320 Temperature Profile over Time of System w/ PID Gains: kp =550, ki =2, kd =8 Time (sec) Temperature(o Kelvin) Experimental Data Set Point (315 o K) 0 20 40 60 80 100 120 295 300 305 310 315 320 325 Temperature Profile over Time of System w/ PID Gains: kp =200, ki =2, kd =8 Time (sec) Temperature(o Kelvin) Experimental Data Set Point (315 o K) 0 20 40 60 80 100 120 295 300 305 310 315 320 Temperature Profile over Time of System w/ PID Gains: kp =900, ki =2, kd =8 Time (sec) Temperature(o Kelvin) Experimental Data Set Point (315 o K) 0 20 40 60 80 100 120 140 160 180 295 300 305 310 315 320 325 330 Temperature Profile over Time of System w/ PID Gains: kp =550, ki =300, kd =8 Time (sec) Temperature(o Kelvin) Experimental Data Set Point (315 o K) 0 20 40 60 80 100 120 295 300 305 310 315 320 Temperature Profile over Time of System w/ PID Gains: kp =550, ki =2, kd =30 Time (sec) Temperature(o Kelvin) Experimental Data Set Point (315 o K) 0 20 40 60 80 100 120 290 295 300 305 310 315 320 Temperature Profile over Time of System w/ PID Gains: kp =550, ki =2, kd =2 Time (sec) Temperature(o Kelvin) Experimental Data Set Point (315 o K)
  • 14. Trimberger 14 Figure 30 – Temp. Profile w/ Gains: kp=550, ki=0, kd=0. Figure 31 – Temp. Profile w/ Gains: kp=550, ki=2, kd=0. Figure 32 – Temp. Profile w/ Gains: kp=550, ki=0, kd=8. Discussion: As seen from the results of the experiment, the kp, ki, and kd values appear to effect the system as described in “Selecting PID gain values” section. The proportional control effects the initial heating time but has difficulty reaching a steady state value (Figure 30). The addition of integral control results in a definite steady state with the trade off of overshoot and increased settling time oscillations (Figure 31). The additional of differential control returns the initial heating time to its original value, while decreasing the overshoot and oscillations during settling time (Figure 24). The other figures included in this section serve to solidify this conclusion. Overall, the experiment went fairly well. There were slight difficulties in figuring out where to start but once a flow chart was created, the rest was fairly simple. The only major difficulty faced was that the output of the controller was resulting in a value so large that it was running multiple duty cycle before rechecking the error. This logically makes sense because 0 20 40 60 80 100 120 290 295 300 305 310 315 320 Temperature Profile over Time of System w/ PID Gains: kp =550, ki =0, kd =0 Time (sec) Temperature(o Kelvin) Experimental Data Set Point (315 o K) 0 20 40 60 80 100 120 290 295 300 305 310 315 320 Temperature Profile over Time of System w/ PID Gains: kp =550, ki =2, kd =0 Time (sec) Temperature(o Kelvin) Experimental Data Set Point (315 o K) 0 20 40 60 80 100 120 290 295 300 305 310 315 320 Temperature Profile over Time of System w/ PID Gains: kp =550, ki =0, kd =8 Time (sec) Temperature(o Kelvin) Experimental Data Set Point (315 o K)
  • 15. Trimberger 15 when the system is first heating, the duty cycle should be constant running. However, this is not ideal when attempting to get a continuous plot. To solve this issue, a scaling algorithm was implemented after the controller output to make the maximum controller output equal to the maximum value of the duty cycle. This easily solved the problem because no matter how large the error was the duty cycle would only run one time for 100% of the time and then recheck the error. Also, towards the end of data collection, the epoxy holding the thermistor to the resistor came undone. This was unfortunate but did not have a significant impact on the data collection. Appendix: MATLAB Code for Temperature Profile Plotting: clear all; close all; clc; % imports experimental data from .txt files % data1 = load('C:UsersGerardDesktopBioen337 Lab4Data FilesTemp_550_2_8.txt'); data2 = load('C:UsersGerardDesktopBioen337 Lab4Data FilesTemp_200_2_8.txt'); data3 = load('C:UsersGerardDesktopBioen337 Lab4Data FilesTemp_900_2_8.txt'); data4 = load('C:UsersGerardDesktopBioen337 Lab4Data FilesTemp_550_300_8.txt'); data5 = load('C:UsersGerardDesktopBioen337 Lab4Data FilesTemp_550_2_30.txt'); data6 = load('C:UsersGerardDesktopBioen337 Lab4Data FilesTemp_550_2_2.txt'); data7 = load('C:UsersGerardDesktopBioen337 Lab4Data FilesTemp_550_0_0.txt'); data8 = load('C:UsersGerardDesktopBioen337 Lab4Data FilesTemp_550_2_0.txt'); data9 = load('C:UsersGerardDesktopBioen337 Lab4Data FilesTemp_550_0_8.txt'); % sets PID gain values for use in for loop % param1 = [550 2 8]; param2 = [200 2 8]; param3 = [900 2 8]; param4 = [550 300 8]; param5 = [550 2 30]; param6 = [550 2 2]; param7 = [550 0 0]; param8 = [550 2 0]; param9 = [550 0 8]; for i = 1:9 % creates a time span for each data set % eval(['time = 1:length([data' num2str(i) '])']); % creates a set point temperature for each time span % eval(['setpnt = ones(1,length([data' num2str(i) ']))*315']); figure hold on % plots the experimental temperature versus time graphs %
  • 16. Trimberger 16 eval(['plot(time, [data' num2str(i) '])']); % plots the set point temperature over time % plot(time, setpnt, '--r') % creates plot title, x axis label, y axis label, and legend % eval(['param = [param' num2str(i) ']']); title(['Temperature Profile over Time of System w/ PID Gains: k_p=' num2str(param(1)) ', k_i=' num2str(param(2)) ', k_d=' num2str(param(3))]); xlabel('Time (sec)') ylabel('Temperature ( ^o Kelvin)') legend('Experimental Data', 'Set Point (315 ^o K)', 'Location', 'Best'); hold off end