Go Down

Topic: Is it possible to use 12 bit ADC or more? (Read 630 times) previous topic - next topic

Hello

In my project i need a resolution of 12 bits or more for my analog input(0-5v)

Is there anyway i could do that?

I've read something in the forum saying that i need an external ADC.  how do i do that?

Thanks

Quentin

Grumpy_Mike

Quote
i need an external ADC.  how do i do that?

Yes you do.
Look here:-
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1291916375
and follow the links.

Chagrin

The playground has a list of links for how to do analog to digital conversion using external ICs.

retrolefty

Here is a nice one that use the I2C bus

http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=230619695873&ssPageName=STRK:MEWAX:IT

Here is a sketch I wrote last weekend to check out it's performance. Works great


Code: [Select]


/* Basic testing and check out sketch for a TI ADS1115 4 channel 16 bit I2C analog to digital converter chip.
  Reads voltage at desired range on desired channel and displays it on serial monitor. Also allows comparitor
  to output a active low signal pin if enabled.
 
  Leftyretro 08/10/11
*/

#include <Wire.h>

int topofScale;          // global to use adc range value to display millivolt reading conversion
int hiCompair = 17000;   // high setting for comparitor threshold value, must be higher then loCompair 32767
int loCompair = 11000;   // low  setting for comparitor threshold value, must be lower then hiCompair -32768


void setup()
 {
   Wire.begin();           // join I2C bus
   Serial.begin(38400);    // initialize serial communication
   setadcConfiguration();  // configure ADS1115 chip for range, channel input, and comparitor options desired
  }
 
void loop() {
   int   rawValue;       // holds 16 bit result read from A/D device
   int   scaledValue;    // to convert to millivolts
   
   Serial.print("Analog input #1 counts =  ");
   rawValue = getadcReading();  // read current A/D value
   Serial.print(rawValue);
   Serial.print("  Millvolts =  ");
   scaledValue = map(rawValue, 0, 32767, 0, topofScale);  //convert raw adc counts to millivolts
   Serial.print(scaledValue);
   Serial.println("     Hit any key to continue");
   while(Serial.available() < 1) {}   // wait for user keystroke
   while(Serial.available() > 0) {byte userKeys = Serial.read();} //read keystrokes
}

int getadcReading()   // read 16 bit analog voltage reading
   {
     int data;
     int deviceAdd = 0x48;              // ADS1115 address with address pin grounded
     Wire.beginTransmission(deviceAdd); // transmit to I2c device address
     Wire.send(0x00);                   // point to device register 0
     Wire.endTransmission();            // stop transmitting
     
     Wire.requestFrom(deviceAdd, 2);    // request 2 bytes from slave device
     while(Wire.available())            // need two bytes, MSB and LSB of converstion value
       {
         data = Wire.receive();         // get MSB of reading
         data = data << 8;              // shift it to high byte of data
         data = data + Wire.receive();  // add LSB to data
       }
     return data;
   }
   
void setadcConfiguration()
   {
     int deviceAdd = 0x48;   // ADS1115 address with address pin grounded
     
           /* uncomment one desired voltage input range */
           
     int confWord= 0x0000; topofScale = 6144;  // +/-6.144 vdc range, electrical limit = Vcc
     //int confWord= 0x0200; topofScale = 4096;  // +/-4.096 vdc range
     //int confWord= 0x0400; topofScale = 2048;  // +/-2.048 vdc range
     //int confWord= 0x0600; topofScale = 1024;  // +/-1.024 vdc range
     //int confWord= 0x0800; topofScale =  512;  // +/-.512 vdc range
     //int confWord= 0x0A00; topofScale =  256;  // +/-.256 vdc range
     
     /*  uncomment one desired channel input
         This also sets sample rate to 860 SPS and turns on continous conversion mode. */
         
     confWord = confWord | 0x00E0;  //input wired to + AIN0 - AIN1, diff +/- max range
     //confWord = confWord | 0x30E0;  //input wired to + AIN2 - AIN3, diff +/- max range
     //confWord = confWord | 0x40E0;  //input wired to + AIN0 - gnd, single ended, 0 to +max range
     //confWord = confWord | 0x50E0;  //input wired to + AIN1 - gnd, single ended, 0 to +max range
     //confWord = confWord | 0x60E0;  //input wired to + AIN2 - gnd, single ended, 0 to +max range
     //confWord = confWord | 0x70E0;  //input wired to + AIN3 - gnd, single ended, 0 to +max range
     
     /* uncomment one desired comparator options
        active low ready pin, window mode = input voltage is inside window values
        active low ready pin, traditional = voltage raised above or fell below set values */
           
     //confWord = confWord | 0x0003;   //disable comparitor
     //confWord = confWord | 0x0008;    //enable comparitor in traditional comparator mode
     confWord = confWord | 0x0018;   //enable comparitor in window comparator mode
         
     //send configuration word to device
     Wire.beginTransmission(deviceAdd); // transmit to ADS1115 device
     Wire.send(0x01);                   // point to configuration register
     Wire.send(highByte(confWord));     // sends MSB of configuration word
     Wire.send(lowByte(confWord));      // sends LSB of configuration word
     Wire.endTransmission();            // stop transmitting
       
     //send low threshold value word to device
     Wire.beginTransmission(deviceAdd);  // transmit to ADS1115 device
     Wire.send(0x02);                    // point to low threshold register
     Wire.send(highByte(loCompair));     // sends MSB of low threshold word
     Wire.send(lowByte(loCompair));      // sends LSB of low threshold word
     Wire.endTransmission();             // stop transmitting
     
     //send high threshold value word to device
     Wire.beginTransmission(deviceAdd);  // transmit to ADS1115 device
     Wire.send(0x03);                    // point to high threshold register
     Wire.send(highByte(hiCompair));     // sends MSB of high threshold word
     Wire.send(lowByte(hiCompair));      // sends LSB of high threshold word
     Wire.endTransmission();             // stop transmitting
     
   }


Lefty

Go Up