leollo98 / AD7606

AD7606 library for Arduino framework
MIT License
12 stars 2 forks source link

Analog input range correction. #1

Open anzishi-mm opened 1 year ago

anzishi-mm commented 1 year ago

Thanks for the library ! It really helps. I found a small point that “The function setRange(bool) can be used to set the limits to 5V (+/- 2.5V) with false or 10V (+/- 5V) with true.” According to the datasheet the analog input range is +/- 5V or +/- 10V .

leollo98 commented 1 year ago

This was a problem that I found while testing. Maybe I got a faulty silicon, but the maximum reading (0x7FFF) with only 3v when false, and a valid +/- 5V (4CCC) for true, considering that all numbers are on 2's complement.

anzishi-mm commented 1 year ago

I tested my AD7606 yesterday. And I found this problem is from the code not hardware. In the data sheet of AD7606, we can find the description:

"The falling edge of CS takes the bus out of three-state and clocks out the MSB of the 16-bit conversion result. This MSB is valid on the first falling edge of the SCLK after the CS falling edge. The subsequent 15 data bits are clocked out of the AD7606/ AD7606-6/AD7606-4 on the SCLK rising edge. Data is valid on the SCLK falling edge. To access each conversion result, 16 clock cycles must be provided to the AD7606/AD7606-6/AD7606-4."

So in the read function, maybe DB15 is missed.

leollo98 commented 7 months ago

Sorry for the wait, I corrected some problems and bugs on the "Dev" branch, if it's possible you can test to se if it's correct now.