robtillaart / ad524x Goto Github PK
View Code? Open in Web Editor NEWArduino library for I2C digital potentiometer AD5241 AD5242
License: MIT License
Arduino library for I2C digital potentiometer AD5241 AD5242
License: MIT License
Hi Everyone,
I'm looking for guidance to know what exactly the reason that my circuit is not working as expected.
PFA schematics and code for your reference.
I'm very happy if anyone over GitHub can help me to solve this problem.
Thanks in advance,
Vaibhav Sugandhi
Hi, in title implicitly states AD5245 is supported, but did not see it written - is this likely to work? AD5245 is one of the top 5 digital potentiometers supported by jlcpcb assembly service currently
Hello! Is the data in the "I2C address" table correct? AD0 and AD1 do not need to be swapped? In the datasheet AD1 is the high bit of the address.
I'm attempting to use this library with a Teensy 4.0 and the potentiometer keeps reading the midpoint value. Simply put, I can't seem to get this to work. It seems to be a communication error but I've noticed the read commands don't actually read from the AD524X but simply return what you last set the value as.
I have finally gotten to the bottom of why the library doesn't work on an Adafruit Feather RP2040! The problem is here:
uint8_t AD524X::send(const uint8_t cmd, const uint8_t value)
{
Wire.beginTransmission(_address);
Wire.write(cmd);
Wire.write(value);
return Wire.endTransmission();
}
This code uses the default Wire channel rather then the one specified during initialization. Changing the code to this, fixed the problem:
uint8_t AD524X::send(const uint8_t cmd, const uint8_t value)
{
_wire->beginTransmission(_address);
_wire->write(cmd);
_wire->write(value);
return _wire->endTransmission();
}
Although I am not using it, I believe this:
uint8_t AD524X::readBackRegister()
{
Wire.beginTransmission(_address);
Wire.endTransmission();
Wire.requestFrom(_address, (uint8_t)1);
return Wire.read();
}
should be changed to this:
uint8_t AD524X::readBackRegister()
{
_wire->beginTransmission(_address);
_wire->endTransmission();
_wire->requestFrom(_address, (uint8_t)1);
return _wire->read();
}
Thanks again for all the hard work in producing this library.
hi
is it possible in some way (ex. a read instruction) to know the type of IC (if 41 or 42) and its pots type (10k, 100k or 1M)?
See PCF8574
just a wrapper would be OK if used in base class (or is this error prone ...?)
uint8_t AD524X::write(const uint8_t value)
{
write(0, value);
};
or if only in AD5421 it might be optimized.
uint8_t AD5241::write(const uint8_t value)
{
// apply the output lines
uint8_t cmd = AD524X_RDAC0 | _O1 | _O2;
_lastValue[0] = value;
return send(cmd, value);
}
Thanks for creating a great library!
I am trying to use the library on an Adafruit RP2040 Feather.
There are two I2C channels on this board. I initialize the library for the second channel (Wire1) as that is the one the AD5242 is connected to:
AD5242 AD01(0x2C, &Wire1);
The setup code indicates that the AD5242 is found. More specifically, this code:
b = AD01.begin();
Serial.println(b ? "Begin: true" : "Begin: false");
Serial.println(AD01.isConnected());
produces this output:
Begin: true
1
However, when I try to write to the AD5242 there are errors:
int a = AD01.write(0, 100);
int b = AD01.write(1, 100 );
char buff[256];
sprintf(buff,"Write 1: %d\tWrite 2: %d\n", a, b);
Serial.println(buff);
The output is:
Write 1: 4 Write 2: 4
From the Arduino documentation for Wire, I believe that a return value of 4 means "other error"
I know that the hardware works properly as everything works correctly when I used an ESP32 instead of the RP2040. My board is designed as a feather wing so that I can simply swap feather processors. (For the ESP32 I initialize with AD5242 AD01(0x2C); )
Any suggestions?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.