Ηλεκτρονική - Συσκευές

2 Νοε 2013 (πριν από 4 χρόνια και 6 μήνες)

107 εμφανίσεις

EGR 100

Lab 3 data sheet

Sept. 28, 2
007

p
erature Sensor

Datasheet

weatherproof temperature sensor with two long leads (one red and one
black, each approximately 30 cm long). The AD592
uses only a s
ingle I/O pin on the
Propeller

chip
. Since the Propeller has 32 I/O pins
,
you could

connect as many as 32

temperature sensors to a single microcontroller!

How do you start measuring temperature? Actually, using the AD592 quite simple
-

you can just build the circuit in shown in Fig. 1, type in the example code from Fig. 2,
and r
un the program. However, you will need to know a little more about how the
AD592 works in order to use it effectively.

Fig. 1 Circuit diagram for the AD592 conn
ected to a Propeller

(P
in 5)

' Simple Program for Measuring Temperature

CON

_clkmode = x
tal1 + pll8x

' clock freq x8

_xinfreq = 5_000_000

' clock freq 80 MHz

PUB MAIN | rctemp

' MAIN PROGRAM

repeat

' repeat loop

outa[5] := 0

' set pin to 0

dira[5] := 1

' make pin
output

waitcnt(clkfreq/1000
+ cnt) ' wait
discharge

dira[5] := 0

' make pin

input

rctemp := cnt

' store counter

waitpeq(|< 5,|< 5, 0)

' wait for change

rctemp := clkfreq/(||(cnt
-

rctemp)
-
1600)*354/1000
' convert to K

waitcnt(clkfreq+cnt)

' wait 1 sec

Fig. 2 SPIN
program for
ing

an

temperature sensor

on Pin 5

So h
ure sensor work? At its core, the AD592

is simply a
current source. At absolute zero (
-
273 on the Celsius scale)
current. For every degree above absolute zero, the AD592 produce
s a microamp, or
equivalently, one

millionth of an amp

of current
. Thus, at room temperature
(approximately 25 C or 298 K), the AD592 produces 298 microamps. If we know

how
EGR 100

Lab 3 data sheet

Sept. 28, 2
007

many microamps are being produced, we know the temperature. The trick is to turn the
very small curren
t into something the Propeller

microcontroller

can actually measure.

How does the AD592 measure microamps?

The current from the AD592 is

used to
cha
rge

a small capacitor,
which occurs as

t
he capacitor
plates collect the electrons

flowing as the electrical current
. The voltage

across the capacitor

is
proportional to the
number of electrons on one plate
.

To measure the current, and ultimately the
tempe
rature, t
he microcontroller
must

do two things. First,
it discharges the capacitor
by draining t
he
electrons from the capacitor
plate

(
creating an electrical path from the
capacitor plate to electrical ground
)
. S
econd,

it collects

electrons

back onto the

capacitor plate

via the current from the AD592 current source

and measure
s

how long it
takes the
plates to
be fully charged
.

The capacitor

is considered fully charged

when the

voltage across the

capacitor reaches

a level of 1.3 volts.

The higher the tem
perature,
the more
current the AD592 produces, and the faster the

capacitor plates are charged
.

Measure the amount of time it takes for the capacitor to
charge

and you know the
temperature. All you need is a mathematical formula to convert time into tempe
rature.

The formula is simply
Temperature

= Constant

/

Time
.

Looking at the circuit from Fig.
1, we define our
Constant

to be a function of the resistance, R, and the capacitance, C
in this circuit
.

If we knew the exact value
s of the resistor and capacit
or, and if all
Propeller chips

were exactly the same, we could have one
Constant

that always gave us
an accurate

temperature.

In reality, the resist
ors, capacitors, and Propeller
s are all
slightly different and no single
Constant

will work on all systems.

You

therefore need
to c
alibrate the temperature sensor to the R and C your are using, as well as to the
specific Propeller chip in your lab kit.

You can find this
Constant

b

at
just
one temper
ature. Start by
using the nominal
Constant

provided in the program above (3
54/1000
) and comparing

measurement with another thermometer that you trust (called a
S
tandard). Be s
ure to place the AD592 and the S
tandard thermometer close together
and allow them stabilize for a few

minutes. Then simply a
djust the
Constant

so that the

temperature matches the S
tandard.

For example,

low
er than the S
tandard
, you should in
crease the
Constant

slightly

and rerun your
program. After a little trial and error
, it is

quite easy to find the value of the
C
onstant

that makes the AD592 agree perfectly with the Standard.