Arduino library for the AD5620 / AD5640 Digital Analog Convertor (12/14 bit).
Experimental
The AD5620 is a 12 bit DAC, which is to be controlled by SPI. This library supports both hardware as software SPI.
The value of the DAC can be changed by setValue() or by setPercentage(). If the values are out of range these function will return false. The value set is kept by the library and can be fetched by getValue() and getPercentage().
The library also implements support for the AD5640, a 14 bit DAC.
Warning The library is not tested with hardware so use with care.
Feedback, issues, improvements are welcome. Please file an issue on GitHub.
Overview devices, nr of bits, setValue range and indicative LSB
device | bits | range | LSB @ 5V | notes |
---|---|---|---|---|
AD5620 | 12 | 0..4095 | 1.221 mV | |
AD5640 | 14 | 0..16383 | 0.3053 mV | |
AD5660 | 16 | 0..262143 | 19.07 uV | almost compatible, not supported. |
#include "AD5620.h"
The AD5640 has identical constructors.
See datasheet P19 for details.
mode | description |
---|---|
0 | normal mode (default) |
1 | 1 KOhm to GND |
2 | 100 KOhm to GND |
3 | Threestate |
Adjust the performance of the SPI port.
Datasheet maximum frequency. Overclocking is not tested.
Voltage | Max Speed |
---|---|
2.7 V | 20 MHz |
3.5 V | 20 MHz |
3.6 V | 30 MHz |
5.5 V | 30 MHz |
Measurements with AD5620_demo.ino - performance of setValue() is the most important. The numbers are rounded and indicative, other boards might produce different numbers.
version | board | clock | SPI | calls / sec | Notes |
---|---|---|---|---|---|
0.1.0 | UNO | 16 MHz | HW | 70900 | max SPI speed |
0.1.0 | UNO | 16 MHz | SW | 5289 | |
0.1.0 | ESP32 | 240 MHz | HW | 1 | |
0.1.0 | ESP32 | 240 MHz | SW |
70000 calls per second means that a 1 KHz wave can be constructed with 70 values per period (max).
Please share your performance data, open an issue to report.
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,