mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
0.1.2 AD5263
This commit is contained in:
parent
540040056c
commit
0bee58b634
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: AD5263.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.1
|
||||
// VERSION: 0.1.2
|
||||
// PURPOSE: Arduino library for I2C digital potentiometer AD5263 and compatibles.
|
||||
// DATE: 2023-10-09
|
||||
// URL: https://github.com/RobTillaart/AD5263
|
||||
@ -52,21 +52,23 @@ bool AD5263::isConnected()
|
||||
|
||||
uint8_t AD5263::reset()
|
||||
{
|
||||
for (int i = 1; i < _pmCount; i++)
|
||||
{
|
||||
write(i, AD5263_MIDPOINT);
|
||||
}
|
||||
return write(0, AD5263_MIDPOINT, LOW, LOW);
|
||||
return setAll(AD5263_MIDPOINT);
|
||||
}
|
||||
|
||||
|
||||
uint8_t AD5263::zeroAll()
|
||||
{
|
||||
return setAll(0);
|
||||
}
|
||||
|
||||
|
||||
uint8_t AD5263::setAll(const uint8_t value)
|
||||
{
|
||||
for (int i = 1; i < _pmCount; i++)
|
||||
{
|
||||
write(i, 0);
|
||||
write(i, value);
|
||||
}
|
||||
return write(0, 0, LOW, LOW);
|
||||
return write(0, value, LOW, LOW);
|
||||
}
|
||||
|
||||
|
||||
@ -151,13 +153,14 @@ uint8_t AD5263::readBackRegister()
|
||||
|
||||
uint8_t AD5263::midScaleReset(const uint8_t rdac)
|
||||
{
|
||||
if (rdac >= _pmCount) return AD5263_ERROR;
|
||||
if (rdac >= _pmCount) return AD5263_ERROR;
|
||||
|
||||
uint8_t cmd = AD5263_RESET;
|
||||
if (rdac == 0) cmd |= AD5263_RDAC0;
|
||||
if (rdac == 1) cmd |= AD5263_RDAC1;
|
||||
if (rdac == 2) cmd |= AD5263_RDAC2;
|
||||
if (rdac == 3) cmd |= AD5263_RDAC3;
|
||||
uint8_t cmd = AD5263_RDAC0;
|
||||
if (rdac == 1) cmd = AD5263_RDAC1;
|
||||
if (rdac == 2) cmd = AD5263_RDAC2;
|
||||
if (rdac == 3) cmd = AD5263_RDAC3;
|
||||
|
||||
cmd |= AD5263_RESET;
|
||||
|
||||
// apply the output lines
|
||||
cmd = cmd | _O1 | _O2;
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: AD5263.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.1
|
||||
// VERSION: 0.1.2
|
||||
// PURPOSE: Arduino library for I2C digital potentiometer AD5263 and compatibles.
|
||||
// DATE: 2023-10-09
|
||||
// URL: https://github.com/RobTillaart/AD5263
|
||||
@ -13,7 +13,7 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define AD5263_LIB_VERSION (F("0.1.1"))
|
||||
#define AD5263_LIB_VERSION (F("0.1.2"))
|
||||
|
||||
|
||||
#define AD5263_OK 0
|
||||
@ -34,6 +34,8 @@ public:
|
||||
// RESET
|
||||
uint8_t reset(); // reset all channels to AD5263_MIDPOINT and O1/O2 to LOW
|
||||
uint8_t zeroAll(); // set all channels to 0 and O1/O2 to LOW
|
||||
uint8_t setAll(const uint8_t value); // set all channels to value and O1/O2 to LOW
|
||||
|
||||
|
||||
// READ WRITE
|
||||
uint8_t read(const uint8_t rdac);
|
||||
|
@ -6,13 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.1.2] - 2023-11-13
|
||||
- update readme.md
|
||||
- add **setAll(value)**
|
||||
- minor edits
|
||||
|
||||
|
||||
## [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)
|
||||
|
||||
|
@ -16,8 +16,6 @@ Arduino library for I2C digital potentiometer AD5263 and compatibles.
|
||||
|
||||
## Description
|
||||
|
||||
**Experimental** needs testing with hardware.
|
||||
|
||||
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.
|
||||
@ -43,43 +41,44 @@ This library is related to
|
||||
|
||||
#### Compatibles
|
||||
|
||||
None known so far.
|
||||
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. |
|
||||
| Pin | Name | Description (short) | notes |
|
||||
|:-----:|:----------|:---------------------------------------|:--------|
|
||||
| 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 | connect to VDD |
|
||||
| 10 | VLOGIC | 2.7 - 5.5V Logic Supply Voltage. | connect to VDD |
|
||||
| 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 | see Address below |
|
||||
| 14 | RES/AD1 | (SPI RESET) I2C Address bit 1 | see Address below |
|
||||
| 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.
|
||||
#### 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.
|
||||
|
||||
|
||||
@ -101,16 +100,25 @@ Note the AD5263 uses the same range as the AD524X devices.
|
||||
|
||||
#### Performance
|
||||
|
||||
- TODO: Test with UNO / ESP32 / RP2040 / ...
|
||||
Timing in microseconds, writing a new value to device.
|
||||
|
||||
| Speed | UNO (us) | ESP32 (us) |
|
||||
|:--------:|:----------:|:------------:|
|
||||
| 100000 | | |
|
||||
| 200000 | | |
|
||||
| 400000 | | |
|
||||
| 600000 | | |
|
||||
| 800000 | | |
|
||||
| 1000000 | | |
|
||||
| Speed | UNO | ESP32 | RP2040 | notes |
|
||||
|:--------:|:-----:|:-------:|:--------:|:--------|
|
||||
| 100000 | 340 | | |
|
||||
| 150000 | 240 | | |
|
||||
| 200000 | 196 | | |
|
||||
| 250000 | 168 | | |
|
||||
| 300000 | 148 | | |
|
||||
| 350000 | 140 | | |
|
||||
| 400000 | 136 | | | max advised speed |
|
||||
| 450000 | 128 | | |
|
||||
| 500000 | 124 | | | max working speed |
|
||||
|
||||
|
||||
The Arduino UNO failed to communicate above 500K, therefor
|
||||
the max speed advised is 400K
|
||||
|
||||
**TODO** Test with ESP32 / RP2040 / ... to fill
|
||||
|
||||
|
||||
## Interface
|
||||
@ -147,8 +155,9 @@ rdac should be 0..3.
|
||||
#### Misc
|
||||
|
||||
- **uint8_t zeroAll()** sets potentiometer's to 0 and I/O to LOW.
|
||||
- **uint8_t reset()** sets potentiometer's to midpoint == 127 and I/O to LOW. (startup default)
|
||||
- **uint8_t midScaleReset(uint8_t rdac)** resets one potentiometer to midpoint == 127.
|
||||
- **uint8_t reset()** sets potentiometer's to midpoint == 128 and O1 and O2 to LOW. (startup default)
|
||||
- **uint8_t setAll(uint8_t value)** sets potentiometer's to value and O1 and O2 to LOW.
|
||||
- **uint8_t midScaleReset(uint8_t rdac)** resets one potentiometer to midpoint == 128.
|
||||
- **uint8_t readBackRegister()** read register back, for debugging.
|
||||
|
||||
|
||||
@ -170,9 +179,6 @@ rdac should be 0..3.
|
||||
#### Must
|
||||
|
||||
- update documentation.
|
||||
- get hardware (breakout).
|
||||
- test with hardware.
|
||||
|
||||
|
||||
#### Should
|
||||
|
||||
@ -181,7 +187,9 @@ rdac should be 0..3.
|
||||
|
||||
- improve error handling.
|
||||
- sync with AD520X / AD524X library
|
||||
- optimize footprint **write()** and **midScaleReset()**
|
||||
- optimize footprint **write()** versions.
|
||||
- optimize **midScaleReset()** = ```return write(rdac, AD5263_MIDPOINT);```
|
||||
- is this the same?
|
||||
- investigate SPI interface (performance better)
|
||||
|
||||
|
||||
|
@ -18,14 +18,15 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println();
|
||||
Serial.print("AD5263_LIB_VERSION: ");
|
||||
Serial.println(AD5263_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Wire.begin();
|
||||
|
||||
Serial.println("\nWRITE");
|
||||
delay(10);
|
||||
for (uint32_t speed = 100000; speed <= 800000; speed += 100000)
|
||||
for (uint32_t speed = 100000; speed <= 600000; speed += 50000)
|
||||
{
|
||||
Wire.setClock(speed);
|
||||
bool b = AD01.begin();
|
||||
@ -45,7 +46,7 @@ void setup()
|
||||
|
||||
Serial.println("\nREAD");
|
||||
delay(10);
|
||||
for (uint32_t speed = 100000; speed <= 800000; speed += 100000)
|
||||
for (uint32_t speed = 100000; speed <= 600000; speed += 50000)
|
||||
{
|
||||
Wire.setClock(speed);
|
||||
bool b = AD01.begin();
|
||||
@ -70,4 +71,3 @@ void loop()
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -15,8 +15,9 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println();
|
||||
Serial.print("AD5263_LIB_VERSION: ");
|
||||
Serial.println(AD5263_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
@ -15,8 +15,9 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println();
|
||||
Serial.print("AD5263_LIB_VERSION: ");
|
||||
Serial.println(AD5263_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
@ -15,8 +15,9 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println();
|
||||
Serial.print("AD5263_LIB_VERSION: ");
|
||||
Serial.println(AD5263_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
@ -15,8 +15,9 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println();
|
||||
Serial.print("AD5263_LIB_VERSION: ");
|
||||
Serial.println(AD5263_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
@ -15,8 +15,9 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println();
|
||||
Serial.print("AD5263_LIB_VERSION: ");
|
||||
Serial.println(AD5263_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
@ -15,8 +15,9 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println();
|
||||
Serial.print("AD5263_LIB_VERSION: ");
|
||||
Serial.println(AD5263_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
@ -15,12 +15,13 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println();
|
||||
Serial.print("AD5263_LIB_VERSION: ");
|
||||
Serial.println(AD5263_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
|
||||
bool b = AD01.begin();
|
||||
Serial.println(b ? "true" : "false");
|
||||
Serial.println(AD01.isConnected());
|
||||
@ -48,4 +49,3 @@ void loop()
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -7,7 +7,10 @@
|
||||
|
||||
#include "AD5263.h"
|
||||
|
||||
AD5263 AD01(0x2C); // AD0 & AD1 == GND
|
||||
// AD0 == GND
|
||||
// AD1 == GND
|
||||
// DIS == +5V
|
||||
AD5263 AD01(0x2C);
|
||||
|
||||
|
||||
void setup()
|
||||
@ -15,12 +18,13 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.println();
|
||||
Serial.print("AD5263_LIB_VERSION: ");
|
||||
Serial.println(AD5263_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
|
||||
|
||||
bool b = AD01.begin();
|
||||
Serial.println(b ? "true" : "false");
|
||||
Serial.println(AD01.isConnected());
|
||||
@ -41,10 +45,9 @@ void loop()
|
||||
AD01.write(1, val, LOW, LOW);
|
||||
}
|
||||
Serial.println(val);
|
||||
delay(20);
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -5,8 +5,11 @@ AD5263 KEYWORD1
|
||||
|
||||
# Methods and Functions (KEYWORD2)
|
||||
begin KEYWORD2
|
||||
isConnected KEYWORD2
|
||||
|
||||
reset KEYWORD2
|
||||
zeroAll KEYWORD2
|
||||
setAll KEYWORD2
|
||||
|
||||
read KEYWORD2
|
||||
write KEYWORD2
|
||||
@ -18,6 +21,8 @@ getO2 KEYWORD2
|
||||
|
||||
midScaleReset KEYWORD2
|
||||
pmCount KEYWORD2
|
||||
|
||||
readBackRegister KEYWORD2
|
||||
shutDown KEYWORD2
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/AD5263"
|
||||
},
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=AD5263
|
||||
version=0.1.1
|
||||
version=0.1.2
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Library to control digital potentiometer AD5263 and compatibles.
|
||||
|
Loading…
Reference in New Issue
Block a user