AD5593R : Troubles reading an I/O set as an ADC

Hello Community,

I come to you today as I have some trouble reading the ADC value on the AD5593R (I have already managed to get a digital output working).

I have to problems:

- The value of the ADC is varying a lot for a fixed voltage

- I'm trying to set the ADC range select to 2xVref but it seems that I can't get it to work 

I am using this schematic:

And this program on a Lopy4 (ESP32) using micropython 1.20 (it's inspired by the figure40 of the datasheet and the AD5593R driver in C): 

from machine import I2C
import pycom
import time
import sys

from ustruct import unpack
from array import array

address = 0x11 # 0x11 ADC

AD5593_ADC_SEQ_REG  = 0b00000010
AD5593_GP_CONTR_REF = 0b00000011
AD5593_ADC_PIN_CONF = 0b00000100
AD5593_GPIO_W_CONF  = 0b00001000
AD5593_GPIO_W_WRITE = 0b00001001
AD5593_ADC_READBACK = 0b01000000
AD5593_BLANK        = 0b00000000


# configure the I2C bus
i2c = I2C(0, pins=('P9','P10')) 
i2c = I2C(0, I2C.MASTER, baudrate=400000)

### ADC/DAC/GPIO Operations :

print("Configuring I/O 1 as an ADC input")
i2c.writeto(address, bytearray([AD5593_ADC_PIN_CONF,AD5593_BLANK,0b00000010]))
i2c.writeto(address, bytearray([AD5593_ADC_SEQ_REG,0b00000010,0b00000010]))
i2c.writeto(address, bytearray([AD5593_GP_CONTR_REF,AD5593_BLANK,0b00100000])) #2xVref for the ADC

print("General Purpose Control Register Readback :")
i2c.writeto(address, bytearray([0b01110011]))

print("Readback ADC")
i2c.writeto(address, AD5593_ADC_READBACK)

while True:
    print("Reading ADC I/O 1")
    data = i2c.readfrom(address,2)
    value = int(((data[0] & 0x0F) << 8 ) + data[1])

I have tried reading the General Purpose Control Register before and after writing it with the bit for the ADC range select and I can see that it has been changed (see the difference between the 2 first setup read): 

And when I use a potentiometer to have a stable 1.10V on the pin, here is what I get with 100 measurements (1 every second) : 

In this configuration 0 is 0V but 4096 is only just below 1.8V.

My first question is: is it normal that the ADC value is varying this much? Is there a way to get something more stable than that without adding averages in the software?

And then, can you tell us what are we doing wrong with the ADC Range select?

Thank you for reading,

Have a good day!


Here are some more screenshots of the communication with AD5593R: 

Initialization and first readings : 

Setting up the General Purpose Register : 

Reading a value : 

Parents Reply Children
No Data