controleverythingcommunity / ads7828 Goto Github PK
View Code? Open in Web Editor NEWAnalog to Digital Converter
Analog to Digital Converter
I am reading wrong Voltage ADC values from the ADS 7828 board in the particle PHOTONH through I2C channel.
Even I haven’t given any input to AD0 & COM0 lines, I am reading random voltage values between 3.1 - 3.9. Actually, it should return zero values because I haven’t attached any input. Please refer below pics for more details. Actually, I don’t understand why I am reading wrong values through I2C. Please refer below source code and detail explanation of my input. If you guys have any idea on this issue, please provide your suggestions.
NOTE: we found reference of this source from this github community and modified it based our need.
// ADS7828 I2C address:- A0 = 0x49(73) & A1 = 0x4A(74)
#define Addr 0x49
int raw_adc = 0;
double Current = 0;
void setup()
{
// Set variable
Particle.variable("Current", Current);
// Initialize I2C communication as MASTER
Wire.begin();
// Initialize serial communication, set baud rate = 9600
Serial.begin(9600);
delay(300);
}
void loop()
{
byte data[2];
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send command byte
// Single Ended inputs
// Channel: 0 (zero) selected
// Internal Reference ON and A/D Converter ON
Wire.write(0x9C);
// Stop I2C transmission
Wire.endTransmission();
// Request 2 bytes of data
Wire.requestFrom(Addr, 2);
//Particle.publish("Digital: ", "read two bytes");
// Read 2 bytes of data
// raw_adc msb, raw_adc lsb
if(Wire.available() == 2)
{
Particle.publish("Digital: ", "after two bytes read");
data[0] = Wire.read();
data[1] = Wire.read();
// Output data to dashboard
Particle.publish("data D0: ", String(data[0]));
Particle.publish("data D1: ", String(data[1]));
// Converting the data to 12 bits
int raw_adc = ((data[0] & 0x0F) * 256) + data[1];
double Voltage = raw_adc * 0.0012207;
Particle.publish("Digital: ", String(Voltage));
// 1 sec delay
delay(1000);
}
else
Particle.publish("Digital: ", "Not available");
}
I2C READ (AD0 & COM0) or (ADx & COMx)
Output: 3.2 - 3.8 voltage values (instead it should return zero value)
1) CHANNEL SELECTION CONTROL
SD C2 C1 C0 CH0 CH1 CH2 CH3 CH4 CH5 CH6 CH7 COM
-----------------------------------------------
1 0 0 0 +IN - - - - - - - –IN
2) POWER DOWN SELECTION
PD1 PD0 DESCRIPTION
--- --- ---------------
0 1 Internal Reference OFF and A/D Converter ON (When Power input from I2C)
1 1 Internal Reference ON and A/D Converter ON (When power src from external 12V pwr supply)
NOTE: I used both options but I am getting wrong values
3) DEVICE ID SELECTION
A1 A0
-----
0 1 -> device ID '01'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.