From 0ced2e51b759c146184861d532b75c20d530817d Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Fri, 13 Oct 2023 13:31:03 +0200 Subject: [PATCH] 0.1.1 AD5263 --- libraries/AD5263/AD5263.cpp | 47 +----------- libraries/AD5263/AD5263.h | 28 +------ libraries/AD5263/CHANGELOG.md | 7 ++ libraries/AD5263/README.md | 65 ++++++++++++++--- .../AD5263_I2C_performance.ino | 73 +++++++++++++++++++ libraries/AD5263/klein groen bordje.txt | 0 libraries/AD5263/library.json | 4 +- libraries/AD5263/library.properties | 6 +- 8 files changed, 145 insertions(+), 85 deletions(-) create mode 100644 libraries/AD5263/examples/AD5263_I2C_performance/AD5263_I2C_performance.ino delete mode 100644 libraries/AD5263/klein groen bordje.txt diff --git a/libraries/AD5263/AD5263.cpp b/libraries/AD5263/AD5263.cpp index d0f370b9..2a30edfa 100644 --- a/libraries/AD5263/AD5263.cpp +++ b/libraries/AD5263/AD5263.cpp @@ -1,7 +1,7 @@ // // FILE: AD5263.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 +// VERSION: 0.1.1 // PURPOSE: Arduino library for I2C digital potentiometer AD5263 and compatibles. // DATE: 2023-10-09 // URL: https://github.com/RobTillaart/AD5263 @@ -193,55 +193,14 @@ uint8_t AD5263::send(const uint8_t cmd, const uint8_t value) } + ////////////////////////////////////////////////////////////// // // DERIVED CLASSES // -/* -AD5280::AD5280(const uint8_t address, TwoWire *wire) : AD5263(address, wire) -{ - _pmCount = 1; -} +// None known so far. -uint8_t AD5280::write(const uint8_t value) -{ - // apply the output lines - uint8_t cmd = AD5263_RDAC0 | _O1 | _O2; - _lastValue[0] = value; - return send(cmd, value); -} - - -uint8_t AD5280::write(const uint8_t value, const uint8_t O1, const uint8_t O2) -{ - _O1 = (O1 == LOW) ? 0 : AD5263_O1_HIGH; - _O2 = (O2 == LOW) ? 0 : AD5263_O2_HIGH; - - // apply the output lines - uint8_t cmd = AD5263_RDAC0 | _O1 | _O2; - _lastValue[0] = value; - return send(cmd, value); -} - - -uint8_t AD5280::write(const uint8_t rdac, const uint8_t value) -{ - return AD5263::write(rdac, value); -} - - -uint8_t AD5280::write(const uint8_t rdac, const uint8_t value, const uint8_t O1, const uint8_t O2) -{ - return AD5263::write(rdac, value, O1, O2); -} - - -AD5242::AD5282(const uint8_t address, TwoWire *wire) : AD5263(address, wire) -{ - _pmCount = 2; -} -*/ // -- END OF FILE -- diff --git a/libraries/AD5263/AD5263.h b/libraries/AD5263/AD5263.h index 09172cdd..0a5447d2 100644 --- a/libraries/AD5263/AD5263.h +++ b/libraries/AD5263/AD5263.h @@ -2,8 +2,8 @@ // // FILE: AD5263.h // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 -// PURPOSE: +// VERSION: 0.1.1 +// PURPOSE: Arduino library for I2C digital potentiometer AD5263 and compatibles. // DATE: 2023-10-09 // URL: https://github.com/RobTillaart/AD5263 // based upon AD524X interface. @@ -13,7 +13,7 @@ #include "Wire.h" -#define AD5263_LIB_VERSION (F("0.1.0")) +#define AD5263_LIB_VERSION (F("0.1.1")) #define AD5263_OK 0 @@ -76,28 +76,8 @@ protected: // // DERIVED CLASSES // -/* -// ONE CHANNEL -class AD5280 : public AD5263 -{ -public: - AD5280(const uint8_t address, TwoWire *wire = &Wire); +// None known so far. - uint8_t write(const uint8_t value); - uint8_t write(const uint8_t value, const uint8_t O1, const uint8_t O2); - - uint8_t write(const uint8_t rdac, const uint8_t value); - uint8_t write(const uint8_t rdac, const uint8_t value, const uint8_t O1, const uint8_t O2); -}; - - -// TWO CHANNEL -class AD5282 : public AD5263 -{ -public: - AD5262(const uint8_t address, TwoWire *wire = &Wire); -}; -*/ // -- END OF FILE -- diff --git a/libraries/AD5263/CHANGELOG.md b/libraries/AD5263/CHANGELOG.md index bfa6eb44..d6ec5369 100644 --- a/libraries/AD5263/CHANGELOG.md +++ b/libraries/AD5263/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.1.1] - 2023-10-11 +- update readme.md +- investigated compatibility AD5280/82 (not) => clean up code +- fix library.json +- add AD5263_I2C_performance.ino + + ## [0.1.0] - 2023-10-09 - initial version (based upon AD524X library) diff --git a/libraries/AD5263/README.md b/libraries/AD5263/README.md index 8852d490..43d629ba 100644 --- a/libraries/AD5263/README.md +++ b/libraries/AD5263/README.md @@ -21,13 +21,11 @@ Arduino library for I2C digital potentiometer AD5263 and compatibles. The AD5263 is a digital potentiometer with 4 channels. This digital potentiometers come in 20, 50 and 200 kΩ and can be set in 256 steps. +This library only implements the I2C interface (See future for SPI). -This library only implements the I2C interface. - -An important property of the device is that it defaults +An important property of the AD5263 device is that it defaults to their mid position at startup. - -The library also defines **AD5263_MIDPOINT** == 128. +The library defines **AD5263_MIDPOINT** == 128 (as per datasheet). To be used to set to defined mid-point. (Library is based on datasheet Rev.F ) @@ -45,8 +43,44 @@ This library is related to #### Compatibles -The AD5280 and AD5282 are one and two channel devices that might be compatible. -Not tested yet. See future. +None known so far. + + +## Hardware connection AD5263 + +Please read datasheet for all details! + +| Pin | Name | Description (short) | +|:----:|:----------|:---------------------------------------| +| 1 | B1 | Resistor Terminal B1. | +| 2 | A1 | Resistor Terminal A1 (ADDR = 00). | +| 3 | W1 | Wiper Terminal W1. | +| 4 | B3 | Resistor Terminal B3. | +| 5 | A3 | Resistor Terminal A3. | +| 6 | W3 | Wiper Terminal W3 (ADDR = 10). | +| 7 | VDD | Positive Power Supply | +| 8 | GND | Ground. | +| 9 | DIS | SPI/I2C Select. SPI = 0, I2C = 1 | +| 10 | VLOGIC | 2.7 - 5.5V Logic Supply Voltage. | +| 11 | SDI/SDA | (SPI data in) I2C SDA | +| 12 | CLK/SCL | Serial Clock I2C SCL | +| 13 | CS/AD0 | (SPI Chip Select). I2C address bit 0 | +| 14 | RES/AD1 | (SPI RESET) I2C Address bit 1 | +| 15 | SHDN | Shutdown. Tie to +5 V if not used. | +| 16 | SDO/O1 | (SPI data out) I2C Output O1 | +| 17 | NC/O2 | (SPI No Connect) I2C Output O2 | +| 18 | VSS | Negative Power Supply. | +| 19 | W4 | Wiper Terminal W4 (ADDR = 11). | +| 20 | A4 | Resistor Terminal A4. | +| 21 | B4 | Resistor Terminal B4. | +| 22 | W2 | Wiper Terminal W2 (ADDR = 01). | +| 23 | A2 | Resistor Terminal A2. | +| 24 | B2 | Resistor Terminal B2. | + + +VLOGIC: +The logic supply voltage should always be less than or equal to VDD. +In addition, logic levels must be limited to the logic supply voltage regardless of VDD. ## I2C @@ -67,9 +101,16 @@ Note the AD5263 uses the same range as the AD524X devices. #### Performance -- TODO -- table -- test sketch +- TODO: Test with UNO / ESP32 / RP2040 / ... + +| Speed | UNO (us) | ESP32 (us) | +|:--------:|:----------:|:------------:| +| 100000 | | | +| 200000 | | | +| 400000 | | | +| 600000 | | | +| 800000 | | | +| 1000000 | | | ## Interface @@ -129,7 +170,7 @@ rdac should be 0..3. #### Must - update documentation. -- get hardware (breakout or so). +- get hardware (breakout). - test with hardware. @@ -138,10 +179,10 @@ rdac should be 0..3. #### Could -- investigate AD5280/82 compatibility. - improve error handling. - sync with AD520X / AD524X library - optimize footprint **write()** and **midScaleReset()** +- investigate SPI interface (performance better) #### Wont diff --git a/libraries/AD5263/examples/AD5263_I2C_performance/AD5263_I2C_performance.ino b/libraries/AD5263/examples/AD5263_I2C_performance/AD5263_I2C_performance.ino new file mode 100644 index 00000000..289ec320 --- /dev/null +++ b/libraries/AD5263/examples/AD5263_I2C_performance/AD5263_I2C_performance.ino @@ -0,0 +1,73 @@ +// +// FILE: AD5263_I2C_performance.ino +// AUTHOR: Rob Tillaart +// PURPOSE: AD5263 demo program +// URL: https://github.com/RobTillaart/AD5263 + + +#include "AD5263.h" + +AD5263 AD01(0x2C); // AD0 & AD1 == GND + +uint32_t start, stop; +volatile uint8_t x = 0; + + +void setup() +{ + Serial.begin(115200); + Serial.println(); + Serial.println(__FILE__); + Serial.println(); + Serial.println(AD5263_LIB_VERSION); + + Wire.begin(); + + Serial.println("\nWRITE"); + delay(10); + for (uint32_t speed = 100000; speed <= 800000; speed += 100000) + { + Wire.setClock(speed); + bool b = AD01.begin(); + if (b == true) + { + start = micros(); + AD01.write(0, 0x55); + stop = micros(); + Serial.print("| "); + Serial.print(speed); + Serial.print(" | "); + Serial.println(stop - start); + } + delay(100); + } + + + Serial.println("\nREAD"); + delay(10); + for (uint32_t speed = 100000; speed <= 800000; speed += 100000) + { + Wire.setClock(speed); + bool b = AD01.begin(); + if (b == true) + { + start = micros(); + x = AD01.read(0); + stop = micros(); + Serial.print("| "); + Serial.print(speed); + Serial.print(" | "); + Serial.println(stop - start); + } + delay(100); + } +} + + +void loop() +{ +} + + +// -- END OF FILE -- + diff --git a/libraries/AD5263/klein groen bordje.txt b/libraries/AD5263/klein groen bordje.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/libraries/AD5263/library.json b/libraries/AD5263/library.json index 439c264e..0d9ddb14 100644 --- a/libraries/AD5263/library.json +++ b/libraries/AD5263/library.json @@ -1,6 +1,6 @@ { "name": "AD5263", - "keywords": "I2C,digital,PotentioMeter, AD5241, AD5242", + "keywords": "I2C,digital,PotentioMeter", "description": "Library to control digital potentiometer AD5263 and compatibles.", "authors": [ @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/AD5263" }, - "version": "0.1.0", + "version": "0.1.1", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/libraries/AD5263/library.properties b/libraries/AD5263/library.properties index 263eb0d9..fdd0644f 100644 --- a/libraries/AD5263/library.properties +++ b/libraries/AD5263/library.properties @@ -1,9 +1,9 @@ name=AD5263 -version=0.1.0 +version=0.1.1 author=Rob Tillaart maintainer=Rob Tillaart -sentence=Arduino Library for AD5263 -paragraph=Library to control digital potentiometer AD5263 and compatibles. +sentence=Library to control digital potentiometer AD5263 and compatibles. +paragraph= category=Signal Input/Output url=https://github.com/RobTillaart/AD5263 architectures=*