A Simple And Free ADC For Your Microcontroller

This article shows how to use an ADC chip on your next project.

Introduction

For this this project you can either choose to use the MAX186 or
the MAX187. The differences between these two chips are described
below.

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.

MAX187 Code

MAX186 Code

SCLK
con 0
CS con 1
SerData_in con 2
adc var wordmain:
gosub convert
gosub print
goto main

print:
debug dec adc
return

convert:
low CS
Shiftin Serdata_in,SCLK,MSBPOST,[adc12]
high CS
return

Channel var nib
Chsel var byte
ADCin var word
X var nib
cs con 1
serDin con 2
serDo con 3
serclk con 4

high cs
main:
low cs
channel =0
lookup channel, [142, 206,158,222,174,238,190,254],chsel
shiftout serDo, serclk, msbfirst,[chsel]
shiftin serDin, serclk, msbpost ,[ADCin12]
high cs
goto main

Source : http://www.robotshop.com/blog/en/a-simple-and-free-adc-for-your-microcontroller-4276

 

M. Agus Tri Mulyono_125150300111036

Advertisements

One thought on “A Simple And Free ADC For Your Microcontroller

  1. really excellent beneficial article

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s