# Magic number in ADC Pi code

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?

## 1 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!

• Those are good finds. :) – bitsmack Apr 3 '15 at 17:53
• So they took an 18 bit DAC with an internal 0.05% tolerance Vref, and put a voltage divider in front of it with no specified tolerance or temperature coefficient? That is just plain crazy. The accuracy of the ADC Pi board is now entirely trapped in the quality of R1-R8 and R13-R20 which from significant digits in the values listed could be just 5% resistors or worse. – RBerteig Apr 3 '15 at 20:32
• Correct as usual, King Friday..err @RBerteig – Daniel Apr 6 '15 at 22:44