Post Go back to editing

AD5252 I2C Issues

Hi there,

I was hoping to get some help with issues I am experiencing with the I2C protocol for the AD5252 chip.

I am trying to communicate with the chip using the MCP2221 chip.

For reference:

AD5252--> 50K potentiometer

AD1 is set low (0) and AD0 is set high (1)

Defualt resistance WA: 24.7K

Defualt resistance WB: 24.7K

Defualt resistance AB: 49.7K

MCP221 i2C write: 0x92

MCP2221 i2C read: 0x93

--------------------------------------------------------------------------------------------

I have setup the slave address as 0x5A--> 01011 (base address) + 01 (AD1, AD0) + 0 (W/R: write--> 01011010

I have seen other scripts that have used 0x2C (0101101) as the slave address, but it does not account for the read/write bit, granted they were using Arduino ido whereas I am using Python, so I am not sure if that would account for that discrepancy ( I am not very familiar with Arduino code structure).

For the instruction byte, I am assuming I need to write to the RDAC register in this case 00000001--> 0x01 ( CMD=0, EE=0)

I also thought to write/store the data to the EEMEM register: 00100001 --> 0x21 (CMD=0, EE=1)

Based off the formula for calculating R(WB)- based off of a value between 0-255, the user can choose the resistance (0-50K ohms).

def set_resistance(self, value: int = 255):

resWB = (value) / 256 * 50000 + 75 #simply included for expected value
bytes_out = int(value)

self.i2cWrite(0x5A, [0x01, data])
self.i2cWrite(0x5A, [0x21, data])

return (resWB)

I have tried different combinations as well trying 0x2C as a slave address due to a lack of success with 0x5A

The goal is to be able to digitally control the resistance from 0-50K. Any help would be appreciated

Best regards,

Tayeb