Kronos Robotics and Electronics
Site Map
 
Home Zeus Projects App Notes Downloads Dios Athena Forums
 

DAN151

MAX127 12 Bit Data Acquisition System

  By Michael Simpson

 

I picked up a MAX127 Data Acquisition System chip.  After some playing around I now see where it gets its name.  The chip has 8 channels and each channel can read up to -10 to +10 volts on each channel even with a 5v power source. 

After playing with the built-in AtoD in various microcontrollers I can really appreciate the MAX127.   It can do up to 8k conversion per second.  Even with my crazy hook up (see below) the readings were spot on and only varied 1 or 2 points.  That's about .008 volts.

For real critical readings the chip can separate the analog and digital ground for less interference. 

 

The only downside for this chip is the cost.   This chip will cost you between $20 and $25.  This means unless your application needs the accuracy and bipolar capability use something else.  But if you need to detect negative and positive sweeps of an AC voltage this chip is for you.

Hookup

I saw a couple of different configurations for this chip but this one works the best for experimentation.  Its pretty much right off the datasheet.   I show it connected to Port 0 and Port 1 of a Dios 32 pin module but you can use and ports or any Dios chip or board.

 

Schematic 1 (click picture to enlarge)

 

 

I really don't want to get into the actual bits and bytes of the I2c Interface.  You can get that from the data sheet.  I created a function called MAX127read that should work for most applications.  Just copy the function to your program and start playing.  The comments lists the arguments and they match the MAX127 data sheet.

The demo program will print the raw reading and converted voltage from channel 0.

Program  (download it here)

'MAX127 Demo
func main()
dim ch0 as float
dim ch1 as float

const sda 0
const scl 1


loop:

ch0 =MAX127read(sda,scl,0,0,1,1)


print {.} "raw=", ch0," ",{.2} "Volts=",ch0*.00245*2
pause 500
goto loop



endfunc



'---------------------------------------------------------
'Read one of the channels from Max127
' sda data pin. Must be held high with 10k resistor
' scl clock pin. Must be held high with 10k resistor
' addr must mach A0,A1,A2 pins (0-7)
' chnl Max127 channel (0-7)
' rng 0=5v 1=10v
' bip 0=Unipolar 1-Bipolar
'
' Returns value as float 0-4095 uniploar -2047 - 2047 Bipolar
'---------------------------------------------------------
func MAX127read(sda,scl,addr,chnl,rng,bip) as float
  dim value
  dim control
  addr = 80 + addr
  control=chnl & 7 * 16
  control.bit(7)=1
  control.bit(3)=rng
  control.bit(2)=bip

'-----------------------------------------
'Set up control byte
'-----------------------------------------
  addr.bit(0)=0
  I2c_start(sda,scl)

'address
  I2c_sendbyte(sda,scl,addr) 'EEprom write
  I2c_getack(sda,scl)

'control
  I2c_sendbyte(sda,scl,control.byte(0))
  I2c_getack(sda,scl)

  I2c_stop(sda,scl)

  pauseus 25

'----------------------------------------
'Go read the conversion
'----------------------------------------
  addr.bit(0)=1
  I2c_start(sda,scl)

'address byte
  I2c_sendbyte(sda,scl,addr)
  I2c_getack(sda,scl)

  value.byte(1) = I2c_getbyte(sda,scl)
  I2c_sendack(sda,scl)
  value.byte(0) = I2c_getbyte(sda,scl)
  I2c_sendnack(sda,scl)

  I2c_stop(sda,scl)

  value = value / 16

  if value.bit(11) = 1 and bip = 1 then
     value = value -1 ^ 4095
      exit value * -1
    else
      exit value
   endif

endfunc


include \lib\DiosI2c.lib
 

Parts

DiosPro 40 Pin Chip

Dios Workboard Deluxe

 

Easy RS232 Driver  

DiosPro 28 Pin Chip

Dios 32 Pin Carrier (Carrier #1)

 

9 Pin Cable

Breadboard Regulator

 

MAX127 Chip: Sorry you will have to search the internet on this one.

 

Copyright © 2001 - 2007 Kronos Robotics