0.2.7 DAC8551

This commit is contained in:
Rob Tillaart 2023-09-23 17:02:25 +02:00
parent b00f2c1cf3
commit c49e35449a
10 changed files with 189 additions and 18 deletions

View File

@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.2.7] - 2023-09-23
- add example DAC8531_hw_spi.ino + screenshot
- update readme.md
- minor edits
## [0.2.6] - 2022-10-31
- add changelog.md
- add rp2040 to build-CI

View File

@ -2,11 +2,8 @@
// FILE: DAC8551.cpp
// AUTHOR: Rob Tillaart
// PURPOSE: Arduino library for DAC8551 SPI Digital Analog Convertor
// VERSION: 0.2.6
// VERSION: 0.2.7
// URL: https://github.com/RobTillaart/DAC8551
//
// HISTORY: see changelog.md
#include "DAC8551.h"
@ -81,7 +78,7 @@ void DAC8551::setGPIOpins(uint8_t clk, uint8_t miso, uint8_t mosi, uint8_t selec
pinMode(_select, OUTPUT);
digitalWrite(_select, HIGH);
mySPI->end(); // disable SPI
mySPI->end(); // disable SPI
mySPI->begin(clk, miso, mosi, select);
}
#endif
@ -139,7 +136,7 @@ void DAC8551::updateDevice()
mySPI->transfer(_value & 0xFF);
mySPI->endTransaction();
}
else // Software SPI
else // Software SPI
{
swSPI_transfer(configRegister);
swSPI_transfer(_value >> 8);
@ -166,7 +163,7 @@ void DAC8551::swSPI_transfer(uint8_t value)
/////////////////////////////////////////////////////////
//
// derive 8501, 8531 and 8550 from 8551
//
//
DAC8501::DAC8501(uint8_t slaveSelect) : DAC8551(slaveSelect)
{
@ -201,5 +198,5 @@ DAC8550::DAC8550(uint8_t spiData, uint8_t spiClock, uint8_t slaveSelect)
}
// -- END OF FILE --
// -- END OF FILE --

View File

@ -2,9 +2,9 @@
//
// FILE: DAC8551.h
// AUTHOR: Rob Tillaart
// PURPOSE: Arduino library for DAC8551 SPI Digital Analog Convertor
// PURPOSE: Arduino library for DAC8551 SPI Digital Analog Convertor
// could work with DAC8550, not tested
// VERSION: 0.2.6
// VERSION: 0.2.7
// HISTORY: See DAC8551.cpp
// URL: https://github.com/RobTillaart/DAC8551
//
@ -14,7 +14,7 @@
#include "SPI.h"
#define DAC8551_LIB_VERSION (F("0.2.6"))
#define DAC8551_LIB_VERSION (F("0.2.7"))
#define DAC8551_POWERDOWN_NORMAL 0
@ -81,7 +81,7 @@ protected:
/////////////////////////////////////////////////////////
//
// derive 8501, 8531 and 8550 from 8551
//
//
#define DAC8501_POWERDOWN_NORMAL 0
#define DAC8501_POWERDOWN_1K 1

View File

@ -2,8 +2,11 @@
[![Arduino CI](https://github.com/RobTillaart/DAC8551/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/DAC8551/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/DAC8551/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/DAC8551/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/DAC8551/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/DAC8551.svg)](https://github.com/RobTillaart/DAC8551/issues)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/DAC8551/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/DAC8551.svg?maxAge=3600)](https://github.com/RobTillaart/DAC8551/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/DAC8551.svg)](https://registry.platformio.org/libraries/robtillaart/DAC8551)
# DAC8551
@ -15,14 +18,23 @@ Arduino library for DAC8501 DAC8531, DAC8550, DAC8551 SPI Digital Analog Convert
The DAC8551 is a SPI based 16 bit DAC with one channel.
The DAC8501, DAC8531 and DAC8550 are drop in compatible
They all have classed derived 1 to 1 from DAC8551.
The DAC8501, DAC8531 and DAC8550 are drop in compatible.
They all have classes derived 1 to 1 from DAC8551.
**Warning** this library is not tested extensively.
#### Related
- https://github.com/RobTillaart/AD5680 (18 bit DAC)
## Interface
```cpp
#include "DAC8551.h"
```
### Core
- **DAC8501(uint8_t slaveSelect)** Constructor for DAC8501 with hardware SPI,
@ -102,7 +114,28 @@ See examples
## Future
- testing
#### Must
- improve documentation
#### Should
- testing (DAC8531 is verified, see example)
- verify replacement chips
#### Could
#### Wont
## Support
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,

View File

@ -0,0 +1,53 @@
//
// FILE: DAC8531_hw_spi.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo DAC8551 library Arduino with hardware SPI
// URL: https://github.com/RobTillaart/DAC8551
#include "DAC8551.h"
DAC8531 mydac(8); // CLK=D13, MISO=D11, SS = D8
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.println(DAC8551_LIB_VERSION);
mydac.begin();
}
void loop()
{
// minimal sawtooth
for (uint16_t val = 0; val < 65500; val += 30)
{
mydac.setValue(val);
int av = analogRead(A0);
Serial.print(val);
Serial.print("\t ==> \t");
Serial.print(av);
if (val % 300 == 0) Serial.println();
}
Serial.println();
// minimal sinus
for (long i = 0; i < 360; i++ )
{
long s = 32768 + 32768 * sin( i * (PI / 180.0));
mydac.setValue(s);
int av = analogRead(A0);
Serial.print(i);
Serial.print("\t ==> \t");
Serial.print(av);
delay(100);
if (i % 30 == 0) Serial.println();
}
Serial.println();
}
// -- END OF FILE --

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -0,0 +1,28 @@
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:
packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
# - uno
# - due
# - zero
# - leonardo
# - m4
- esp32
# - esp8266
# - mega2560
# - rpipico

View File

@ -0,0 +1,54 @@
//
// FILE: DAC8551_ESP32_VSPI.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo DAC8551 library Arduino with hardware SPI
// URL: https://github.com/RobTillaart/DAC8551
#include "DAC8551.h"
#include "Wire.h"
// HW SPI uses slave spin since 0.2.0
DAC8531 mydac(1);
void setup()
{
Serial.begin(115200);
mydac.selectVSPI();
mydac.begin();
}
void loop()
{
// minimal sawtooth
for (uint16_t val = 0; val < 65500; val += 30)
{
mydac.setValue(val);
int av = analogRead(A0);
Serial.print(val);
Serial.print("\t ==> \t");
Serial.print(av);
if (val % 300 == 0) Serial.println();
}
Serial.println();
// minimal sinus
for (long i = 0; i < 360; i++ )
{
long s = 32768 + 32768 * sin( i * (PI / 180.0));
mydac.setValue(s);
int av = analogRead(A0);
Serial.print(i);
Serial.print("\t ==> \t");
Serial.print(av);
delay(100);
if (i % 30 == 0) Serial.println();
}
Serial.println();
}
// -- END OF FILE --

View File

@ -15,9 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/DAC8551"
},
"version": "0.2.6",
"version": "0.2.7",
"license": "MIT",
"frameworks": "arduino",
"frameworks": "*",
"platforms": "*",
"headers": "DAC8551.h"
}

View File

@ -1,5 +1,5 @@
name=DAC8551
version=0.2.6
version=0.2.7
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for DAC8501, DAC8531, DAC8550 and DAC8551 SPI 16-bit Digital Analog Convertor