22[ ![ Arduino CI] ( https://github.com/RobTillaart/MCP_ADC/workflows/Arduino%20CI/badge.svg )] ( https://github.com/marketplace/actions/arduino_ci )
33[ ![ Arduino-lint] ( https://github.com/RobTillaart/MCP_ADC/actions/workflows/arduino-lint.yml/badge.svg )] ( https://github.com/RobTillaart/MCP_ADC/actions/workflows/arduino-lint.yml )
44[ ![ JSON check] ( https://github.com/RobTillaart/MCP_ADC/actions/workflows/jsoncheck.yml/badge.svg )] ( https://github.com/RobTillaart/MCP_ADC/actions/workflows/jsoncheck.yml )
5+ [ ![ GitHub issues] ( https://img.shields.io/github/issues/RobTillaart/MCP_ADC.svg )] ( https://github.com/RobTillaart/MCP_ADC/issues )
6+
57[ ![ License: MIT] ( https://img.shields.io/badge/license-MIT-green.svg )] ( https://github.com/RobTillaart/MCP_ADC/blob/master/LICENSE )
68[ ![ GitHub release] ( https://img.shields.io/github/release/RobTillaart/MCP_ADC.svg?maxAge=3600 )] ( https://github.com/RobTillaart/MCP_ADC/releases )
9+ [ ![ PlatformIO Registry] ( https://badges.registry.platformio.org/packages/robtillaart/library/MCP_ADC.svg )] ( https://registry.platformio.org/libraries/robtillaart/MCP_ADC )
710
811
912# MCP_ADC
1013
11- Arduino library for MCP3002 MCP3004 MCP3008 MCP3201 MCP3202 MCP3204 MCP3208 and compatibles.
14+ Arduino library for MCP3001 MCP3002 MCP3004 MCP3008 MCP3201 MCP3202 MCP3204 MCP3208 and compatibles.
1215
1316
1417## Description
@@ -19,10 +22,11 @@ The chips are communicates with SPI and support both hardware SPI or optional so
1922
2023| type | bits | chan | notes |
2124| :----------| :------:| :------:| :--------|
25+ | MCP3001 | 10 | 1 | not tested yet.
2226| MCP3002 | 10 | 2 |
2327| MCP3004 | 10 | 4 |
2428| MCP3008 | 10 | 8 |
25- | MCP3201 | 12 | 1 | not tested yet.
29+ | MCP3201 | 12 | 1 | test, see # 13
2630| MCP3202 | 12 | 2 |
2731| MCP3204 | 12 | 4 |
2832| MCP3208 | 12 | 8 |
@@ -39,17 +43,29 @@ Build into the library is a delta mode which is a software enhanced differential
3943This delta mode can return negative values too.
4044
4145
46+ #### Related
47+
48+ - https://gammon.com.au/adc tutorial about ADC's (UNO specific)
49+ - https://github.com/RobTillaart/ADS1x15 (12 & 16 bit ADC, I2C, slow)
50+ - https://github.com/RobTillaart/PCF8591 (8 bit ADC + 1 bit DAC)
51+
52+
53+ - https://github.com/RobTillaart/MCP_DAC
54+
55+
56+
4257## Interface
4358
4459``` cpp
4560#include " MCP_ADC.h"
4661```
4762
48- #### Base
63+ #### Constructors
4964
5065If the pins are not set in the constructor, the class will automatically
5166use the hardware SPI, otherwise it will use software SPI.
5267
68+ - ** MCP3001(uint8_t dataIn, uint8_t dataOut, uint8_t clock)** constructor 10 bit ADC 1 channel.
5369- ** MCP3002(uint8_t dataIn, uint8_t dataOut, uint8_t clock)** constructor 10 bit ADC 2 channel.
5470- ** MCP3004(uint8_t dataIn, uint8_t dataOut, uint8_t clock)** constructor 10 bit ADC 4 channel.
5571- ** MCP3008(uint8_t dataIn, uint8_t dataOut, uint8_t clock)** constructor 10 bit ADC 8 channel.
@@ -59,8 +75,12 @@ use the hardware SPI, otherwise it will use software SPI.
5975- ** MCP3208(uint8_t dataIn, uint8_t dataOut, uint8_t clock)** constructor 12 bit ADC 8 channel.
6076- ** void begin(uint8_t select)** set select pin.
6177- ** uint8_t channels()** returns the number of channels.
62- - ** int16_t maxValue()** returns maxReading of adc, e.g. 1023.
78+ - ** int16_t maxValue()** returns maxReading of ADC, typical 1023 or 4095 .
6379This makes it easy to calculate relative measurements.
80+
81+
82+ #### Base
83+
6484- ** int16_t analogRead(uint8_t channel)** reads the value of a single channel.
6585- ** void analogReadMultiple(uint8_t channels[ ] , uint8_t numChannels, int16_t readings[ ] )**
6686reads multiple channels in one call. See section below.
@@ -87,6 +107,8 @@ of the ADC first to get optimal speed.
87107| 6 | 6 | 7 | 3x08 |
88108| 7 | 7 | 6 | 3x08 |
89109
110+ Note: the MCP3x01 are not included in this table, not investigated yet.
111+
90112
91113### Debug
92114
@@ -108,8 +130,10 @@ BEFORE the **begin()** function.
108130#### setGPIOpins() experimental
109131
110132- ** void setGPIOpins(uint8_t clk, uint8_t miso, uint8_t mosi, uint8_t select)**
111- overrule GPIO pins of ESP32 for hardware SPI. needs to be called AFTER the ** begin()** function.
133+ overrule GPIO pins of ESP32 for hardware SPI.
134+ This function needs to be called AFTER the ** begin()** function.
112135
136+ in code:
113137``` cpp
114138void setup ()
115139{
@@ -165,16 +189,15 @@ Finally **analogReadMultiple()** can be used to read only one channel too
165189by using numChannels = 1.
166190
167191
168- ## MCP3201 experimental
169-
170- Since 0.2.0 code for the MCP3201 has been added however this 12 bit single
171- channel device has not been tested yet.
192+ ## MCP3001, MCP3201 experimental
172193
173- As the SPI transfer looked quite a bit like the MCP3202 it is expected to work
174- but the proof is in the hardware test.
194+ Since 0.2.0 code for the MCP3201 has been added.
195+ The first tests are done (see #13 ) which showed that the 0.2.0 implementation
196+ was not correct.
197+ This has been fixed in the 0.2.1 version.
175198
176- Note that not all function calls make sense for the MCP3201 as this device only
177- has one channel. So use the library carefully.
199+ Note that not all function calls make sense for the MCP3201 and MCP3001 as these
200+ devices only have one channel. So use the library carefully.
178201
179202Feedback is as always welcome.
180203
@@ -202,3 +225,12 @@ Feedback is as always welcome.
202225 it actually does float mapping. As it implies the same mapping for all it might
203226 not be that useful => check multiMap library.
204227
228+
229+ ## Support
230+
231+ If you appreciate my libraries, you can support the development and maintenance.
232+ Improve the quality of the libraries by providing issues and Pull Requests, or
233+ donate through PayPal or GitHub sponsors.
234+
235+ Thank you,
236+
0 commit comments