I have a confusion here ..Let say my ADDR=0
then getvalue(0) and getvalue(1) means what? I mean what it will read actually?
AD7367 AD(5, 6, 7, 8, 9, 10);
When connecting this ADC to an Arduino Mega, I wanted to check if there are any specific changes needed in the pin configuration. Since the Arduino Mega has dedicated MOSI/MISO pins for SPI communication, do I need to adjust these in the class instantiation or can I use any digital pins for SPI?
when ADDR == 0
read()
samples ADC-a1 and ADC-b1 and stores these values in (an array of) two internal variables.
getValue(0)
returns the value from ADC-a1
getvalue(1)
returns the value from ADC-b1
when ADDR == 1
read()
samples ADC-a2 and ADC-b2 and stores these values in (an array of) two internal variables.
getValue(0)
returns the value from ADC-a2
getvalue(1)
returns the value from ADC-b2
If you have a proposal for a more intuitive name instead of getValue()
let me know.
The AD7367 device c.q. this library does not use SPI but a very SPI alike protocol.
There exists a QSPI (quad-SPI) protocol to sample up to 4 "MISO" lines in parallel.
This is mostly used to clock out a byte (8 bits) as two nibbles (4 bits).
In theory this QSPI could be used to sample the two data channels of the AD7367, ignoring 2 of the 4 "MISO" channels.
In practice this is inefficient and more important I have never seen a working QSPI in the Arduino eco system.
So what I implemented for the AD7367 is a software (bit bang) solution which might be called a Dual-SPI or DSPI to read the two "MISO" lines in parallel.
Having studied the datasheet a bit further.
According to the datasheet it is possible to read both ADC's over one "MISO" line thus with standard SPI.
After clocking out the ADC-a1, if one continues clocking the data from the other ADC-b1 comes over the same line. Drawback is that the clocking takes twice as long and one needs some bit-manipulation to split the data. Effectively one looses about 50% of the performance. And that "parallel" performance is imho the strength of this AD7367.
Configuration wise it is easier to have two single ADC's side by side if performance is not a requirement. Note the library does not implement this single SPI feature.
name is good .. but my suggestion is if possible give some description on the function . So that we can easily understand the function
1.So do i need to connect the output data pin of ADC with the MISO pin of the Arduino mega?
2.Or can I proceed with any digital pin of mega for data0, data1?
3. Can you explain the pin connection of ADC with arduino Mega based on any of the example code?
There is a short description in the readme.md
- int read() synchronous call to make a measurement from both channels.
... - int getValue(uint8_t channel) get the last measurement of channel 0 or 1.
Multiple calls to getValue() will result in the same value until new data
is read, sync or async.
Can you propose the text you would like to see?
- you might do that, free choice of non-used IO pins.
- yes, free choice of non-used IO pins.
- the pins in the example can be adjusted to your choice of free non-used pins.
I think here mentioning the parameter as channel , but better to give it as adc type or something like that because as you mentioned earlier:
when ADDR == 0
read()
samples ADC-a1 and ADC-b1 and stores these values in (an array of) two internal variables.
getValue(0)
returns the value from ADC-a1
getvalue(1)
returns the value from ADC-b1
when ADDR == 1
read()
samples ADC-a2 and ADC-b2 and stores these values in (an array of) two internal variables.
getValue(0)
returns the value from ADC-a2
getvalue(1)
returns the value from ADC-b2
here the arguments 0,1 represents the type of ADC (0: ADC-A, 1:ADC-B) but the function definition it is given like :
int getValue(uint8_t channel); // channel = 0 or 1
makes little confusion
okay, i will try
Would function names getLastADCA() and getLastADCB() be more clear?
update
So instead of a parameterized function you get two?
yes, that will make the function more specific
yes, that will make the function more specific
OK, that is a minor change, I will update the API in the develop branch.
Develop branch updated, all examples including new ones compile
status 0.1.1 vs 0.1.0
- add getLastADCA() and getLastADCB()
- obsolete getValue()
- updated examples (with above change).
- add support for ADDR pin
- add support for REFSEL pin
- add examples
- update readme.md
Please test with your hardware and post results
great work .... once i finish the hardware i will check and let you know
Configuration wise it is easier to have two single ADC's side by side if performance is not a requirement. Note the library does not implement this single SPI feature.
- what this actually means?
2.if I have only single input how to check that?
3.is it difficult to include the the single spi feature?
-
It means that the library does not support a standard SPI interface, neither hardware nor software SPI.
-
Read both channels in parallel and ignore the one you do not want.
-
For me it is probably not difficult to include, but it will take several days again as it would include rethinking the interface again, dive into protocol details, testing, adjust examples etc. It is not on my planning as this library already took many hours
actually like this the hardware connection is..
- So can i use the library directly to measure the input analog signal?
(I am using mega to control the ADC. and i have two inputs one is varying between +-10 and other is positive only up to +10v )
That is exactly what you should verify with the library as I have no hardware to verify it.