mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.1 AD5263
This commit is contained in:
parent
297c6b45e0
commit
0ced2e51b7
@ -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 --
|
||||
|
||||
|
@ -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 --
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 --
|
||||
|
@ -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": "*",
|
||||
|
@ -1,9 +1,9 @@
|
||||
name=AD5263
|
||||
version=0.1.0
|
||||
version=0.1.1
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
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=*
|
||||
|
Loading…
x
Reference in New Issue
Block a user