Electronic – Magic number in ADC Pi code

adcpythonraspberry pi

Im trying to measure temperature using PT100. Im using ADC Pi board for that. ADC Pi uses MCP3424(pdf datasheet) A/D converters, and in datasheet I found how to calculate voltage – it is pretty simple –

Input Voltage =  (Output Code) * LSB/PGA

So i made a simple app which would get the output code, calculate voltage, and from that voltage calculate resistance. But the result was not right. So I searched the sample codes and found out that the calculation is a little bit different –

voltage = float(
            (raw * (self.__lsb / self.__pga)) * 2.448579823702253) 

I was not able to find out what the number 2.448579823702253 means… I assume it has something to do with other parts on the board, but i dont really understand electronics so good.

Can someone explain what exactly does it mean?

Best Answer

According to the schematic, there is a 10k--6.8k resistor divider in the circuit.

6.8k / (6.8k + 10k) = .4047619 1/.4047619 = 2.470588

Another place to look might be:

__lsb = float(0.0000078125) # default lsb value for 18 bit 7.8125e-6 * 2^18 = 2.048 // full-scale value? 5V / 2.048 = 2.441406

Or maybe some combination of those things.

Sorry I don't have time to analyze the whole datasheet, but both of those numbers are close to your magic number.

I encourage you to work through it step by step and try to get it figured out fully -- to the point where your results match within a few mV. There is going to be a right answer, and it will help if you keep track of your units (mV, LSBs, etc)

You can learn a lot about how digital systems talk to the real world!