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,