mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.3 AD5144A
This commit is contained in:
parent
b526ef73f2
commit
8f69b16b4d
@ -2,6 +2,10 @@ compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
- uno
|
||||
- leonardo
|
||||
- due
|
||||
- zero
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
- m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
@ -4,10 +4,14 @@ name: Arduino CI
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
arduino_ci:
|
||||
runTest:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: Arduino-CI/action@master
|
||||
# Arduino-CI/action@v0.1.1
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
- run: |
|
||||
gem install arduino_ci
|
||||
arduino_ci.rb
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: AD5144A.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// VERSION: 0.1.3
|
||||
// PURPOSE: I2C digital potentiometer AD5144A
|
||||
// DATE: 2021-04-30
|
||||
// URL: https://github.com/RobTillaart/AD5144A
|
||||
@ -10,6 +10,7 @@
|
||||
// 0.1.0 2021-04-30 initial version
|
||||
// 0.1.1 2021-05-12 add topScale() and bottomScale()
|
||||
// 0.1.2 2021-05-12 add increment() and decrement() functions
|
||||
// 0.1.3 2021-10-17 update build-ci, improve readme.md
|
||||
|
||||
|
||||
#include "AD5144A.h"
|
||||
@ -338,25 +339,27 @@ uint8_t AD51XX::writeControlRegister(uint8_t mask)
|
||||
return send(cmd, mask);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
/*
|
||||
_wire->endTransmission
|
||||
0:success
|
||||
1:data too long to fit in transmit buffer
|
||||
2:received NACK on transmit of address
|
||||
3:received NACK on transmit of data
|
||||
4:other error
|
||||
*/
|
||||
//
|
||||
// _wire->endTransmission
|
||||
// returns description
|
||||
// 0: success
|
||||
// 1: data too long to fit in transmit buffer
|
||||
// 2: received NACK on transmit of address
|
||||
// 3: received NACK on transmit of data
|
||||
// 4: other error
|
||||
//
|
||||
uint8_t AD51XX::send(const uint8_t cmd, const uint8_t value)
|
||||
{
|
||||
// COMMAND 1 - page 20
|
||||
_wire->beginTransmission(_address); // returns nothing.
|
||||
_wire->write(cmd); // returns bytes written
|
||||
_wire->write(value); // returns bytes written
|
||||
return _wire->endTransmission(); // returns status of actual write..
|
||||
return _wire->endTransmission(); // returns status of actual write
|
||||
}
|
||||
|
||||
|
||||
@ -380,57 +383,67 @@ uint8_t AD51XX::readBack(const uint8_t rdac, const uint8_t mask)
|
||||
return _wire->read();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DERIVED CLASSES
|
||||
//
|
||||
AD5123::AD5123(const uint8_t address, TwoWire *wire) : AD51XX(address, wire)
|
||||
{
|
||||
_potCount = 4;
|
||||
_maxValue = 127;
|
||||
}
|
||||
|
||||
|
||||
AD5124::AD5124(const uint8_t address, TwoWire *wire) : AD51XX(address, wire)
|
||||
{
|
||||
_potCount = 4;
|
||||
_maxValue = 127;
|
||||
}
|
||||
|
||||
|
||||
AD5143::AD5143(const uint8_t address, TwoWire *wire) : AD51XX(address, wire)
|
||||
{
|
||||
_potCount = 4;
|
||||
_maxValue = 255;
|
||||
}
|
||||
|
||||
|
||||
AD5144::AD5144(const uint8_t address, TwoWire *wire) : AD51XX(address, wire)
|
||||
{
|
||||
_potCount = 4;
|
||||
_maxValue = 255;
|
||||
}
|
||||
|
||||
|
||||
AD5144A::AD5144A(const uint8_t address, TwoWire *wire) : AD51XX(address, wire)
|
||||
{
|
||||
_potCount = 4;
|
||||
_maxValue = 255;
|
||||
}
|
||||
|
||||
|
||||
AD5122A::AD5122A(const uint8_t address, TwoWire *wire) : AD51XX(address, wire)
|
||||
{
|
||||
_potCount = 2;
|
||||
_maxValue = 128;
|
||||
}
|
||||
|
||||
|
||||
AD5142A::AD5142A(const uint8_t address, TwoWire *wire) : AD51XX(address, wire)
|
||||
{
|
||||
_potCount = 2;
|
||||
_maxValue = 255;
|
||||
}
|
||||
|
||||
|
||||
AD5121::AD5121(const uint8_t address, TwoWire *wire) : AD51XX(address, wire)
|
||||
{
|
||||
_potCount = 1;
|
||||
_maxValue = 128;
|
||||
}
|
||||
|
||||
|
||||
AD5141::AD5141(const uint8_t address, TwoWire *wire) : AD51XX(address, wire)
|
||||
{
|
||||
_potCount = 1;
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: AD5144A.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// VERSION: 0.1.3
|
||||
// PURPOSE: I2C digital PotentioMeter AD5144A
|
||||
// DATE: 2021-04-30
|
||||
// URL: https://github.com/RobTillaart/AD5144A
|
||||
@ -12,7 +12,7 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define AD51XXA_VERSION (F("0.1.2_experimental"))
|
||||
#define AD51XXA_VERSION (F("0.1.3_experimental"))
|
||||
|
||||
|
||||
#define AD51XXA_OK 0
|
||||
@ -72,7 +72,7 @@ public:
|
||||
// page 27-28
|
||||
uint8_t setLinearMode(const uint8_t rdac);
|
||||
uint8_t setPotentiometerMode(const uint8_t rdac);
|
||||
// 0 = potentio, 1 = linear
|
||||
// 0 = potentiometer, 1 = linear
|
||||
uint8_t getOperationalMode(const uint8_t rdac);
|
||||
|
||||
uint8_t incrementLinear(const uint8_t rdac);
|
||||
@ -86,10 +86,10 @@ public:
|
||||
|
||||
|
||||
// SYNC functions
|
||||
// preload registers to change all channels synchronuous
|
||||
// preload registers to change all channels synchronous
|
||||
uint8_t preload(const uint8_t rdac, const uint8_t value);
|
||||
uint8_t preloadAll(const uint8_t value);
|
||||
// copy the preloads to the channels. The bitmask indicates which channels
|
||||
// copy the preloads to the channels. The bit mask indicates which channels
|
||||
// b00001101 would indicate channel 0, 2 and 3;
|
||||
uint8_t sync(const uint8_t mask);
|
||||
|
||||
@ -109,18 +109,20 @@ public:
|
||||
|
||||
// USE WITH CARE - READ DATASHEET
|
||||
// write to control register
|
||||
//
|
||||
// value : 0 1
|
||||
// bit 0 : FREEZE RDAC's normal operation
|
||||
// bit 1 : EEPROM DISABLED normal operation
|
||||
// bit 2 : normal operation LINEAR GAIN MODE
|
||||
// bit 3 : normal operation BURST MODE
|
||||
//
|
||||
uint8_t writeControlRegister(uint8_t mask);
|
||||
// TODO separate get set functions ?
|
||||
|
||||
|
||||
protected:
|
||||
uint8_t _potCount = 4; // unknown
|
||||
uint8_t _maxValue = 255; // unknown
|
||||
uint8_t _potCount = 4; // unknown, default max
|
||||
uint8_t _maxValue = 255; // unknown, default max
|
||||
|
||||
|
||||
private:
|
||||
@ -133,8 +135,11 @@ private:
|
||||
TwoWire* _wire;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DERIVED CLASSES
|
||||
//
|
||||
class AD5123 : public AD51XX
|
||||
{
|
||||
AD5123(const uint8_t address, TwoWire *wire = &Wire);
|
||||
|
@ -1,5 +1,7 @@
|
||||
|
||||
[![Arduino CI](https://github.com/RobTillaart/AD5144A/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
||||
[![Arduino-lint](https://github.com/RobTillaart/AD5144A/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/AD5144A/actions/workflows/arduino-lint.yml)
|
||||
[![JSON check](https://github.com/RobTillaart/AD5144A/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/AD5144A/actions/workflows/jsoncheck.yml)
|
||||
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/AD5144A/blob/master/LICENSE)
|
||||
[![GitHub release](https://img.shields.io/github/release/RobTillaart/AD5144A.svg?maxAge=3600)](https://github.com/RobTillaart/AD5144A/releases)
|
||||
|
||||
@ -38,6 +40,7 @@ The library has a number of functions which are all quite straightforward.
|
||||
|
||||
As the library is experimental, function signatures might change in the future.
|
||||
|
||||
|
||||
### Constructors
|
||||
|
||||
- **AD51XX(uint8_t address, TwoWire \*wire = &Wire)** base class, to set the I2C address and optional the Wire bus used.
|
||||
@ -81,9 +84,9 @@ Returns true if the address of the device can be found on the I2C bus.
|
||||
|
||||
Used to set one channel at the time.
|
||||
|
||||
- **uint8_t write(rdac, value)** set channel rdac 0..3 to value 0..255 (depending on type less channels and lower max value should be used)
|
||||
- **uint8_t write(uint8_t rdac, uint8_t value)** set channel rdac 0..3 to value 0..255 (depending on type less channels and lower max value should be used)
|
||||
The value is also written into a cache of last set values for fast retrieval later.
|
||||
- **uint8_t read(rdac)** read back set value from the **cache**, not from the device.
|
||||
- **uint8_t read(uint8_t rdac)** read back set value from the **cache**, not from the device.
|
||||
|
||||
|
||||
### EEPROM
|
||||
@ -92,39 +95,72 @@ The value stored in the EEPROM is the value the 4 potmeters will start at boot t
|
||||
This allows to start at predefined values and makes it possibly easier to continue after
|
||||
a reboot.
|
||||
|
||||
- **uint8_t storeEEPROM(rdac)** store the current channel value in EEPROM.
|
||||
- **uint8_t storeEEPROM(rdac, value)** store a specific (new) value in EEPROM.
|
||||
- **uint8_t recallEEPROM(rdac)** get the value from EEPROM and set the channel.
|
||||
- **uint8_t storeEEPROM(uint8_t rdac)** store the current channel value in EEPROM.
|
||||
- **uint8_t storeEEPROM(uint8_t rdac, uint8_t value)** store a specific (new) value in EEPROM.
|
||||
- **uint8_t recallEEPROM(uint8_t rdac)** get the value from EEPROM and set the channel.
|
||||
|
||||
|
||||
### Async
|
||||
|
||||
Sets values in sequence, not at exact same time
|
||||
|
||||
- **uint8_t writeAll(value)** write the same value to all channels.
|
||||
- **uint8_t writeAll(uint8_t value)** write the same value to all channels.
|
||||
- **uint8_t zeroAll()** sets all channels to 0
|
||||
- **uint8_t midScaleAll()** sets all channels to their midpoint 128 / 64
|
||||
- **uint8_t maxAll()** sets all channels to the max 255 / 127
|
||||
- **uint8_t zero(rdac)** sets one channel to 0
|
||||
- **uint8_t midScale(rdac)** sets one channel to its midpoint = 128 / 64
|
||||
- **uint8_t maxValue(rdac)** sets one channel to the max 255 / 127
|
||||
- **uint8_t zero(uint8_t rdac)** sets one channel to 0
|
||||
- **uint8_t midScale(uint8_t rdac)** sets one channel to its midpoint = 128 / 64
|
||||
- **uint8_t maxValue(uint8_t rdac)** sets one channel to the max 255 / 127
|
||||
|
||||
|
||||
### Sync
|
||||
|
||||
- **uint8_t preload(rdac, value)** prepare a rdac for a new value but only use it after **sync()** is called.
|
||||
- **uint8_t preloadAll(value)** prepape all rdacs with the same value, and wait for **sync()**
|
||||
- **uint8_t sync(mask)** will transfer the preloaded values to the (4) rdacs at the very same moment. The 4-bit mask is used to select which rdacs to sync.
|
||||
- **uint8_t preload(uint8_t rdac, uint8_t value)** prepare a single rdac for a new value but only use it after **sync()** is called.
|
||||
- **uint8_t preloadAll(uint8_t value)** prepare all rdacs with the same value, and wait for **sync()**
|
||||
- **uint8_t sync(uint8_t mask)** will transfer the preloaded values to the (4) rdacs at the very same moment.
|
||||
The 4-bit mask is used to select which rdacs to sync.
|
||||
|
||||
|
||||
### TopScale BottomScale
|
||||
|
||||
See page 27 datasheet
|
||||
|
||||
- **uint8_t setTopScale(uint8_t rdac)**
|
||||
- **uint8_t clrTopScale(uint8_t rdac)**
|
||||
- **uint8_t setTopScaleAll()**
|
||||
- **uint8_t clrTopScaleAll()**
|
||||
- **uint8_t setBottomScale(uint8_t rdac)**
|
||||
- **uint8_t clrBottomScale(uint8_t rdac)**
|
||||
- **uint8_t setBottomScaleAll()**
|
||||
- **uint8_t clrBottomScaleAll()**
|
||||
|
||||
|
||||
### Operational modes
|
||||
|
||||
See page 27-28 datasheet
|
||||
|
||||
- **uint8_t setLinearMode(uint8_t rdac)**
|
||||
- **uint8_t setPotentiometerMode(uint8_t rdac)**
|
||||
- **// 0 = potentio, 1 = linear
|
||||
- **uint8_t getOperationalMode(uint8_t rdac)**
|
||||
- **uint8_t incrementLinear(uint8_t rdac)**
|
||||
- **uint8_t incrementLinearAll()**
|
||||
- **uint8_t decrementLineair(uint8_t rdac)**
|
||||
- **uint8_t decrementLineairAll()**
|
||||
- **uint8_t increment6dB(uint8_t rdac)**
|
||||
- **uint8_t increment6dBAll()**
|
||||
- **uint8_t decrement6dB(uint8_t rdac)**
|
||||
- **uint8_t decrement6dBAll()**
|
||||
|
||||
|
||||
### ReadBack
|
||||
|
||||
These function read back from the internal registers of the actual device.
|
||||
|
||||
- **uint8_t readBackINPUT(rdac)** reads back the "preload value" in the INPUT register.
|
||||
- **uint8_t readBackEEPROM(rdac)** reads the **boot value** for the selected rdac from EEPROM.
|
||||
- **uint8_t readBackCONTROL(rdac)** read back the control register. Read the datasheet for the details of the individual bits.
|
||||
- **uint8_t readBackRDAC(rdac)** reads the value of the rdac from the device.
|
||||
- **uint8_t readBackINPUT(uint8_t rdac)** reads back the "preload value" in the INPUT register.
|
||||
- **uint8_t readBackEEPROM(uint8_t rdac)** reads the **boot value** for the selected rdac from EEPROM.
|
||||
- **uint8_t readBackCONTROL(uint8_t rdac)** read back the control register. Read the datasheet for the details of the individual bits.
|
||||
- **uint8_t readBackRDAC(uint8_t rdac)** reads the value of the rdac from the device.
|
||||
|
||||
|
||||
### Write control register
|
||||
@ -136,7 +172,9 @@ Read the datasheet for the details of the individual bits.
|
||||
|
||||
### Misc
|
||||
|
||||
- **uint8_t pmCount()** returns the number of potmeters / channels the device has. Useful when writing your own loops over all channels.
|
||||
- **uint8_t pmCount()** returns the number of potentiometers / channels the device has.
|
||||
Useful when writing your own loops over all channels.
|
||||
- **uint8_t maxValue()** return maxValue (127 / 255) of the potentiometer.
|
||||
- **uint8_t shutDown()** check datasheet, not tested yet, use at own risk.
|
||||
|
||||
|
||||
@ -145,21 +183,15 @@ Read the datasheet for the details of the individual bits.
|
||||
The examples show the basic working of the functions.
|
||||
|
||||
|
||||
## TODO
|
||||
## Future
|
||||
|
||||
See also open issues.
|
||||
|
||||
#### Must
|
||||
|
||||
- testing ...
|
||||
- example sketches
|
||||
|
||||
#### Could
|
||||
|
||||
- CI test code
|
||||
- update documentation
|
||||
- more testing ...
|
||||
- CI unit test code
|
||||
- SPI based version of the library ?
|
||||
- test for maxValue when writing a channel as not all derived use 0..255
|
||||
|
||||
- some functions can be performance optimized
|
||||
- writing a value is not needed is last value is the same?
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
//
|
||||
// FILE: AD5144A_low_level.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: test low level IO
|
||||
// DATE: 2021-05-04
|
||||
// URL: https://github.com/RobTillaart/AD5144A
|
||||
|
@ -1,7 +1,6 @@
|
||||
//
|
||||
// FILE: AD5144A_test_EEPROM.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: test EEPROM functions
|
||||
// DATE: 2021-05-04
|
||||
// URL: https://github.com/RobTillaart/AD5144A
|
||||
|
@ -1,7 +1,6 @@
|
||||
//
|
||||
// FILE: AD5144A_test_control_register.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: read CONTROL REGISTER functions
|
||||
// DATE: 2021-05-04
|
||||
// URL: https://github.com/RobTillaart/AD5144A
|
||||
|
@ -1,7 +1,6 @@
|
||||
//
|
||||
// FILE: AD5144A_test_isConnected.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: check isConnected()
|
||||
// DATE: 2021-05-04
|
||||
// URL: https://github.com/RobTillaart/AD5144A
|
||||
|
@ -1,7 +1,6 @@
|
||||
//
|
||||
// FILE: AD5144A_test_performance.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: indication performance methods of the class
|
||||
// DATE: 2021-04-30
|
||||
// URL: https://github.com/RobTillaart/AD5144A
|
||||
|
@ -1,14 +1,13 @@
|
||||
//
|
||||
// FILE: AD5144A_test_preload_sync.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo
|
||||
// DATE: 2021-05-04
|
||||
// URL: https://github.com/RobTillaart/AD5144A
|
||||
|
||||
|
||||
// connect the AD5144A to a multichannel scope
|
||||
// to verify the potmeters change at the same time
|
||||
// to verify the potentiometers change at the same time
|
||||
|
||||
|
||||
#include "AD5144A.h"
|
||||
|
@ -1,7 +1,6 @@
|
||||
//
|
||||
// FILE: AD5144A_test_speed.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo
|
||||
// DATE: 2021-04-30
|
||||
// URL: https://github.com/RobTillaart/AD5144A
|
||||
|
@ -1,7 +1,6 @@
|
||||
//
|
||||
// FILE: AD5144A_test_write.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo
|
||||
// DATE: 2021-04-30
|
||||
// URL: https://github.com/RobTillaart/AD5144A
|
||||
|
@ -1,7 +1,6 @@
|
||||
//
|
||||
// FILE: AD5144A_test_writeAll.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: test writeAll + wrappers
|
||||
// DATE: 2021-05-04
|
||||
// URL: https://github.com/RobTillaart/AD5144A
|
||||
|
@ -36,12 +36,34 @@ preload KEYWORD2
|
||||
preloadAll KEYWORD2
|
||||
sync KEYWORD2
|
||||
|
||||
setTopScale KEYWORD2
|
||||
clrTopScale KEYWORD2
|
||||
setTopScaleAll KEYWORD2
|
||||
clrTopScaleAll KEYWORD2
|
||||
setBottomScale KEYWORD2
|
||||
clrBottomScale KEYWORD2
|
||||
setBottomScaleAll KEYWORD2
|
||||
clrBottomScaleAll KEYWORD2
|
||||
|
||||
setLinearMode KEYWORD2
|
||||
setPotentiometerMode KEYWORD2
|
||||
getOperationalMode KEYWORD2
|
||||
incrementLinear KEYWORD2
|
||||
incrementLinearAll KEYWORD2
|
||||
decrementLineair KEYWORD2
|
||||
decrementLineairAll KEYWORD2
|
||||
increment6dB KEYWORD2
|
||||
increment6dBAll KEYWORD2
|
||||
decrement6dB KEYWORD2
|
||||
decrement6dBAll KEYWORD2
|
||||
|
||||
readBackINPUT KEYWORD2
|
||||
readBackEEPROM KEYWORD2
|
||||
readBackCONTROL KEYWORD2
|
||||
readBackRDAC KEYWORD2
|
||||
|
||||
pmCount KEYWORD2
|
||||
maxValue KEYWORD2
|
||||
shutDown KEYWORD2
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/AD5144A"
|
||||
},
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*"
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=AD5144A
|
||||
version=0.1.2
|
||||
version=0.1.3
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino Library for AD5144A
|
||||
|
Loading…
x
Reference in New Issue
Block a user