Author Topic: Need help with programming I2C ADC using arduino  (Read 1111 times)

0 Members and 1 Guest are viewing this topic.

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Need help with programming I2C ADC using arduino
« on: December 07, 2018, 09:30:43 pm »
Hello
I made a board using an atmega328p-au (arduino nano) , an ADS1219 and a voltage reference.
I'm not very good with programming, especially for I2C communication. Can somebody help me get the circuit to work?
 

Offline archnemesis

  • Contributor
  • Posts: 19
  • Country: us
Re: Need help with programming I2C ADC using arduino
« Reply #1 on: December 07, 2018, 10:58:17 pm »
Try Google.

I hope that answer was as frustrating for you as reading your question was for me.
 

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: Need help with programming I2C ADC using arduino
« Reply #2 on: December 07, 2018, 11:00:58 pm »
I tried googling , searching github and even the arduino froum  :-DD
 

Offline archnemesis

  • Contributor
  • Posts: 19
  • Country: us
Re: Need help with programming I2C ADC using arduino
« Reply #3 on: December 07, 2018, 11:03:36 pm »
But you offer no indication of anything you've tried, what you're even having issues with. Did you write any code?
 

Offline OM222OTopic starter

  • Frequent Contributor
  • **
  • Posts: 768
  • Country: gb
Re: Need help with programming I2C ADC using arduino
« Reply #4 on: December 07, 2018, 11:22:00 pm »
I found some codes which are for the ADS1115 (a very similar product, 16 bit I2C ADC) and tried modifying it to work with the 24 bit ADS1219 but I had no luch tbh. My main issue is using the register maps given in the data sheet and writing / reading data to / from them.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9903
  • Country: us
Re: Need help with programming I2C ADC using arduino
« Reply #5 on: December 07, 2018, 11:28:19 pm »
Maybe start here:

https://www.arduino.cc/en/Reference/Wire

Or here:

https://playground.arduino.cc/Main/SoftwareI2CLibrary

Or just Google for 'arduino i2c library' = there will be about 1,460,000 hits.

Or, Google for 'arduino ads1219'  There won't be anything directly on point but there is a hint that code exists for a similar device.

I2C is my least favorite protocol.  It is a real problem child to bring up unless you have the tools - like a logic analyzer or scope with  I2C decoding.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9903
  • Country: us
Re: Need help with programming I2C ADC using arduino
« Reply #6 on: December 07, 2018, 11:57:37 pm »
The biggest mistake people make with I2C is dealing with the address.  If both A0 and A1 are grounded, the address of the device is 40h as a 7 bit quantity.  The value is shifted left one spot to make the address actually sent over the wire as 80h or 81h where the low order bit is the R/W' value.  In effect, you write the commands to 80h and read the status from 81h.  Those are the only addresses and there is only one register in each direction.  See page 29 here:

http://www.ti.com/lit/ds/symlink/ads1219.pdf

Some libraries will handle the shift internally and mask in the R/W' bit so you tell them to use address 40h and the code knows what to do with the R/W' bit.  Other libraries want you to shift the address (to 80h) and still allow them to mask in the R/W' bit.  Getting this part right is the main difficulty with I2C.

For a first approximation, I would write code to read the status register and look for some kind of ID code in bits 0..6.  I'm hoping they didn't leave the field 0x00 or 0xff.  If I could get a consistent ID, I would know I'm on the right track.  Just print the value to the terminal.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf