Missing Low Byte in ADS1113 Read - Page 1
Forum section: electronics / projects

author: fsonnichsen
author_rank: Newbie
timestamp: April 16, 2022, 01:32:11 pm
content: I am programming an ADS1113. This is the simplest of the ADD111x series with only 1 channel and without a PGA, comparator etc. It is a 16 bit ADC requiring two one-byte reads to retrieve the output.The device is configured with 2 bytes. Most of these bits are zero for this series . I have tried a few combinations of single and continuous read.I am applying 0->3.3V to the input channel. I am able to display voltage from the high order byte . However I always get 0x00 for the low order.I stripped down a very simple Arduino code to test and I attach it here.Also the datasheet is at:https://www.ti.com/lit/ds/symlink/ads1113.pdf?ts=1650106901012Any ideas appreciatedthanksFritz

author: mikerj
author_rank: Super Contributor
timestamp: April 16, 2022, 03:52:12 pm
content: Couple of things I can see:1) You are addressing the ADC to write data to it with Wire.beginTransmission() immediately prior to reading the data back. This is not correct, the Wire.requestFrom() function addresses the slave device for reading, so no other slave addressing is required. I suspect this is the primary cause of your problems.Code:///////////////////////// READ ADC /////////////////////////////////////////Wire.beginTransmission(addr); //address ADC <-----INCORRECT, REMOVE THIS!rc = Wire.requestFrom((int)addr, (int)2); // request 2 bytes2) You have configured the ADC to run at just 8 samples per second (config register = 0x8100) but then you are trying to read a result back immediately after starting a conversion which is doomed to failure. You should be polling the OS bit in the config register to wait until a conversion has completed.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: April 18, 2022, 08:46:12 am
content: First step is to verify your I2C levels and rise time with an oscilloscope.I2C is always a bit finicky because of the required passive pullup resistors.If you do not have an oscilloscope, then you can try to add stronger pullups (2k2 is a possibility) and/ or reduce the clock rate. Try a clock rate of 1kHz.Next step is to get a logic analyser.The "saleaeaaea" clones cost less then EUR 10 (or a bit more if sourced from adafruit) and they work pretty well with the FOSS Sigrok / Pulseview software.They are also quite small boxes and easy to integrate into a breadboard.I make more use of such a cheap LA then of my Rigol Oscilloscope.When trying to setup some microcontroller project that controls external IC's, the first question that pops up if it does not work is if the fault is in software or in hardware, and sniffing the uC output with such an LA lets you verify quickly if your software is behaving as you think it should behave.Sigrok / Pulseview supports 100+ different software decoders which also add a lot of meaning to the raw sniffed data.

author: fsonnichsen
author_rank: Newbie
timestamp: April 18, 2022, 11:39:30 am
content: I appreciated your comments and regardless of my outcome below they are good points.At any rate I got back in the lab and after some troubleshooting found that the wrong amplifier resistor was being used -- this amp feeds the ADC hence was producing a very small voltage. Making excuses, I am, (as I would think you all are) a victim of the recent IC shortages and I am cobbling my older designs together to accommodate chips that I can still obtain- I had forgot to make some adjustments here.I managed to find some ADS1119 in my parts boxes and I think these will supplant the ADS1113 but has 4 channels which I need.Thanks again for replying-Sorry for any confusionFritz