Skip to content

Commit 8cc2898

Browse files
committed
0.1.1 AD5660
1 parent 2263c37 commit 8cc2898

File tree

10 files changed

+51
-35
lines changed

10 files changed

+51
-35
lines changed

libraries/AD5660/AD5660.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//
22
// FILE: AD5660.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.0
5-
// DATE: 2024-10-25
4+
// VERSION: 0.1.1
5+
// DATE: 2024-10-29
66
// PURPOSE: Arduino library for AD5660 Digital Analog Convertor (16 bit).
77

88

@@ -51,7 +51,7 @@ void AD5660::begin()
5151
// _mySPI->begin();
5252
// delay(1);
5353
}
54-
else // SOFTWARE SPI
54+
else // SOFTWARE SPI MODE0
5555
{
5656
pinMode(_dataOut, OUTPUT);
5757
pinMode(_clock, OUTPUT);
@@ -187,7 +187,7 @@ void AD5660::swSPI_transfer(uint32_t value)
187187
uint8_t clk = _clock;
188188
uint8_t dao = _dataOut;
189189
// 24 bit
190-
for (uint16_t mask = 0x800000; mask; mask >>= 1)
190+
for (uint32_t mask = 0x800000; mask; mask >>= 1)
191191
{
192192
digitalWrite(dao,(value & mask));
193193
digitalWrite(clk, HIGH);

libraries/AD5660/AD5660.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
//
33
// FILE: AD5660.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.1.0
5+
// VERSION: 0.1.1
66
// DATE: 2024-10-29
77
// PURPOSE: Arduino library for AD5660 Digital Analog Convertor (16 bit).
88

99

1010
#include "Arduino.h"
1111
#include "SPI.h"
1212

13-
#define AD5660_LIB_VERSION (F("0.1.0"))
13+
14+
#define AD5660_LIB_VERSION (F("0.1.1"))
1415

1516
#ifndef __SPI_CLASS__
1617
// MBED must be tested before RP2040

libraries/AD5660/CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
# Change Log AD5620
1+
# Change Log AD5660
22

33
All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9+
## [0.1.1] - 2024-10-29
10+
- update examples
11+
- update readme.md
12+
- minor edits
13+
14+
915
## [0.1.0] - 2024-10-29
1016
- initial version, based upon AD5620
1117

libraries/AD5660/README.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,26 @@ Feedback, issues, improvements are welcome.
3232
Please file an issue on GitHub.
3333

3434

35+
### Differences
36+
37+
The parts incorporate a power-on reset circuit to ensure that the DAC output
38+
powers up to 0 V (AD5620/AD5640/AD5660-1-2) or midscale (AD5620-3 and AD5660-3)
39+
and remains there until a valid write takes place.
40+
41+
3542
### Compatibles
3643

37-
Overview devices, nr of bits, setValue range and indicative LSB
44+
Overview of related devices, nr of bits, setValue range and indicative LSB
3845

39-
| device | bits | range | LSB @ 5V | notes |
40-
|:--------:|:------:|:-----------:|:-----------:|:-------:|
41-
| AD5620 | 12 | 0..4095 | 1.221 mV | see AD5620 library
42-
| AD5640 | 14 | 0..16383 | 0.3053 mV | see AD5620 library
43-
| AD5660 | 16 | 0..65535 | 0.0763 mV |
44-
| AD5680 | 18 | 0..262143 | 19.07 uV | see AD5680 library
46+
| device | bits | range | % stepsize | LSB @ 5V | notes |
47+
|:--------:|:------:|:-----------:|:------------:|:-----------:|:-------:|
48+
| AD5620 | 12 | 0..4095 | 0.025 | 1.221 mV | see AD5620 library
49+
| AD5640 | 14 | 0..16383 | 0.0065 | 0.3053 mV | see AD5620 library
50+
| AD5660 | 16 | 0..65535 | 0.0017 | 0.0763 mV |
51+
| AD5680 | 18 | 0..262143 | 0.0005 | 19.07 uV | see AD5680 library
52+
53+
54+
The AD5662 is compatible, however it does not support the Vref functions.
4555

4656

4757
### Related
@@ -62,8 +72,6 @@ Overview devices, nr of bits, setValue range and indicative LSB
6272

6373
### Base class
6474

65-
The AD5640 has identical constructors.
66-
6775
- **AD5660(uint8_t slaveSelect, SPIClassRP2040 \* mySPI = &SPI)** constructor hardware SPI (RP2040 specific).
6876
Sets internal value to zero.
6977
- **AD5660(uint8_t slaveSelect, SPIClass \* mySPI = &SPI)** constructor hardware SPI.
@@ -72,7 +80,7 @@ Sets internal value to zero.
7280
Sets the software SPI pins.
7381
Sets internal value to zero.
7482
- **void begin()** initializes the SPI and sets internal state.
75-
- **uint8_t getType()** returns nr of bits, 12 for AD5660, 14 for AD5640.
83+
- **uint8_t getType()** returns nr of bits, 16 for AD5660.
7684

7785

7886
### Set DAC
@@ -81,10 +89,11 @@ Sets internal value to zero.
8189
effectively a prepare + update in one call.
8290
Returns false if value out of range.
8391
- **uint16_t getValue()** returns the set value from cache.
84-
At power up the device will be reset to 0 (== 0 volt).
92+
At power up the device will be reset to 0 (== 0 volt). (not always).
8593
- **uint16_t getMaxValue()** returns 65535 for AD5660.
8694
- **bool setPercentage(float percentage)** sets the output as a percentage 0..100%.
8795
If percentage is out of range, it is **not** set and the function returns false.
96+
The stepsize is about 0.002% for the AD5660.
8897
- **float getPercentage()** returns percentage, wrapper around **getValue()**.
8998
Might return a slightly different value than **setPercentage()** due to
9099
rounding math.
@@ -104,7 +113,7 @@ See datasheet P19 for details.
104113
| 0 | normal mode (default) |
105114
| 1 | 1 KOhm to GND |
106115
| 2 | 100 KOhm to GND |
107-
| 3 | Threestate |
116+
| 3 | ThreeState |
108117

109118

110119
### SPI
@@ -116,7 +125,7 @@ please read datasheet of the ADC first to get optimal speed.
116125
- **uint32_t getSPIspeed()** gets current speed in **Hz**.
117126
- **bool usesHWSPI()** returns true if HW SPI is used.
118127

119-
Datasheet maximum frequency. Overclocking is not tested.
128+
Datasheet P7 maximum frequency. Overclocking is not tested.
120129

121130
| Voltage | Max Speed |
122131
|:---------:|:-----------:|
@@ -135,17 +144,17 @@ produce different numbers.
135144

136145
| version | board | clock | SPI | calls / sec | Notes |
137146
|:---------:|:-------:|:---------:|:-----:|:-------------:|:--------|
138-
| 0.1.0 | UNO | 16 MHz | HW | | max SPI speed
139-
| 0.1.0 | UNO | 16 MHz | SW | |
147+
| 0.1.0 | UNO | 16 MHz | HW | 58800 | max SPI speed
148+
| 0.1.0 | UNO | 16 MHz | SW | 3300 |
140149
| 0.1.0 | ESP32 | 240 MHz | HW | | 1
141150
| 0.1.0 | ESP32 | 240 MHz | SW | |
142151

143152

144153
1. ESP32 HW is equal performant for HSPI and VSPI.
145154
Unknown why HW SPI is 20% slower than SW SPI (transaction overhead?)
146155

147-
xxxxxx calls per second means that a 1 KHz wave can be
148-
constructed with xxxx values per period (max).
156+
58800 calls per second means that a 1 KHz wave can be
157+
constructed with 58 values per period (max).
149158

150159
Please share your performance data, open an issue to report.
151160

@@ -159,8 +168,8 @@ Please share your performance data, open an issue to report.
159168

160169
#### Should
161170

162-
- add examples
163-
- create a similar library for AD5660
171+
- sync with AD5620.
172+
- power on reset level 0 or midscale.
164173

165174
#### Could
166175

libraries/AD5660/examples/AD5660_demo/AD5660_demo.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ void setup()
2626

2727
Serial.print("HWSPI: ");
2828
Serial.println(AD16_HW.usesHWSPI());
29-
Serial.print("HWSPI: ");
29+
Serial.print("SWSPI: ");
3030
Serial.println(AD16_SW.usesHWSPI());
3131
delay(100);
3232

3333
AD16_HW.setSPIspeed(16000000);
34-
34+
3535
Serial.println();
3636
Serial.println("usec\tcalls/sec");
3737
}
@@ -42,8 +42,8 @@ void loop()
4242
uint32_t start = micros();
4343
for (uint16_t i = 0; i < 1000; i++)
4444
{
45-
AD16_HW.setValue(i);
46-
// AD16_SW.setValue(i);
45+
// AD16_HW.setValue(i);
46+
AD16_SW.setValue(i);
4747
}
4848
uint32_t duration = micros() - start;
4949
Serial.print(duration * 0.001);

libraries/AD5660/examples/AD5660_sawtooth/AD5660_sawtooth.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ AD5660 AD16_HW(8, &SPI);
1212
AD5660 AD16_SW(5, 6, 7);
1313

1414
float frequency = 50;
15-
float amplitude = 4095; // 12 bits
15+
float amplitude = 65535; // 16 bits
1616

1717

1818
void setup()

libraries/AD5660/examples/AD5660_sinus/AD5660_sinus.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ AD5660 AD16_HW(8, &SPI);
1212
AD5660 AD16_SW(5, 6, 7);
1313

1414
float frequency = 10.0;
15-
float amplitude = 2047; // 50% of 12 bits
15+
float amplitude = 32767; // 50% of 16 bits
1616

1717
void setup()
1818
{

libraries/AD5660/examples/AD5660_triangle/AD5660_triangle.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ AD5660 AD16_HW(8, &SPI);
1212
AD5660 AD16_SW(5, 6, 7);
1313

1414
float frequency = 10.0;
15-
float amplitude = 4095; // 12 bits
15+
float amplitude = 65535; // 16 bits
1616

1717

1818
void setup()

libraries/AD5660/library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/AD5660.git"
1717
},
18-
"version": "0.1.0",
18+
"version": "0.1.1",
1919
"license": "MIT",
2020
"frameworks": "*",
2121
"platforms": "*",

libraries/AD5660/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=AD5660
2-
version=0.1.0
2+
version=0.1.1
33
author=Rob Tillaart <[email protected]>
44
maintainer=Rob Tillaart <[email protected]>
55
sentence=Arduino library for AD5660 Digital Analog Convertor (16 bit).

0 commit comments

Comments
 (0)