This article shows how to use an ADC chip on your next project.
For this this project you can either choose to use the MAX186 or
the MAX187. The differences between these two chips are described
The MAX187 is an 12 bit one analog input ADC. The MAX187 requires
a 3 pin interface to communicate with the Stamp, CS(chip select),
DOUT(serial data), and SCLK(serial clock). It requires no external
reference voltage or external clock, its all built in to the chip.
The Max186 is an 12 bit 8 Channel ADC. Eight Channels means it can
measure 8 different voltages at once. There are many sensor around
today that output a voltage and to take the reading from them you
need to measure a voltage. Analog to Digital converters are a way
to interface the Basic Stamp, or other microcontrollers to the
analog world. They can measure hundreds of volts depending on the
voltage divider you use.
The reason for a voltage divider is because the MAX186 ADC can
only take an input voltage of 4.096V. A voltage divider a way the
divide the voltage you want to monitor. For instance say you want
to monitor a 12V car battery. But the MAX186 can only handle 4V
right. So how would you do this? Simple, a voltage divider. To
measure 12 Volts you want to divide
the voltage by 3. So all you need it a 220K resistor and a 100K.
Put them in series and connect your 12V to the 220K and GND to the
other end of the 100K. Then your output to the Op-amp comes from
the middle where the two resistor are connected.
Here is a formula to figure out the output. Vout=(R2/RT)*Vin
Now put the 12V into the formula Vout = (100K/320K)*12V= 3.75V Now
just times the 3.75V by 3.2 in your stamp program to get 12 Volts.
If you want to measure 100V, for instance, use a 1M and and a 33K.
Now here is what the op amp is for. The op-amp is in a voltage
follower configuration. This is a special case of a non-inverting
amplifier where all of Vout is fed back to the inverting input.
The straight feedback connection causes a voltage gain of approximately
one and a Av (Current gain) of one. The most important feature of
the voltage follower are its very high input impedance and
its very low output impedance. These features make it a ideal
buffer amplifier for interfacing high impedance sources and low
impedance loads. In other words it isolates the input from the
ADC. Another feature of the op-amp is its noise filtering. The two
inputs of the op-amp go directly into a differential amplifier
which compares the inputs and cuts the noise out completely. Most
of today’s sensors, that put out a voltage are very sensitive
(such as the LM35) which puts out 10mV/degree C and if you have
the slightest bit of noise and your readings are going to be off
by quite a bit. If you want more detailed info on the MAX186
download the data sheet.
Also the Max186 is available from Maxim
for free. Go to the products section and click request free
samples and they will send them to you, but be warned, it may take
a while for them to ship it. If you want to buy the MAX186 it will
run you about $50! They can be purchased at Digi-Key
or other electronics vendors.
Below is the code for interfacing with the MAX186 A/D converter to the
Basic Stamp II.
CS con 1
SerData_in con 2
adc var word
Channel var nib
BASIC Stamp is a registered trademark
of Parallax, Inc.
Shaun is the webmaster of a
basic stamping page click
here to visit his site.