Home Getting Started My Stamp Projects Electric Eng. Projects My Robots My PIC Projects PIC Mircontrollers Downloads Links Email


Interfacing the MAX186 8 Channel ADC to the BSII to measure voltages

Introduction

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 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 forumla to firgure 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 opamp is in a voltage follower configuration. This is a special case of a noninverting amplifier where all of Vout is fed back to the inverting input. The straight feedback connection causes a voltage gain of appx one and a Av (Current gain) of one. The most important feature of the voltage follower are its very high imput inpedance and its very low output inpedance. These features make it a ideal buffer amplifer for interfacing high impedance sources and low impedance loads. In other words it isolates the Input from the ADC. Another feature of the opamp is its noise filtering. The two inputs of the opamp go directly into a differential ampifiler which compares the inputs and cuts the nosie out completely. Most of todays sensor that put out voltage are very senitive (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.



Code for interfacing with the MAX186 A/D converter to the Basic Stamp II. Schematic for this source code


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 ,[ADCin\12]
high cs
goto main




This is just the basic subroutine for reading the device. For the complete code with remarks and display subroutine, download the txt file of the code below.



Downloads

2 Kb BASIC Stamp II Code
9 Kb Schematic for connecting the MAX186 to the Stamp
250 Kb Datasheet for the Max186


Parts Needed

Component Manufacture Price Distrubitor Part Number
Basic Stamp II Parallax Inc. $43 US Parallax Inc. BS2
12 bit 8 Channel ADC Maxim $50 US Digikey MAX186
Serial Alphanumeric LCD Scott Edwards $79 US Scott Edwards BPP-420L








Home Stamp Projects EE Projects PIC projects Downloads Getting Started Links Robots

Last update: March 17/2001
Questions or comments email me at shaunwilson19@yahoo.com or

Put your comments or whatever on my message board