0.1.1 ADC08XS

This commit is contained in:
Rob Tillaart 2024-01-16 17:17:25 +01:00
parent 7276c4cb9a
commit fd4de0c136
9 changed files with 79 additions and 8 deletions

View File

@ -1,7 +1,7 @@
//
// FILE: ADC08XS.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// VERSION: 0.1.1
// DATE: 2024-01-13
// PURPOSE: Arduino library for ADC082S, ADC084S, ADC102S, ADC104S, ADC122S, ADC124S,
// 8, 10, 12 bits, 2 or 4 channel ADC (SPI).
@ -91,6 +91,12 @@ uint16_t ADC08XS::read(uint8_t channel)
}
int ADC08XS::deltaRead(uint8_t chanA, uint8_t chanB)
{
return int(read(chanA)) - int(read(chanB));
}
void ADC08XS::setSPIspeed(uint32_t speed)
{
_SPIspeed = speed;

View File

@ -2,7 +2,7 @@
//
// FILE: ADC08XS.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// VERSION: 0.1.1
// DATE: 2024-01-13
// PURPOSE: Arduino library for ADC082S, ADC084S, ADC102S, ADC104S, ADC122S, ADC124S,
// 8, 10, 12 bits, 2 or 4 channel ADC (SPI).
@ -14,7 +14,7 @@
#include "SPI.h"
#define ADC08XS_LIB_VERSION (F("0.1.0"))
#define ADC08XS_LIB_VERSION (F("0.1.1"))
#ifndef __SPI_CLASS__
@ -39,6 +39,7 @@ public:
uint16_t maxValue();
uint8_t maxChannel();
uint16_t read(uint8_t channel);
int deltaRead(uint8_t chanA, uint8_t chanB);
// speed in Hz
void setSPIspeed(uint32_t speed);

View 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] - 2024-01-16
- add **int deltaRead(chanA, chanB)**
- add example **ADC08XS_deltaRead.ino**
- fix select pin in **ADC08XS_read.ino**
- update readme.md
## [0.1.0] - 2024-01-13
- initial version.

View File

@ -125,8 +125,13 @@ depending on number of bits / class.
- **uint16_t read(uint8_t channel)** reads the value of the device.
The parameter channel must be 0,1,2,3, depending on device.
Invalid channels will always return zero 0.
- **void setSPIspeed(uint32_t speed)** sets SPI clock in **Hz**, please read datasheet
of the ADC first to get optimal speed.
- **int deltaRead(chanA, chanB)** read channel A and B and return the difference.
Note that the value can be negative if read(B) > read(A) or zero.
if chanA == chanB there will be two reads of the same channel just
a few microseconds apart, most often returning 0.
The function does not check if both channels are the same.
- **void setSPIspeed(uint32_t speed)** sets SPI clock in **Hz**,
please read datasheet of the ADC first to get optimal speed.
- **uint32_t getSPIspeed()** returns current speed in **Hz**.

View File

@ -0,0 +1,51 @@
//
// FILE: ADC08XS_deltaRead.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo
// URL: https://github.com/RobTillaart/ADC08XS
#include "ADC08XS.h"
ADC124S adc01(5, 6, 7); // use SWSPI
uint32_t start, stop;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("ADC08XS_LIB_VERSION: ");
Serial.println(ADC08XS_LIB_VERSION);
adc01.begin(4);
}
void loop()
{
// ADC124S has several possible combinations for deltaRead
// including using the same channel twice.
Serial.println("A\tB\tDelta");
for (int A = 0; A < 4; A++)
{
for (int B = 0; B < 4; B++)
{
Serial.print(A);
Serial.print("\t");
Serial.print(B);
Serial.print("\t");
Serial.println(adc01.deltaRead(A, B));
delay(10);
}
}
Serial.println();
Serial.println();
delay(5000);
}
// -- END OF FILE --

View File

@ -22,7 +22,7 @@ void setup()
Serial.println(ADC08XS_LIB_VERSION);
adc01.begin(10);
adc02.begin(5);
adc02.begin(4);
Serial.println();
Serial.println("ADC\tMAXVALUE");

View File

@ -17,6 +17,7 @@ maxValue KEYWORD2
maxChannel KEYWORD2
read KEYWORD2
deltaRead KEYWORD2
setSPIspeed KEYWORD2
getSPIspeed KEYWORD2

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/ADC08XS.git"
},
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"frameworks": "*",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=ADC08XS
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 ADC08XS 8, 10, 12 bit ADC (SPI), 2 or 4 channel.