cc lee digital temperature controller - richard...
TRANSCRIPT
Design and Implementation of a Digital Temperature
Controller
BY:DAVE PONTIUS
KUNAL JAINRAJ VORA
Jain, Pontius, Vora 1
TABLE OF CONTENTS
1. Project
2. Component Familiarity
3. Background
4. Design Approach
5. Results
6. Improvements
7. Other Issues
8. Team Work
9. Summary
10. Budgeting
11. References
Jain, Pontius, Vora 2
1. Project:
These days, the feedback network system is applicable to so many different functions. It
is the optimal template to use for tasks which need high precision and fast or real-time response.
For our project, we are applying it to the world of temperature control. The motivation behind
this project stems from the need to make temperature control systems more user friendly and
efficient. Currently, there are many systems in the real world that control temperature using a
feedback network. Recreating one using innovative ideas has not only given us a deeper
understanding of temperature control methods but it has allowed us to improve the system in
many ways for other applications. The requirements of our temperature control system, as set by
our faculty mentor Professor Chin C. Lee, had two main elements. The system must be able to
sustain an average temperature of 350 degrees Celsius and secondly, the overshoot must be
within plus or minus 2 degrees Celsius. The industry software Matlab will control the system and
an algorithm will compare the output temperature with the input temperature (350 deg C)
sending voltage to the relay compensating for overshoot or undershoot. The following block
diagram explains our project design at first glance:
Jain, Pontius, Vora 3
After researching specific parts given our design specifications, we chose each part with
the intention that it would meet our project’s requirements. Our initial system was a great in
theory but we realized how hard it is to be an engineer. While selecting parts we encountered
many problems such as certain parts not working together or in particular our labjack not being
able to output certain voltages and currents in order to work our relays. The following diagram is
a more detailed version of our specific temperature control feedback system:
Jain, Pontius, Vora 4
2. Component Familiarity:
Here are all the components we had purchased for our project. The ones that actually were of use are highlighted.
Stove:
• MAX TEMP: 440 degrees celsius• Rise to max temp:
Jain, Pontius, Vora 5
Mechanical Relay:
• Min switching voltage: 12VDC• Max current rating: 10A• Data sheet attached on back
Reed Relay:
• Min Switching voltage: 5VDC • Max current rating: .5A• Data sheet attached on back
Jain, Pontius, Vora 6
LabJack U12:
• System Control• Analog Inputs• Analog to digital converter• Digital Outputs• Matlab controlled
Thermocouple to Analog Connector:
• Converts and amplifies voltage across thermocouple• Type K: -100 to +1250°C (-148 to +2282°F)
Jain, Pontius, Vora 7
• Converts a thermocouple input signal (Type J, K, or T) to a linear, compensated, amplified analog output.
• Data sheet attached on back
3. Background:The initial step in our temperature controller was to find a coil that could withstand the target
temperature of 350° C. In order to do this, we had mostly to consider the effects of black body
radiation.
Radiation is a means of energy transfer. All objects continuously emit energy in the form
of electromagnetic waves. This accounts for glow given off by our coil, and other heating
devices.
The rate of energy transfer is calculated through a principal known as Stefans law (2).
Stefan’s law accentuates that Power is proportional to temperature loss at a fourth power. More
specifically:
P = σAeT4
In this situation, P is the power radiated from the surface in watts, σ is a constant equal to
5.669 X 10-8 W/m2 K4, A is the surface area of the object in square meters and e is the emissivity.
Finally T is the surface temperature in Kelvins.
For black bodies specifically, which is the case of our coil, the emissivity is equal to 1.
Which is due to the fact that black bodies are ideal absorbers and absorb all energy incident upon
them (2).
In our case, knowing the power rating of our coil, we worked backwards and found the
maximum temperature that our coil could reach. After a little work it was easy to see that the coil
would reach well above 400° C. This would be sufficient in allowing us to reach our target
Jain, Pontius, Vora 8
temperature. Although we didn’t take into account the effects of heat loss due to air, we knew
that its effects would be so negligible that it would not affect our overall calculations.
4. Design Approach:The controller is the building block for our project so we wanted to use this as the
building block for the rest of our project. We were originally going with the idea of controlling
the temperature of the stove by using a microcontroller. After looking more into the design
specifications and future applications we decided that using Matlab would provide us with more
versatility and better graphing and display options(1). The basic configuration for our project
was discussed earlier so the main goal of this section is to explain both the positive and negative
reasons why what we chose what worked or did not work. Many problems arose while trying to
stick to the plan, but we realize this is the problem for everyday engineers. After deciding on
using Matlab we had to look for an interface card that would communicate with our circuit. We
found the LabJack U12 to be exactly what we were looking for. The one draw back was that it
only could output 5vdc and 50mA max at any given time; to control our relay more current was
needed. Our relay needed an input of 5V@100mA. Our other relay was a high power relay that
needed a minimum of 12vdc. To solve this problem we connected a 12v dc power supply to the
high power relay and on one of the dc power supply lines we attached a smaller relay that we
found in an electronic shop in series that was controlled by LabJack. So the only time that the
stove got power was when LabJack would output 5vdc, this would then turn on the smaller relay,
which would mean the 12v dc power supply was turned on and then correspondingly close the
circuit so the stove could get power and start to heat up as shown below:
Jain, Pontius, Vora 9
After we got our basic circuit configuration up and running we found that LabJack’s
inputs are not very sensitive. In order to capture the change in voltage form the thermocouple,
the labjack had to distinguish between only mV. Also there was a bit of a nonlinear distribution
at temperatures less then 500C for the type K thermocouple(3). We had to find away to amplify
the readings from the thermocouple and also linearize it(4). Our original thermometer that we
used was from Omega Engineering. It is a high heat digital thermometer we found to be perfect
for our project. We also then found that Omega Engineering makes a meter that solves both these
Jain, Pontius, Vora 10
issues. The output voltage readings were set up so that 1mv was equivalent to one degree C so
350mvdc equals to 350ºC. We were able to confirm the readings from the thermocouple by
comparing it to the digital thermometer from Omega. We found that the delay from a
thermocouple when placed on a element that was preheated to 400ºC would be 1.5 seconds,
however because the thermocouple in our case is in constant contact with the hot plate its
response time is significantly diminished and we found that the response time was faster then the
thermometer we used to confirm our readings. In our original Matlab coding we would have the
stove top turn off whenever the thermocouple would read a temperature greater then 350ºC and
on when it was less. However, because this left no cushion or room for error that Matlab would
send out readings to turn on and off the stove at such a fast rate that there would not be enough
time to read the reading from the thermocouple. Another problem with this design was the
overshoot. Because the stove rises and falls so quickly when we made it to our target
temperature, the overshoot would blow out of proportion and it would never be able to hit the
right temperature. Our next decision had to be an important one because we needed to figure out
how to get rid of the overshoot. So we decided to figure out the time constant for our stove.
Basically we found out how long it took to get to 63% of our target temperature and then decided
to slow the process down at that point(1). So after it reached 63% we began to change the duty
cycle. After many failed attempts we finally found the timing that worked best with our stove.
After 64% we changed the duty cycle with time. We discovered that in order to slow down the
stove well enough to create less overshoot we would have to then turn it on for 6 seconds and off
for 2 seconds. It came to these numbers because otherwise the temperature would fall to fast and
then rise again way to fast and then blow out of control. With this process we were able to attain
Jain, Pontius, Vora 11
our target temperature with a freedom of +/- 7 degrees; which was still not good enough. As a
great start we felt we could do better. So we changed the duty cycles even more. We broke down
the curve into 3 pieces. Till 63% it is on fully. Then from 64% to 84% we repeated the 6 on and 2
off. Then to take an extra measure to reduce our freedom of degrees, from 85% to 100% the duty
cycle was 2 seconds on and 1 second off. In this last 15% we made our target voltage window
even smaller. Though we had a back up just in case it overshot, while it was in that small
window, we were able to bring down the degrees of freedom to about +/- 3 degrees. At the end
the target window was so small that our relay would just go back and forth with very minute
increases. Taking our process and implementing it in Matlab was much more difficult than we
imagined. Being able to record data live in time was a bit of a complication. We originally
wanted to make a temperature versus time graph but it didn’t make enough sense to do so.
Instead we graphed time versus voltage output from our Omega voltage amplifier.
Jain, Pontius, Vora 12
5. Results:
One of the main problems we had dealing with, like we said earlier, was the stove and
overshoot. The stove we were using seemed to heat up and cool down very quickly. To
experiment we let the stove reach its maximum temperature which was about 440 degrees
Celsius. At high temperatures the stove will cool down quicker then it will at lower temperatures.
After taking this into consideration we made three experiments. Like we discussed earlier it took
us some time to finally get to our final code.
Experiment 1:
• Target Temperature: 350 degrees Celsius
• Code:
function [a, b] = clutchit(w, x, z)
g = 2;n = 1;vn = 0;counttime = 1;counttime0 = 1;counttime1 = 0;counttime2 = 0;counttimef = 1;plotter = 1;firsttimeOff = 2;firsttimeOn = 6;
Jain, Pontius, Vora 13
secondtime = 1;secondtimeOn = 4;rampuptime = [];rampdowntime = [];inbetweentime = [];finaltime = 0; while(g < 3000)[inputvoltage, f, h, i] = EAnalogIn(-1, 0, 0, 0)a = g/2;whole = floor(a);part = a-whole;if part > 0; vn = 1; number = inputvoltage;else vn = 2; number = finaltime;end voltages(n) = [inputvoltage]; plotvoltagetime(n, vn) = [number] plotx(plotter) = [plotvoltagetime(n, 2)]; plotx = plotx(plotx ~=0) ploty(plotter) = [plotvoltagetime(n, 1)]; ploty = ploty(ploty ~=0); plotz = [0, plotx] plotter = plotter + 1 t = 0;if inputvoltage < .45 tic; y = 5; [a, b] = EAnalogOut(w, x, y, z); toc; t = toc; rampuptime(counttime) = [t]; x0 = sum(rampuptime); counttime = counttime + 1;elseif inputvoltage > .415 tic; y = 0;
Jain, Pontius, Vora 14
[a, b] = EAnalogOut(w, x, y, z); toc; t = toc; rampdowntime(counttime0) = [t]; counttime0 = counttime0 + 1; x1 = sum(rampdowntime); x2 = sum(inbetweentime); u = (counttime1) * ((firsttimeOff) + (firsttimeOn));v = (counttime2) * ((secondtime) + (secondtimeOn)); endu = (counttime1) * ((firsttimeOff) + (firsttimeOn));v = (counttime2) * ((secondtime) + (secondtimeOn));x0 = sum(rampuptime); x2 = sum(inbetweentime); x1 = sum(rampdowntime);finaltime = (x1) + (x2) + (x0) + (u) + (v); g = g + 1; n = n + 1;end voltages; x0;x1;x2;u;v;plot(plotz, ploty);
FINAL PLOT:
Jain, Pontius, Vora 15
High Voltage: .4590
Low Voltage: .4443
MAXIMIM Difference .0147
Error = +/- 17 Degrees Celsius
Explanation:
In the first experiment we were actually close to our mark. The problem that we faced in
this experiment was over shoot. You can see in the graph that after it gets near its target
temperature, it begins to overshoot low and then go out of control. After facing this problem we
knew we had to fix the code and figure out a new way for it to heat up and cool down. Our error
was also way to high which correlates to the overshooting. The rise is too fast, there needed to be
a way to slow it down, which was what we did next.
Experiment 2:
• Target Temperature: 350 degrees Celsius
• Code:
function [a, b] = clutch2(w, x, z)
g = 2;n = 1;vn = 0;counttime = 1;counttime0 = 1;counttime1 = 0;counttime2 = 0;counttimef = 1;plotter = 1;firsttimeOff = 2;firsttimeOn = 6;secondtime = 1;secondtimeOn = 4;rampuptime = [];rampdowntime = [];inbetweentime = [];
Jain, Pontius, Vora 17
finaltime = 0; while(g < 3000)[inputvoltage, f, h, i] = EAnalogIn(-1, 0, 0, 0)a = g/2;whole = floor(a);part = a-whole;if part > 0; vn = 1; number = inputvoltage;else vn = 2; number = finaltime;end voltages(n) = [inputvoltage]; plotvoltagetime(n, vn) = [number] plotx(plotter) = [plotvoltagetime(n, 2)]; plotx = plotx(plotx ~=0) ploty(plotter) = [plotvoltagetime(n, 1)]; ploty = ploty(ploty ~=0); plotz = [0, plotx] plotter = plotter + 1 t = 0;if inputvoltage < .2 tic; y = 5; [a, b] = EAnalogOut(w, x, y, z); toc; t = toc; rampuptime(counttime) = [t]; x0 = sum(rampuptime); counttime = counttime + 1; elseif ((inputvoltage > 0.20) & (inputvoltage < .30))counttime1 = counttime1 + 1; tic;while t < firsttimeOff y = 0; [a, b] = EAnalogOut(w, x, y, z); toc; t = toc; end tic;while t < firsttimeOn y = 5; [a, b] = EAnalogOut(w, x, y, z); toc; t = toc; endelseif((inputvoltage > .301)& (inputvoltage < .415)) tic y = 5; [a, b] = EAnalogOut(w, x, y, z); toc t = toc; inbetweentime(counttimef) = [t]; x2 = sum(inbetweentime);
Jain, Pontius, Vora 18
counttimef = counttimef + 1;elseif inputvoltage > .415 tic; y = 0; [a, b] = EAnalogOut(w, x, y, z); toc; t = toc; rampdowntime(counttime0) = [t]; counttime0 = counttime0 + 1; x1 = sum(rampdowntime); x2 = sum(inbetweentime); u = (counttime1) * ((firsttimeOff) + (firsttimeOn));v = (counttime2) * ((secondtime) + (secondtimeOn)); endu = (counttime1) * ((firsttimeOff) + (firsttimeOn));v = (counttime2) * ((secondtime) + (secondtimeOn));x0 = sum(rampuptime); x2 = sum(inbetweentime); x1 = sum(rampdowntime);finaltime = (x1) + (x2) + (x0) + (u) + (v); g = g + 1; n = n + 1;end voltages; x0;x1;x2;u;v;plot(plotz, ploty);
FINAL PLOT:
Jain, Pontius, Vora 19
High Voltage: 0.4150V
Low Voltage: 0.4033V
MAXIMUM difference: .0117V
Error: +/- 8 Degrees Celsius
Explanation:
In the second experiment we came very close to the goal. Our error improved and we had
less overshoot. As you can see in the graph we began the slow down process after 63%. Because
of this the stove slowed its heating process but still increased. Once it reached the target
temperature it began to stay close. Although it looked good at first it seemed we still have the
overshoot problem and have not made the degree of freedom we wanted. This can only be
explained but the duty cycles not being what they were supposed to. After watching this trial we
realized it needs to be even more controlled towards the end. Although it comes very close, the
overshoot still needs to be maintained so it does not blow out of proportion. This lead us to
experiment number 3.
Experiment 3:
• Target Temperature: 350 degrees Celsius
• Code:
function[a, b] = clutchit(w, x, z)
g = 2;
n = 1;
vn = 0;
counttime = 1;
Jain, Pontius, Vora 21
counttime0 = 1;
counttime1 = 0;
counttime2 = 0;
counttimef = 1;
plotter = 1;
firsttimeOff = 2;
firsttimeOn = 6;
secondtime = 1;
secondtimeOn = 4;
rampuptime = [];
rampdowntime = [];
inbetweentime = [];
finaltime = 0;
while
(g < 3000)
[inputvoltage, f, h, i] = EAnalogIn(-1, 0, 0, 0)
a = g/2;
whole = floor(a);
part = a-whole;
if
part > 0;
vn = 1;
number = inputvoltage;
else
vn = 2;
number = finaltime;
end
voltages(n) = [inputvoltage];
plotvoltagetime(n, vn) = [number]
plotx(plotter) = [plotvoltagetime(n, 2)];
plotx = plotx(plotx ~=0)
ploty(plotter) = [plotvoltagetime(n, 1)];
Jain, Pontius, Vora 22
ploty = ploty(ploty ~=0);
plotz = [0, plotx]
plotter = plotter + 1
t = 0;
if
inputvoltage < .2
tic;
y = 5;
[a, b] = EAnalogOut(w, x, y, z);
toc;
t = toc;
rampuptime(counttime) = [t];
x0 = sum(rampuptime);
counttime = counttime + 1;
elseif ((inputvoltage > 0.20) & (inputvoltage < .30))
counttime1 = counttime1 + 1;
tic;
while
t < firsttimeOff
y = 0;
[a, b] = EAnalogOut(w, x, y, z);
toc;
t = toc;
end
tic;
while
t < firsttimeOn
y = 5;
[a, b] = EAnalogOut(w, x, y, z);
toc;
t = toc;
end
Jain, Pontius, Vora 23
elseif
((inputvoltage > 0.30) & (inputvoltage < .38))
counttime2 = counttime2 + 1;
tic
while
t < secondtime
y = 0;
[a, b] = EAnalogOut(w, x, y, z);
toc;
t = toc;
end
tic;
while
t < secondtimeOn
y = 5;
[a, b] = EAnalogOut(w, x, y, z);
toc;
t = toc;
end
elseif
((inputvoltage > .38)& (inputvoltage < .415))
tic
y = 5;
[a, b] = EAnalogOut(w, x, y, z);
toc
t = toc;
inbetweentime(counttimef) = [t];
x2 = sum(inbetweentime);
counttimef = counttimef + 1;
elseif
inputvoltage > .415
tic;
Jain, Pontius, Vora 24
y = 0;
[a, b] = EAnalogOut(w, x, y, z);
toc;
t = toc;
rampdowntime(counttime0) = [t];
counttime0 = counttime0 + 1;
x1 = sum(rampdowntime);
x2 = sum(inbetweentime);
u = (counttime1) * ((firsttimeOff) + (firsttimeOn));
v = (counttime2) * ((secondtime) + (secondtimeOn));
end
u = (counttime1) * ((firsttimeOff) + (firsttimeOn));
v = (counttime2) * ((secondtime) + (secondtimeOn));
x0 = sum(rampuptime);
x2 = sum(inbetweentime);
x1 = sum(rampdowntime);
finaltime = (x1) + (x2) + (x0) + (u) + (v);
g = g + 1;
n = n + 1;
end
voltages;
x0;
x1;
x2;
u;
v;
plot(plotz, ploty);
FINAL PLOT:
Jain, Pontius, Vora 25
High Voltage: .4150V
Low Voltage: .4073V
MAXIMUM Difference: .0077
Error: +/- 2.3 Degrees Celsius
Explanation:
As you can see our final plot does exactly what we wanted. At the 63% range it begins to
slow down. Then at the 85% range it slows down even more in order to maintain control. Soon it
begins to fluctuate around the region of 350 degrees Celsius. After much time and proper coding
we were able to maintain our target temperature. After learning from our first and second
experiment we realized what it took in order to maintain target temperatures. We needed to slow
down the burner and bring it to an average temperature in order to maintain stability. As you can
see there is no overshoot in our last plot. We were able to lose to overshoot by coding in three
separate processes.
6. Improvements:
We are sure that there might be many areas of improvement. A faster relay, a faster
voltage amplifier, and of course a better stove which can keep its heat better and not fluctuate so
much. Although these would greatly help out project, there is one area of improvement which we
think could have significantly helped our results. One of the main issues we ran into was our
code and the duty cycle. Though we were able to find a duty cycle that worked for us, just
recently we uncovered a way we also could have controlled the stove. Instead of using duty
cycles, a great way of control would have been phase control(2). If we were able to use phase
control, we could have really clued into the behavior of the stove and controlled it more
precisely. If we could have found a way to take in the AC voltage, use a transformer to bring it
Jain, Pontius, Vora 28
down to about 5VAC, and then watch its period we could have been able to control the phase
with impulses. We could have precisely turned the stove to only be on for a certain time during
its phase. If we were able to control the stove along with the phase of the AC source, we could
have completely controlled how long the stove stays on and off. If we were to take this approach
it would have been a lot easier with a solid state relay so it can switch a lot faster without
creating mechanical problems. To better explain this idea we have included graphs and ideas in
order to show this could have been done:
Jain, Pontius, Vora 29
7. Other Issues:
Another issue that came about was our safety because we were using a coil that
had a maximum temperature of 440 degrees Celsius and our application required us to
test our system at 350 degrees Celsius. After collecting all our information we came to the
conclusion that we needed to buy a regular hot plate, one which had its own support and base, as
our heating source and not just a heating coil which we would have to purchase a power supply
to run. The hot plate we used for our project connected directly to the wall outlet, which allowed
us to avoid buying another power source. This worked out very well for us. Although our project
worked well, we still feel the stove was more of an issue. If we had been able to use a real coil
and base, maybe something of better quality, we would have been able to better control our
system.
8. Team Work:
When we started working on this project we had a lot of questions that needed to be answered.
The process began by studying black body radiation and moved on to picking parts and so forth.
We broke down the project in strength areas in order to be efficient. It broke down as followed:
• Programming in Matlab – Two people to be in charge of making the control
algorithm and interfacing all the different components using LabJack U12.
• Plant and sensor – One person to be in charge of implementing the plant, which
includes the relay, heater coil and thermocouple (sensor).
Jain, Pontius, Vora 30
As our project progressed, we realized that we had very good team chemistry and worked
efficiently together. Thus, despite having our work split up as above, we ended up working on
everything together. This was beneficial to all group members as we were able to learn about all
the different areas of our project inside out. One of the main problem areas was controlling the
Labjack with Matlab but we luckily had help online with debugging. Every weekend, we put a
good 5 or 6 hours of work into our project as there was a lot of troubleshooting to be done. We
had our first prototype ready by the end of 8th week this quarter and spent the last two weeks to
test and fine-tune our system. Overall, this senior design project did a good job of demonstrating
to us how much work and time actually goes into any project. We learned that with every one
solution there are about five other problems.
9. Summary:
Within weeks of the beginning of fall quarter senior year, our group was at the
drawing boards, planning and mapping out the next two quarters and setting goals in
order to accomplish the senior design project. We began by plotting our weekly goals for each
week on a calendar up until the presentation of the project. Planning which weeks to complete
research for parts, which weeks to buy parts and which weeks to assemble parts really gave us a
map of our timeline. As we researched more for our project, we initially had a feedback network
block diagram for our system. After buying parts and putting things together we figured slowly
how some parts were not going to work and some were manageable. We went to several
electronics stores to speak with specialists who could guide us with which parts to choose and
the interfacing between them. As we continued to work on our project we improved our system
Jain, Pontius, Vora 31
significantly. In particular, we decided to use a Matlab algorithm as our controller, we
determined the best way to send the thermocouple voltage to the controller and we found a
heating source that matched our application. Our fastest progress was during winter quarter when
we tested the system after our first prototype was assembled. As the system began to work, we
tweaked our Matlab algorithm for optimal performance. Lastly, when our project completely
worked we focused on our oral presentation. This project has been a great learning experience
and our group has grown in strides as engineers.
Jain, Pontius, Vora 32
11. References:
1 Ibrahim, Dogan. Microcontroller Based Temperature Monitoring & Control. Woburn, MA:
Elsevier Science, 2002.
2 Serway, Raymond A., and John W. Jewett, Jr. Physics for Scientists and Engineers. 6th ed.
Belmont, CA: Brooks/Cole-Thomson Learning, 2004.
3 Stephenson, D. A. "Tool-Work Thermocouple Temperature Measurements--Theory and
Implementation Issues." CSA Illumina. Nov. 1993. 23 Nov. 2007 http://md1.csa.com/partners/
viewrecord.php?
requester=gs&collection=TRD&recid=199603530161MD&q=Thermocouple&uid=792355797&
setcookie=yes
4 Raber, Ervin T. "Thermocouple Circuit Detector for Simultaneous Analog Trend Recording."
Oct. 1997. 22 Dec. 2007 <http://www.google.com/patents?
hl=en&lr=&vid=USPAT3973184&id=kGUrAAAAEBAJ&oi=fnd&dq=thermocouple+to
+analog>
5 Long, Ming. "Virtual Instruments Was Analyzed Based on LabJack." CSA Illumina. Mar. 2005.
22 Nov. 2007 http://md1.csa.com/partners/viewrecord.php?
requester=gs&collection=TRD&recid=2006076141681MT&recid=2006075232654CI&q=labjac
k&uid=792355797&setcookie=yes.
Jain, Pontius, Vora 33