circuit-arduino uno, INA125P, ADS1115, load cell 4 wire

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
harsheel
 
Posts: 10
Joined: Mon Mar 03, 2014 3:46 pm

circuit-arduino uno, INA125P, ADS1115, load cell 4 wire

Post by harsheel »

i need help connecting the circuit with arduino uno, INA125P, ADS1115, loadcell- 4 wires (interface model: SSM-AJ-250)
I USED THIS CIRCUIT TYPE LOOKING OVER THE BLOGS. BUT DONT THINK SO THAT WORKS BUT ITS NOT LETTING ME UPLOAD A code.on arduino uno board.
code is :

Code: Select all

#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 #4 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("H");
    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.write(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.read();         // get MSB of reading
          data = data << 8;              // shift it to high byte of data
          data = data + Wire.read();  // 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
      //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
          
      //write configuration word to device
      Wire.beginTransmission(deviceAdd); // transmit to ADS1115 device
      Wire.write(0x01);                   // point to configuration register
      Wire.write(highByte(confWord));     // writes MSB of configuration word
      Wire.write(lowByte(confWord));      // writes LSB of configuration word
      Wire.endTransmission();            // stop transmitting
         
      //write low threshold value word to device
      Wire.beginTransmission(deviceAdd);  // transmit to ADS1115 device
      Wire.write(0x02);                    // point to low threshold register
      Wire.write(highByte(loCompair));     // writes MSB of low threshold word
      Wire.write(lowByte(loCompair));      // writes LSB of low threshold word
      Wire.endTransmission();             // stop transmitting
       
      //write high threshold value word to device
      Wire.beginTransmission(deviceAdd);  // transmit to ADS1115 device
      Wire.write(0x03);                    // point to high threshold register
      Wire.write(highByte(hiCompair));     // writes MSB of high threshold word
      Wire.write(lowByte(hiCompair));      // writes LSB of high threshold word
      Wire.endTransmission();             // stop transmitting
      
    }



error "avrdude: stk500_getsync(): not in sunc: resp=0x30
Attachments
adcINa_bb.png
adcINa_bb.png (260.91 KiB) Viewed 2057 times
Last edited by harsheel on Tue Mar 04, 2014 2:27 am, edited 2 times in total.

harsheel
 
Posts: 10
Joined: Mon Mar 03, 2014 3:46 pm

Re: circuit-arduino uno, INA125P, ADS1115, load cell 4 wire

Post by harsheel »

Code: Select all

#ifndef _ADS1115_H_
#define _ADS1115_H_

#include "I2Cdev.h"

// -----------------------------------------------------------------------------
// Arduino-style "Serial.print" debug constant (uncomment to enable)
// -----------------------------------------------------------------------------
//#define ADS1115_SERIAL_DEBUG

#define ADS1115_ADDRESS_ADDR_GND    0x48 // address pin low (GND)
#define ADS1115_ADDRESS_ADDR_VDD    0x49 // address pin high (VCC)
#define ADS1115_ADDRESS_ADDR_SDA    0x4A // address pin tied to SDA pin
#define ADS1115_ADDRESS_ADDR_SCL    0x4B // address pin tied to SCL pin
#define ADS1115_DEFAULT_ADDRESS     ADS1115_ADDRESS_ADDR_GND

#define ADS1115_RA_CONVERSION       0x00
#define ADS1115_RA_CONFIG           0x01
#define ADS1115_RA_LO_THRESH        0x02
#define ADS1115_RA_HI_THRESH        0x03

#define ADS1115_CFG_OS_BIT          15
#define ADS1115_CFG_MUX_BIT         14
#define ADS1115_CFG_MUX_LENGTH      3
#define ADS1115_CFG_PGA_BIT         11
#define ADS1115_CFG_PGA_LENGTH      3
#define ADS1115_CFG_MODE_BIT        8
#define ADS1115_CFG_DR_BIT          7
#define ADS1115_CFG_DR_LENGTH       3
#define ADS1115_CFG_COMP_MODE_BIT   4
#define ADS1115_CFG_COMP_POL_BIT    3
#define ADS1115_CFG_COMP_LAT_BIT    2
#define ADS1115_CFG_COMP_QUE_BIT    1
#define ADS1115_CFG_COMP_QUE_LENGTH 2

#define ADS1115_OS_INACTIVE         0x00
#define ADS1115_OS_ACTIVE           0x01

#define ADS1115_MUX_P0_N1           0x00 // default
#define ADS1115_MUX_P0_N3           0x01
#define ADS1115_MUX_P1_N3           0x02
#define ADS1115_MUX_P2_N3           0x03
#define ADS1115_MUX_P0_NG           0x04
#define ADS1115_MUX_P1_NG           0x05
#define ADS1115_MUX_P2_NG           0x06
#define ADS1115_MUX_P3_NG           0x07

#define ADS1115_PGA_6P144           0x00
#define ADS1115_PGA_4P096           0x01
#define ADS1115_PGA_2P048           0x02 // default
#define ADS1115_PGA_1P024           0x03
#define ADS1115_PGA_0P512           0x04
#define ADS1115_PGA_0P256           0x05
#define ADS1115_PGA_0P256B          0x06
#define ADS1115_PGA_0P256C          0x07

#define ADS1115_MV_6P144            0.187500
#define ADS1115_MV_4P096            0.125000
#define ADS1115_MV_2P048            0.062500 // default
#define ADS1115_MV_1P024            0.031250
#define ADS1115_MV_0P512            0.015625
#define ADS1115_MV_0P256            0.007813
#define ADS1115_MV_0P256B           0.007813 
#define ADS1115_MV_0P256C           0.007813

#define ADS1115_MODE_CONTINUOUS     0x00
#define ADS1115_MODE_SINGLESHOT     0x01 // default

#define ADS1115_RATE_8              0x00
#define ADS1115_RATE_16             0x01
#define ADS1115_RATE_32             0x02
#define ADS1115_RATE_64             0x03
#define ADS1115_RATE_128            0x04 // default
#define ADS1115_RATE_250            0x05
#define ADS1115_RATE_475            0x06
#define ADS1115_RATE_860            0x07

#define ADS1115_COMP_MODE_HYSTERESIS    0x00 // default
#define ADS1115_COMP_MODE_WINDOW        0x01

#define ADS1115_COMP_POL_ACTIVE_LOW     0x00 // default
#define ADS1115_COMP_POL_ACTIVE_HIGH    0x01

#define ADS1115_COMP_LAT_NON_LATCHING   0x00 // default
#define ADS1115_COMP_LAT_LATCHING       0x01

#define ADS1115_COMP_QUE_ASSERT1    0x00
#define ADS1115_COMP_QUE_ASSERT2    0x01
#define ADS1115_COMP_QUE_ASSERT4    0x02
#define ADS1115_COMP_QUE_DISABLE    0x03 // default

// -----------------------------------------------------------------------------
// Arduino-style "Serial.print" debug constant (uncomment to enable)
// -----------------------------------------------------------------------------
//#define ADS1115_SERIAL_DEBUG


class ADS1115 {
    public:
        ADS1115();
        ADS1115(uint8_t address);
        
        void initialize();
        bool testConnection();
        
        // SINGLE SHOT utilities
        void waitBusy(uint16_t max_retries);

        // Read the current CONVERSION register
        int16_t getConversion();
        
        // Differential
        int16_t getConversionP0N1();
        int16_t getConversionP0N3();
        int16_t getConversionP1N3();
        int16_t getConversionP2N3();
        
        // Single-ended
        int16_t getConversionP0GND();
        int16_t getConversionP1GND();
        int16_t getConversionP2GND();
        int16_t getConversionP3GND();

        // Utility
        float getMilliVolts(); 
        float getMvPerCount();

        // CONFIG register
        uint8_t getOpStatus();
        void setOpStatus(uint8_t op);
        uint8_t getMultiplexer();
        void setMultiplexer(uint8_t mux);
        uint8_t getGain();
        void setGain(uint8_t gain);
        uint8_t getMode();
        void setMode(uint8_t mode);
        uint8_t getRate();
        void setRate(uint8_t rate);
        uint8_t getComparatorMode();
        void setComparatorMode(uint8_t mode);
        uint8_t getComparatorPolarity();
        void setComparatorPolarity(uint8_t polarity);
        bool getComparatorLatchEnabled();
        void setComparatorLatchEnabled(bool enabled);
        uint8_t getComparatorQueueMode();
        void setComparatorQueueMode(uint8_t mode);

        // *_THRESH registers
        int16_t getLowThreshold();
        void setLowThreshold(int16_t threshold);
        int16_t getHighThreshold();
        void setHighThreshold(int16_t threshold);
        
        // DEBUG
        void showConfigRegister();

    private:
        uint8_t devAddr;
        uint16_t buffer[2];
        uint8_t devMode;
        uint8_t muxMode;
        uint8_t pgaMode;
};

#endif /* _ADS1115_H_ */

I USED THIS CODE EITHER, ERROR "12Cdev.h: no such file or directory
Last edited by harsheel on Tue Mar 04, 2014 2:26 am, edited 1 time in total.

harsheel
 
Posts: 10
Joined: Mon Mar 03, 2014 3:46 pm

Re: circuit-arduino uno, INA125P, ADS1115, load cell 4 wire

Post by harsheel »

Code: Select all

#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 #4 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("H");
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.write(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.read(); // get MSB of reading
data = data << 8; // shift it to high byte of data
data = data + Wire.read(); // 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
//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

//write configuration word to device
Wire.beginTransmission(deviceAdd); // transmit to ADS1115 device
Wire.write(0x01); // point to configuration register
Wire.write(highByte(confWord)); // writes MSB of configuration word
Wire.write(lowByte(confWord)); // writes LSB of configuration word
Wire.endTransmission(); // stop transmitting

//write low threshold value word to device
Wire.beginTransmission(deviceAdd); // transmit to ADS1115 device
Wire.write(0x02); // point to low threshold register
Wire.write(highByte(loCompair)); // writes MSB of low threshold word
Wire.write(lowByte(loCompair)); // writes LSB of low threshold word
Wire.endTransmission(); // stop transmitting

//write high threshold value word to device
Wire.beginTransmission(deviceAdd); // transmit to ADS1115 device
Wire.write(0x03); // point to high threshold register
Wire.write(highByte(hiCompair)); // writes MSB of high threshold word
Wire.write(lowByte(hiCompair)); // writes LSB of high threshold word
Wire.endTransmission(); // stop transmitting
}
error "avrdude: stk500_getsync(): not in sunc: resp=0x30
same error messege.
can some help me with this code and even check if my circuit connection is correct.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: circuit-arduino uno, INA125P, ADS1115, load cell 4 wire

Post by adafruit_support_mike »

Our tutorial for using an ADS1115 is here: http://learn.adafruit.com/adafruit-4-ch ... s/overview

That links to our own code library which we know to work with the ADS1x15 breakouts we sell.

The "not in sync" error means the Arduino IDE can't even talk to your Arduino though. Have you selected the correct interface under the Tools -> Serial Port menu?

harsheel
 
Posts: 10
Joined: Mon Mar 03, 2014 3:46 pm

Re: circuit-arduino uno, INA125P, ADS1115, load cell 4 wire

Post by harsheel »

Code: Select all

#include <Wire.h>
#include <Adafruit_ADS1015.h>

//Adafruit_ADS1115 ads;     /* Use this for the 16-bit version */
Adafruit_ADS1015 ads;     /* Use this for the 12-bit version */

void setup(void) 
{
  Serial.begin(9600);
  Serial.println("Hello!");
  
  Serial.println("Getting single-ended readings from AIN0..3");
  Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
  
  // The ADC input range (or gain) can be changed via the following
  // functions, but be careful never to exceed VDD +0.3V max, or to
  // exceed the upper and lower limits if you adjust the input range!
  // Setting these values incorrectly may destroy your ADC!
  //                                                                ADS1015  ADS1115
  //                                                                -------  -------
  // ads.setGain(GAIN_TWOTHIRDS);  // 2/3x gain +/- 6.144V  1 bit = 3mV      0.1875mV (default)
  // ads.setGain(GAIN_ONE);        // 1x gain   +/- 4.096V  1 bit = 2mV      0.125mV
  // ads.setGain(GAIN_TWO);        // 2x gain   +/- 2.048V  1 bit = 1mV      0.0625mV
  // ads.setGain(GAIN_FOUR);       // 4x gain   +/- 1.024V  1 bit = 0.5mV    0.03125mV
  // ads.setGain(GAIN_EIGHT);      // 8x gain   +/- 0.512V  1 bit = 0.25mV   0.015625mV
  // ads.setGain(GAIN_SIXTEEN);    // 16x gain  +/- 0.256V  1 bit = 0.125mV  0.0078125mV
  
  ads.begin();
}

void loop(void) 
{
  int16_t adc0, adc1, adc2, adc3;

  adc0 = ads.readADC_SingleEnded(0);
  adc1 = ads.readADC_SingleEnded(1);
  adc2 = ads.readADC_SingleEnded(2);
  adc3 = ads.readADC_SingleEnded(3);
  Serial.print("AIN0: "); Serial.println(adc0);
  Serial.print("AIN1: "); Serial.println(adc1);
  Serial.print("AIN2: "); Serial.println(adc2);
  Serial.print("AIN3: "); Serial.println(adc3);
  Serial.println(" ");
  
  delay(1000);
}

i used this code from your library in adafruit tutorial and its giving me error messege
"
arduinocore:5: error: 'Adafruit_ADS1015' does not name a type
arduinocore.ino: In function 'void setup()':
arduinocore:28: error: 'ads' was not declared in this scope
arduinocore.ino: In function 'void loop()':
arduinocore:35: error: 'ads' was not declared in this scope
"
can you please help me what does this error messege is about as i am new too using this software and coding.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: circuit-arduino uno, INA125P, ADS1115, load cell 4 wire

Post by adafruit_support_mike »

That means you don't have the library installed in the right place.

This tutorial has a description of how to install libraries: http://learn.adafruit.com/adafruit-all- ... -libraries

harsheel
 
Posts: 10
Joined: Mon Mar 03, 2014 3:46 pm

Re: circuit-arduino uno, INA125P, ADS1115, load cell 4 wire

Post by harsheel »

https://github.com/adafruit/Adafruit_ADS1X15
i downloaded this codes in one zip file.
but still it says error in the Adafruit_ADS1115
i did folllow your instruction for libraries.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: circuit-arduino uno, INA125P, ADS1115, load cell 4 wire

Post by adafruit_support_mike »

That's the correct source for the Adafruit ADS1x15 library, but you need to remove the '-master' from the name of the folder the zipfile creates, then you need to move the folder to sketchbook/libraries.

harsheel
 
Posts: 10
Joined: Mon Mar 03, 2014 3:46 pm

Re: circuit-arduino uno, INA125P, ADS1115, load cell 4 wire

Post by harsheel »

i got the code working.
but is there any circuit's schematic diagram that connect the arduino uno or mega with INA125 , ADS1115 with loadcell (4 wire)???????????????
and should i use the same code for this type of circuit tooo???????????

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: circuit-arduino uno, INA125P, ADS1115, load cell 4 wire

Post by adafruit_support_mike »

The diagram you posted above has things laid out correctly. All the Arduino needs to see is the ADS1115. All the ADS1115 needs to see is the output from the INA125P. How you connect the INA125P to the load cell is entirely your business.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”