I am working on a project to increase ADC resolution of emonPi. So, I chose the PMOD AD5, a 24 bit ADC converter which is embedded with Analog Devices AD7193 chip. I successfully connected the AD5 to emonpi through SPI interface and now I am wondering, how would I modify 10 bit EmonLib.h for 24 bit ADC converter?
I think as long as ADC_BITS is defined correctly, that’s the only change that relates to the ADC resolution.
Of course, you won’t have the ability for emonLib to calibrate the supply/reference voltage against an internal reference, so you’ll need to define emonTxV3 or add another similar conditional to ensure the correct value for SupplyVoltage (also the analogue reference) is used.
(Don’t confuse the number 1024 used in the filter time constant with the number of steps in the 10-bit ADC of the Atmel 328P.)
Is there an overflow somewhere? “inf” is indicative of a divide-by-zero error. You need to start looking at the sizes of the variables used in the calculations and see how the values fit. You might for example need to change integers to longs.