Coder Social home page Coder Social logo

ads7828's People

Contributors

ryker1990 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ads7828's Issues

[Particle Photon] Reading wrong voltage ADC values from ADS 7828 through I2C

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.

20200628_183626
20200628_183641
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'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.