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 :
#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 (260.91 KiB) Viewed 2057 times
Last edited by harsheel on Tue Mar 04, 2014 2:27 am, edited 2 times in total.
#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.
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?
#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.
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.
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.
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???????????
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.