Serial communication issue with 16 bit external ADC for arduino
Posted: Fri Mar 02, 2018 3:53 pm
Hi, I'm using Megunolink to test an XY plot of my arduino circuit data.
I've two analog measurements coming out of circuit captured by an external 16 bit ADC (ADS1115) (https://www.adafruit.com/product/1085). I've an Arduino UNo attached to the circuit. When I use the arduino's serial monitor, I can see readings of both measurements just fine. So I tried to plot a set of those using Megunolink interface XY plot.
For some reason, neither the 'XY plot' nor the 'Message monitor' visualizers is working with the 16 bit ADC. I say this because, I disconnected the 16 bit ADC and used arduino uno's inbuilt 8 bit ADC and your software works fine. I attached my code below.
Is this something related to your software libraries or compatibility issue. Please help me. I definitely need to use the 16 bit and if needed, a 24 bit ADCs in my project as I need greater resolutions for my analog measurements.
Thanks
program code:
#include "MegunoLink.h"
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads1115;
XYPlot MyPlot;
void setup()
{
Serial.begin(9600);
pinMode(9, OUTPUT); // PWM signal for measurement unit
pinMode(A0,INPUT); // Green push button
MyPlot.SetTitle("My Analog Measurement");
MyPlot.SetXlabel("Voltage(V)");
MyPlot.SetYlabel("Current(uA)");
MyPlot.SetSeriesProperties("Measurement", Plot::Magenta, Plot::Solid, 2, Plot::Square);
}
void loop()
{
int16_t adc0,adc1;
int Bstate = analogRead(A0);
analogWrite(9,0);
if (Bstate>100){
for(int i=0; i<=150; i+=5){ //i =255 for max 60.6 uA current input 127 for 30uA
analogWrite(9,i);
delay(500);
adc1 = ads1115.readADC_SingleEnded(1); //16 bit adc channel 1 value reading
adc0 = ads1115.readADC_SingleEnded(0); ////16 bit adc channel 0 value reading
delay(300);
float Voltage = adc0*0.000188; //ADC value to voltage conversion 188uV is a conversion factor for 16 bit adc
float Vi = adc1*0.000188; //ADC value to voltage conversion
float Current = Vi/0.09798; //V=IR using sense Resistor 97.98K and conversion
MyPlot.SendData("Measurement", Voltage, Current);
}
}
I've two analog measurements coming out of circuit captured by an external 16 bit ADC (ADS1115) (https://www.adafruit.com/product/1085). I've an Arduino UNo attached to the circuit. When I use the arduino's serial monitor, I can see readings of both measurements just fine. So I tried to plot a set of those using Megunolink interface XY plot.
For some reason, neither the 'XY plot' nor the 'Message monitor' visualizers is working with the 16 bit ADC. I say this because, I disconnected the 16 bit ADC and used arduino uno's inbuilt 8 bit ADC and your software works fine. I attached my code below.
Is this something related to your software libraries or compatibility issue. Please help me. I definitely need to use the 16 bit and if needed, a 24 bit ADCs in my project as I need greater resolutions for my analog measurements.
Thanks
program code:
#include "MegunoLink.h"
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads1115;
XYPlot MyPlot;
void setup()
{
Serial.begin(9600);
pinMode(9, OUTPUT); // PWM signal for measurement unit
pinMode(A0,INPUT); // Green push button
MyPlot.SetTitle("My Analog Measurement");
MyPlot.SetXlabel("Voltage(V)");
MyPlot.SetYlabel("Current(uA)");
MyPlot.SetSeriesProperties("Measurement", Plot::Magenta, Plot::Solid, 2, Plot::Square);
}
void loop()
{
int16_t adc0,adc1;
int Bstate = analogRead(A0);
analogWrite(9,0);
if (Bstate>100){
for(int i=0; i<=150; i+=5){ //i =255 for max 60.6 uA current input 127 for 30uA
analogWrite(9,i);
delay(500);
adc1 = ads1115.readADC_SingleEnded(1); //16 bit adc channel 1 value reading
adc0 = ads1115.readADC_SingleEnded(0); ////16 bit adc channel 0 value reading
delay(300);
float Voltage = adc0*0.000188; //ADC value to voltage conversion 188uV is a conversion factor for 16 bit adc
float Vi = adc1*0.000188; //ADC value to voltage conversion
float Current = Vi/0.09798; //V=IR using sense Resistor 97.98K and conversion
MyPlot.SendData("Measurement", Voltage, Current);
}
}