2022-08-03 05:00:56 -04:00
|
|
|
|
|
|
|
[![Arduino CI](https://github.com/RobTillaart/AD5245/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
|
|
|
[![Arduino-lint](https://github.com/RobTillaart/AD5245/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/AD5245/actions/workflows/arduino-lint.yml)
|
|
|
|
[![JSON check](https://github.com/RobTillaart/AD5245/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/AD5245/actions/workflows/jsoncheck.yml)
|
2023-09-21 15:37:28 -04:00
|
|
|
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/AD5245.svg)](https://github.com/RobTillaart/AD5245/issues)
|
|
|
|
|
2022-08-03 05:00:56 -04:00
|
|
|
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/AD5245/blob/master/LICENSE)
|
|
|
|
[![GitHub release](https://img.shields.io/github/release/RobTillaart/AD5245.svg?maxAge=3600)](https://github.com/RobTillaart/AD5245/releases)
|
2023-09-21 15:37:28 -04:00
|
|
|
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/AD5245.svg)](https://registry.platformio.org/libraries/robtillaart/AD5245)
|
2022-08-03 05:00:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
# AD5245
|
|
|
|
|
2023-01-16 08:38:52 -05:00
|
|
|
Arduino library for I2C single channel digital potentiometer AD5245.
|
2022-08-03 05:00:56 -04:00
|
|
|
|
2023-09-21 15:37:28 -04:00
|
|
|
The library is experimental and not tested with hardware yet.
|
2022-08-03 05:00:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
2023-01-16 08:38:52 -05:00
|
|
|
The AD5245 is a single channel digital potentiometer which comes in
|
2023-09-21 15:37:28 -04:00
|
|
|
5 kΩ, 10 kΩ, 50 kΩ, 100 kΩ and can be set in 256 steps.
|
|
|
|
|
|
|
|
Indicative step size.
|
|
|
|
|
|
|
|
| value | step size |
|
|
|
|
|:--------:|:-----------:|
|
|
|
|
| 5 kΩ | 19.53 Ω |
|
|
|
|
| 10 kΩ | 39.06 Ω |
|
|
|
|
| 50 kΩ | 195.3 Ω |
|
|
|
|
| 100 kΩ | 390.6 Ω |
|
|
|
|
|
2022-08-03 05:00:56 -04:00
|
|
|
|
|
|
|
An important property of the device is that it defaults
|
2023-09-21 15:37:28 -04:00
|
|
|
to the mid-scale position at startup.
|
|
|
|
One can use **AD5245_MIDPOINT** == 128 to reset to the mid-scale position.
|
2022-08-03 05:00:56 -04:00
|
|
|
|
|
|
|
|
2023-09-21 15:37:28 -04:00
|
|
|
#### Related
|
2022-08-03 05:00:56 -04:00
|
|
|
|
|
|
|
This library is based upon the AD524X library, and triggered by this issue:
|
|
|
|
- https://github.com/RobTillaart/AD524X/issues/11
|
2023-01-16 08:38:52 -05:00
|
|
|
|
2023-09-21 15:37:28 -04:00
|
|
|
- - https://www.analog.com/en/products/ad5245.html
|
|
|
|
- https://github.com/RobTillaart/AD520X/
|
|
|
|
- https://github.com/RobTillaart/AD524X/
|
|
|
|
- https://github.com/RobTillaart/AD5245/ potentiometer
|
|
|
|
- https://github.com/RobTillaart/AD5246/ rheostat
|
|
|
|
|
2022-08-03 05:00:56 -04:00
|
|
|
|
|
|
|
## I2C address
|
|
|
|
|
|
|
|
The AD5245 has one address line to configure the I2C address.
|
|
|
|
|
2023-09-21 15:37:28 -04:00
|
|
|
| Address(dec)| Address(Hex) | AD0 |
|
|
|
|
|:-----------:|:------------:|:-----:|
|
|
|
|
| 44 | 0x2C | GND |
|
|
|
|
| 45 | 0x2D | +5V |
|
|
|
|
|
|
|
|
The maximum I2C speed is 400 KHz.
|
2022-08-03 05:00:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
## Interface
|
|
|
|
|
2023-09-21 15:37:28 -04:00
|
|
|
```cpp
|
|
|
|
#include AD5245.h"
|
|
|
|
```
|
|
|
|
|
2022-08-03 05:00:56 -04:00
|
|
|
The library has a number of functions which are all quite straightforward.
|
|
|
|
One can get / set the value of the potentiometer.
|
|
|
|
|
|
|
|
- **AD5245(uint8_t address, TwoWire \*wire = &Wire)** constructor
|
|
|
|
- **bool begin(uint8_t sda, uint8_t scl)** ESP32 a.o initializing of Wire.
|
|
|
|
- **bool begin()** for UNO.
|
|
|
|
- **bool isConnected()** See if address set in constructor is on the bus.
|
|
|
|
- **uint8_t reset()** sets potentiometer to midpoint = 128. (startup default)
|
|
|
|
- **uint8_t write(uint8_t value)** set to value 0 .. 255.
|
2023-01-16 08:38:52 -05:00
|
|
|
- **uint8_t read()** read value from cache.
|
|
|
|
- **uint8_t readDevice()** read value from device.
|
2022-08-03 05:00:56 -04:00
|
|
|
- **uint8_t shutDown()** check datasheet, not tested yet, use at own risk.
|
|
|
|
|
|
|
|
|
2022-10-25 15:41:23 -04:00
|
|
|
## Error codes
|
|
|
|
|
|
|
|
| define | value |
|
|
|
|
|:---------------|:-------:|
|
|
|
|
| AD5245_OK | 0 |
|
|
|
|
| AD5245_ERROR | 100 |
|
|
|
|
|
|
|
|
|
2022-08-03 05:00:56 -04:00
|
|
|
## Operation
|
|
|
|
|
|
|
|
The examples show the basic working of the functions.
|
|
|
|
|
|
|
|
|
|
|
|
## Future
|
|
|
|
|
|
|
|
- sync with AD520X library
|
|
|
|
- sync with AD524X library
|
2022-10-25 15:41:23 -04:00
|
|
|
- reset ==> midScaleReset() ? AD524X alike
|
2022-08-03 05:00:56 -04:00
|
|
|
|
2023-09-21 15:37:28 -04:00
|
|
|
|
|
|
|
## Support
|
|
|
|
|
|
|
|
If you appreciate my libraries, you can support the development and maintenance.
|
|
|
|
Improve the quality of the libraries by providing issues and Pull Requests, or
|
|
|
|
donate through PayPal or GitHub sponsors.
|
|
|
|
|
|
|
|
Thank you,
|
|
|
|
|