by Jon Williams
Putting the Spotlight on BASIC Stamp Projects, Hints, and Tips
Getting Hot, Hot, Hot
I think it’s fair to say that my friends would
tell you I’m a bit of a quirky guy. I accept that; I
am what I am. One of my many quirks — one
that makes me laugh at myself — is how freakishly sensitive I am to temperature. I probably
adjust the thermostat in my home 15 to 20
times a day — and that includes the night, too
(if I have to get up for a drink of water, I’m visiting the thermostat). Well, now that it’s summer in
north Texas, it’s getting hot (as it is in most of the
northern hemisphere) and it’s probably time for
more experiments with temperature.
Like the BASIC Stamp, the Maxim/Dallas DS1620
has been around a long time and has been a big
part of my temperature-based projects. Yet in all
this time, I had never explored the high-resolution use of
the DS1620. “High resolution?” you ask. Yeah. With just a
little bit of extra work, we can get temperature resolution
to 0.05 degrees Celsius (0.09 degrees Fahrenheit) from
our old stand-by. How is this possible?
You see, the DS1620 actually measures temperature
through the use of a couple temperature-controlled oscillators that drive a counter. When one oscillator rolls over within the period determined by the other oscillator, the temperature count is incremented (from the base of -55C). The key
for us is that the fractional portion of the temperature can
be determined by examining the count left over at the end
of the conversion period and comparing it to the number of
counts per degree (called the slope – this value is used to
linearize the natural non-linear behavior of the oscillators).
Before we get to the high-resolution calculation, let’s go
back to what we know and use the standard calculations
first. What we will do differently is configure the DS1620 so
that it converts temperature only when requested (we’ve
typically set it up for continuous conversion), and we’ll
recode for PBASIC 2.5 — which you’ll see makes things dramatically easier than before. Figure 1 shows the connections to the DS1620. For those of you that are new, don’t
leave the 1K resistor out of the circuit. The DQ pin is bidirectional and the resistor protects the BASIC Stamp and
the DS1620 in the event that both IO pins are made outputs
and driven in opposite directions (one high, one low —
which would cause a short circuit without the resistor).
Let’s get to the initialization. As you can see, it’s simpler than what we’ve used in the past as we’re just configuring for use with a CPU and in one-shot mode. We start by
activating the DS1620 (Reset pin is made high), then
writing % 11 to the configuration register. When that’s done,
we can deactivate the DS1620 by taking the DS1620 low.
SHIFTOUT DsDQ, DsClk, LSBFIRST, [WrCfg, %11]
Figure 1. DS1620 Connections.
NUTS & VOLTS
Just a note on the DS1620 Reset pin: It does more
than select the device we’re addressing; it also terminates
a communication “burst” with the host. I bring this up so
that you don’t think you can tie that line high when you’re
just using one DS1620 in a project.
Okay, you may notice that the program doesn’t run correctly the first time — we have to cycle power for the new configuration to “take.” Now that we’ve configured the DS1620
for one-shot mode, let’s start a temperature conversion.
SHIFTOUT DsDQ, DsClk, LSBFIRST, [StartC]
How do we know when the conversion cycle is done?