I am using ADS1115's to read sensor data. So far, so good. However, every time I request a value from the ADC, I need to wait for 8 ms conversion delay. I am looking for a shorter read-time but I do not know where to start.
I am using this library;
I think I must use continous mode instead of single-shot mode, but I don't know how to get it working. Any advice?
you might try to change the
#define ADS1115_CONVERSIONDELAY ( 8 )
line in the .h file of the library with 7,6 ... and see how low you can go.
I do not know what the datasheet says about minimal delay between reads.
Related question, do you need 16 bits?
I changed that, but once I decrease the value, the output is no longer corresponding to the analog signal.
I don't mind waiting for 8 ms, but I do mind if I need to wait for the chip 6 times per loop.
Can you tell me how to put the device in continous mode instead of single shot? I am not familiar with altering libraries yet.
Can you post your code?
To see why you wait 6 times ?
Voila, I use three ADS1115's on three boards. All have a different address and use two of the four inputs to read a sensor with two outputs. The ads1115 library is stock.
#include <Wire.h>
#include <Adafruit_ADS1015.h>
#include <SPI.h>
Adafruit_ADS1115 boardroll(0x4a);
Adafruit_ADS1115 boardpitch(0x4b);
Adafruit_ADS1115 boardyaw(0x49);
double sensor1;
double sensor2;
double sensor3;
//Gyro related
int result;
int result2;
int GyROLL;
int GyPITCH;
int GyYAW;
int16_t adcroll_1, adcroll_2;
int16_t adcpitch_1, adcpitch_2;
int16_t adcyaw_1, adcyaw_2;
void setup(void)
{
Wire.begin();
Serial.begin(19200);
SPI.begin();
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV2);
SPI.setDataMode(SPI_MODE0);
boardroll.setGain(GAIN_TWOTHIRDS);
boardpitch.setGain(GAIN_TWOTHIRDS);
boardyaw.setGain(GAIN_TWOTHIRDS);
boardroll.begin();
boardpitch.begin();
boardyaw.begin();
}
void loop(void)
{
adcroll_1 = boardroll.readADC_SingleEnded(1);
adcroll_2 = boardroll.readADC_SingleEnded(2);
adcpitch_1 = boardpitch.readADC_SingleEnded(1);
adcpitch_2 = boardpitch.readADC_SingleEnded(2);
adcyaw_1 = boardyaw.readADC_SingleEnded(1);
adcyaw_2 = boardyaw.readADC_SingleEnded(2);
digitalWrite(10, LOW);
result = SPI.transfer(0x20);
result = result << 8 | SPI.transfer(0x00);
result2 = SPI.transfer(0x00) >>2;
SPI.transfer(0x00);
GyROLL = result << 6 | result2;
digitalWrite(10, HIGH);
digitalWrite(8, LOW);
result = SPI.transfer(0x20);
result = result << 8 | SPI.transfer(0x00);
result2 = SPI.transfer(0x00) >>2;
SPI.transfer(0x00);
GyPITCH = result << 6 | result2;
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
result = SPI.transfer(0x20);
result = result << 8 | SPI.transfer(0x00);
result2 = SPI.transfer(0x00) >>2;
SPI.transfer(0x00);
GyYAW = result << 6 | result2;
digitalWrite(9, HIGH);
Serial.print(adcyaw_1);
Serial.print(',');
Serial.print(adcpitch_2);
Serial.print(',');
Serial.print(adcyaw_2);
Serial.print(',');
Serial.print(adcroll_2);
Serial.print(',');
Serial.print(adcroll_1);
Serial.print(',');
Serial.print(adcpitch_1);
Serial.print(',');
Serial.print(GyROLL);
Serial.print(',');
Serial.print(GyPITCH);
Serial.print(',');
Serial.print(GyYAW);
Serial.println();
}