AD7789 24bit ADC data register read issue (Arduino)

Hello,

I'm trying to use the AD7789 24 bit ADC with an Arduino, and I'm having an issue that every so often the AD7789 returns 0xFFFFFF when it shouldn't. This is for my EE senior design project at georgia tech, we're making a device that measures the IV curve of a solar panel.

I wrote firmware that outputs the function y = -0.0001*exp(5*x) + 4 (y is output from AD5300 8 bit DAC, we plan on using a 24 bit DAC, but haven't received the samples yet; ADI hurry up with your samples!! ) as a way to test my driver. It measures y with the AD7789 and built in 10bit ADC on the Arduino. I plotted this data in MATLAB, and as you can see it has issues. Every so often the AD7789 decides that it will return 0xFFFFFF or something close to that, which corresponds to 5V, which is why you see the spikes in the plot below.

I believe this is caused by trying to read the data register on the AD7789 before it is ready to be read, according to the datasheet, it says that if it’s not ready, than the DOUT pin will remain HIGH, and once it’s ready it will go LOW. Also I want to point out that I'm reading data in continuous read mode.

This is an excerpt from the AD7789 datasheet (pg. 16) that explains what I just stated about the DOUT pin:

When DOUT/RDY goes low to indicate the end of a conversion, sufficient SCLK cycles must be applied to the ADC and the data conversion is placed on the DOUT/RDY line. When the conversion is read, DOUT/RDY returns high until the next conversion is available.

Using that logic, I tried adding a code statement in the AD7789 read_data() function that loops and does nothing until the DOUT pin is LOW, but the code loops forever ( I also tried using the read_data() as an ISR that triggered on a falling DOUT, but I had the same effect), which doesn’t make sense to me, because it should break the loop once the data is ready to be read. The plots below do not include that loop.

If you have any insight to what the problem may be, or have any other code it would be greatly appreciated! I have also attached my code that I used to get the data for the plot below (plots are all the same, except the bottom two are zoomed in versions of the top).

Thanks and Regards,

Eriko Gleason

adc.ino.zip
  • Hello,

    I'm not an expert, but I got the sameroblem with an AD7730.

    For me the problem had 2 sources:

    - ADC isnot alone on the SPI, an EEPROM is on the same bus (I'm not responsable for this design ^^)

    When the EEPROM was in a write operation, it was driveing the DOUT pin to LOW.

    So, do you have another part on the ADC bus?

    - Second is when you want to read the data and in the same time a new data is written into the Data register.

    In this case, the DOUT pin stays HIGH and I was reading always 0XFFFFFF like you.

    But usising an interruption to read the data is a good solution (the one I'm using) and this problem should not comes.

    - Another way to checkis on the signal line itself. May be someone is driving the line to 5V.

    You say you measure the signal with another ADC (10bits). Are you sure that it doesn't disturb the AD7789?

  • 0
    •  Analog Employees 
    on Oct 17, 2012 4:47 AM

    Hi, Eriko.

    Can you provide me a scope shot of the CS line? Based on your code at start_cont_read, CS is enabled after doing the following: reset, taking the CS to low and writing 0x3C.

    void start_cont_read(void)

    {

    reset_adc();

    digitalWrite(CS2, LOW);

    SPI.transfer(0x3C);

    digitalWrite(CS2, HIGH); =====> CS line is enabled

    }

    You also brought the CS line to high in reading your data.

    void read_data(void)

    {

    long b, adc;

    digitalWrite(CS2, LOW);

    b = SPI.transfer(0);

    adc = b<<8;

    b = SPI.transfer(0);

    adc |= b;

    adc <<= 8;

    b = SPI.transfer(0);

    adc |= b;

    digitalWrite(CS2, HIGH); =====> CS line is enabled

    vin = 5.0*(adc/8388608.0 - 1.0);

    }

    You only need to tell the device that you are going to do a continuous-read mode by writing 0x3C. Taking the CS high after does not make sense. Just wait until the DRDY line goes low after writing 0x3C to know that data is available while maintaining the CS low.

    In continuous read mode, it is essential that DRDY goes low before a read operation. When DRDY goes low, apply the 24 SCLK pulses. The data remains in the data register until the next conversion is available. As soon as the next conversion is available, the data register is updated and the SPI interface is reset. Therefore, correct timing is essential in this mode.

    Is the SPI bus shared with other devices? Do you perform the data read on the AD7789 at the same time as you read using the 10-bit ADC?

    Regards,

    Johnny

  • Thank you all for the quick response! Yes the SPI line is shared with a 8 bit DAC (AD5300), but the DOUT line is only connected to the AD7789 (DAC only has DIN). The 10 bit ADC I was talking about is one that is built into the Arduino, so it doesn't connect to SPI. The only reason I pulled CS HIGH again, was because it shares DIN and SCLK with the DAC, and I didn't want it to respond when I communicate with DAC. I will take some oscilloscope captures soon and post, my other team member has all the equipment at the moment.

    " Just wait until the DRDY line goes low after writing 0x3C to know that data is available while maintaining the CS low"

    I will also try this as soon as I get the stuff back , I never tried waiting with CS low.

    Thanks Again!

    Eriko

  • 0
    •  Analog Employees 
    on Aug 2, 2018 4:42 PM
    This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.

    Thank you,
    EZ Admin