I needed to work with a digital potentiometer and I choose the AD5242 (I2C). The reasons are simple: One AD5242 has two potmeters (10K in 256 steps) on board and because the AD has two free address lines, I can have 8 digital pot meters over I2C . Valid addresses are 0x2C..0x2F.
datasheet: - http://www.analog.com/static/imported-files/data_sheets/AD5241_5242.pdf
On the internet there were samples how to control the AD5241 (single pot) but I found no code for the AD5242 and no support for the additional output lines. So I made a library that allows one to set the value of the two potmeters, read them back AND to control the 2 output lines.
The first version of the lib can be found here - https://github.com/RobTillaart/Arduino/tree/master/libraries/AD524X
- and it includes a number of example sketches. The lib seems to work well and I tested the devices both at 100KHz and 400KHz without problems.
- read about the meaning of the shutdown bit
- implement a read function for the 2 output lines (prio; completeness)
- optimize if possible.
- refactor the code
The lib can also be used for the AD5241 but of course only rdac 0 can be addressed meaningful.
Comments, remarks etc are as always welcome.