Using external ADC converter with emonPi

Hi everyone,

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?

https://reference.digilentinc.com/reference/pmod/pmodad5/start#example_projects

Many thanks.

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.)

Thanks Robert for your reply.

I changed ADC_BITS for 10 to 24 in EmonLib.h but I am not getting any value.

image

Serial monitor results with 24 bit;

image

Serial monitor results with 10 bit;

image

The reference voltage of PMOD AD5 is same as emonTxV3 of 3.3V.

thanks

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.