Pages: [1]   Go Down
Author Topic: library for AD5242 and AD5241 digital potentiometer  (Read 564 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13739
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

TODO:
- 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.
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13739
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

updated to version 0.1.01   
main points:
+ added  getO1()  , getO2()  => also in test sketch
+ added zeroAll() - no test sketch yet
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: