DIY Meat Thermometer with Predictive Filter

Uploaded by nerdkits on 14.06.2009

Hi. To passionate chefs, cooking is an art. Knowing exactly when a cut of meat is done
to perfection requires knowledge of your meat, your grill, and really most of the time it
comes down to a Jedi art, more so than a solid science. Now, I don't presume to take anything
away from those passionate chefs who prefer to cook on nothing but a whim and a spatula,
but for those of us whose senses aren't quite yet that attuned, sometimes it helps to have
a little help in the form of a meat thermometer that can tell us the temperature at the exact
center of the meat. Now this meat thermometer can be a lot more exciting if you build it
yourself. And it can be even cooler if you use signal processing techniques to predict
the temperature faster. The meat thermometer is an interesting project
because it shows off how we can use engineering to vastly improve an otherwise crude design.
The temperature sensor in this project really is just a thermometer that we are ramming
in to your steak. However, we do a series of things to make it a much better design.
We first start with a physical assembly. It is true that physically sticking the whole
temperature sensing chip inside the meat would be ideal for measuring the temperature, but
it would probably not be that tasty, so we do the next best thing and transfer the heat
using a small piece of copper wire. We attach this copper wire to the sensor using a small
drop of super glue. Copper is very good at transferring heat -- roughly 20 times better
than stainless steel -- and it is so much better than air that we can sort of assume
that the temperature at the tip will quickly make its way over to the temperature sensor
on the other side. To help transfer the heat from the copper wire to the chip itself, we
use a piece of copper desoldering braid and wrap it around a couple of times. We also
take the ground pin of the temperature sensor and bend it up against the desoldering braid.
This creates a really quick thermal path from the braid to the internals of the chip. We
then solder it all together. You want to be careful in this step because heating it for
too long can damage the chip. Don't be too concerned about getting it all covered with
solder. As long as the copper braid is wrapped around tightly, it should be good enough.
The point of all this is to do our best to make sure there's a very short thermal path
from the tip of the wire probe to the temperature sensor chip itself.
Now, we solder some wire onto the leads so that we can plug it into our breadboard. We
made a wire braid out of the normal colored wire. You can solder the ground wire onto
any part of the solder braid, but make sure there is a solder path between the ground
wire and the ground pin of the temperature sensor. We also wrapped some electrical tape
around the leads so we can keep them all electrically separated. Then, we covered the chip and the
leads in 5 Minute Epoxy. This serves both to keep the whole setup together and protect
the electronics from the food or water you might be sticking it near.
You know you're an engineer when you're more worried about your electronics than your food.
At this point, our contraption is ready to be used as a thermometer, and we can connect
it to the NerdKit, and from there to the computer. But looking at this live graph of temperature
versus time, you'll see that the whole system is really quite slow to react to a change
in temperature. This relatively slow reaction from a change in temperature at the tip, to
a change in the output signal, can be fine if you're measuring in a relatively steady
room temperature. But when you're looking for a more instantaneous reading from your
meat, you have to be a little more creative. This is a good time to talk about a very advanced
topic: the transfer function of a system. All linear systems with inputs and outputs
can be thought about in terms of the transfer function of the system. We sort of got a peek
at the transfer function of our thermometer when we looked at what happened when we stuck
it in hot water. When we stuck it in hot water, we very quickly changed the temperature at
the tip from room temperature to boiling. But you saw that the output actually took
a little while to respond. This is known as the step response of the system. And this
step response can actually tell us an awful lot about what the actual transfer function
of the system is. And knowing that, it can help us predict what the temperature at the
tip is based on some initial readings. Think of it this way: if I was to put a different
temperature at the tip and I was to let you watch the curve as it slowly rised and then
reached its final value, I bet you about after the third time or so that I let you do this,
you can get pretty good at predicting what the final value was going to be based on just
a couple of these initial readings. So, for example, if you saw sort of this curve at
the beginning, you would go, uhm, and say it was going to end up there. And if you saw,
sort of, this curve at the beginning, you would continue this line and sort of estimate
where it was going to end up. What you're doing there in your head is actually inverting
the transfer function of the system and guessing what the initial reading was based on just
a few of the samples and how fast they were rising. Well what if I told you that we could
have a mathematical model of what the transfer function actually is, and that we could invert
that mathematical model in software instead of having you do it in your head? Well, that's
actually what signals people do all the time, and so for a better explanation of this, here's
Mike. Lots of things in nature have what's called
a first-order response. In a very general way, this just means that the rate of change
of something has to do with how much of that thing there currently is. One example is your
body metabolizing the medicine in your bloodstream at a rate proportional to how much is left,
giving a biological half-life that's characteristic for each substance. You might have heard this
called exponential decay. Another example is a cup of hot coffee dissipating its heat
energy to the air and cooling down. Heat is removed at a rate roughly proportional to
the temperature difference between the coffee and the air. Finally, for an electrical example,
the rate of flow of charge filling a capacitor in an RC circuit driven from a battery is
proportional to the difference in voltage between the capacitor and the battery. In
this case you get a graph that looks like this. And for this RC circuit, this graph
is the voltage across the capacitor when we suddenly connect the battery. It rises quickly
at first because the entire battery voltage is across the resistor. Then, as the capacitor
voltage increases, the voltage drop across the resistor has to get smaller, so the current
decreases because of Ohm's Law. If you go through the math or remember back to your
Physics class, the equation for this curve is VB, battery voltage, times 1 minus e to
the minus T over RC -- RC is that time constant. So I want to show you something cool, kind
of special about this equation. If we take V of T and we add in RC times its derivative,
dv/dt, we can actually use that to predict the eventual value that the curve is going
to rise to. So graphically, what this equation means is I can take any point on this curve,
draw the tangent line, and if I go forward in time by one time constant, I end up exactly
at VB. And the cool thing is I can do that anywhere on this curve. So I take this tangent
line, go forward on the same amount of time, I again end up right at VB.
So, if you want to see this graphically or in the equations, you can go expand this equation
VB minus VB * e to the minus T over RC. That's just this part expanded. Then we add in RC
times the derivative of this part which is 1 over RC times VB, e to the minus T over
RC. So if you look at this, the RC is cancelled and you end up getting this part and this
part completely cancelling each other, and you're just left with the VB. That's showing
the same thing over here. And again, the important thing to remember is that just by looking
at any one tangent line, just by knowing the voltage and its slope at any point, you can
actually predict the eventual value it's going to settle to. Now this might sound like a
lot of work just to get back to what we started with, but you have to remember, we started
with a signal that looked like this. Our measurement capabilities forced us to read a signal that
looked like this. But we were able to use math to go back and predict ahead of time
what the original signal was without having to wait for our measurement to settle out.
And it might seem like this will only work when you're stepping from one value to another,
but if you get a little deeper into linear systems theory, you'll see it actually works
no matter what shape the input takes. So what we're going to do with the microcontroller
is exactly that. Take the sensor reading and its derivative and combine them in a way that
lets us predict ahead of time what the final value is going to be.
So now we are going to do the same thing we did before, going from room temperature to
hot water. But now we are showing two lines. The blue line is the raw temperature measurement
coming from the sensor. And the green line is the output of our predictive filter. Notice
how the green line rises much faster than the measured output and is continuously guessing
what the temperature at the tip actually is. Pretty cool, huh? There is one last little
point in this discussion. Since we used a derivative to try to predict what the actual
temperature was, we ran into a problem with noise. Small variations in the measured temperature
due to noise can cause wild fluctuations in our guess, so we need to sort of average out
these guesses and help out and filter away the noise. This sort of sets up one of those
very common trade outs we have to make in engineering. The less we filter, the faster
our guess will be, but very inaccurate due to noise. If we try to filter the noise too
much, then we pretty much end up with the original slow output signal. So you trade
off speed versus accuracy and find the right middle ground, and then get cooking. I don't
really want to have my laptop next to the grill so we are using the NerdKits LCD to
show the raw temperature measurement and the predicted value from our filter. You actually
have all the electronics parts you need in the USB NerdKit to do this project. For more
information about our kits, or more videos like this one, visit us at
Happy grilling!