Electronic – ExternalDifferential ADC Values for PIC

adccdifferentialembeddedpic

I have a temperature sensor design that I'm using as a reference. It takes 2 RTD sensors and reads their values with a Dual Channel 16-bit Differential ADC. The ADC interfaces through the SPI bus.

RTD Sensor Sch

I know for a general ADC you can take the formula:

Voltage on Pin (in mV) = [(ADC Value) * (System Voltage in mV)]/(Max ADC Value)

I'm just not sure how it directly applies to a differential ADC

Here is my reference code (applicable to only one of the channels):

//--------------------------------------------------------------
// Temperature in degrees C
//
// Platinum (3850 ppm/K) RTD sensor
// 0 to 850 degrees C, Rt = R0(1 + A*t + B*t^2)
//   Rt = resistance at temperature (degrees C)
//   R0 = is resistance at 0 degrees C, which is 1,000 ohms
//   A  = 3.9083 * 10^-3
//   B  = -5.775 * 10^-7
//
//   (R0 * B)t^2 + (R0 * A)t + (R0 - Rt) = 0
//
//   Quadradic Equation: ax^2 + bx + c = 0
//     x = (-b +/- SQRT(b^2 - 4ac)) / 2a
//
// therefore:
//       (-(R0 * A) +/- SQRT((R0 * A)^2 - (4 * (R0 * B) * (R0 - Rt))
//   t = -----------------------------------------------------------
//                           2 * (R0 * B)
//
//       (-3.9083 +/- SQRT(15.2748 - ((-2.3104 * 10^-3) * (1,000 - Rt)))
//     = ------------------------------------------------------------------
//                             -1.1552 * 10^-3
{   float Vr, Rt;
    Vr = ((ADC_Meas * 1.25) / 32768.0) + 2.5;
    Rt = (1000.0 * Vr) / (5.0 - Vr);
    t = ((-3.9083) + sqrt(15.2748 - (-0.0023104) * (1000.0 - Rt))) / (-0.0011552);
}
//--------------------------------------------------------------

What I'm trying to understand is how the two formulas for the Vr and Rt were devised?

Also I am still a little bit confused about how the differential ADC works.

I believe in a typical ADC we give the REF+ and REF- voltages and the resulting reading for a given channel is the ratio of how close it is to REF+ starting from REF-.

For example for a regular 16-bit adc a reading of 0 would mean our input is 0 (or equal to REF-) and a reading of 65536 would mean our channel is equal to REF+.

I suppose what I'm confused about is how a differential ADC relates to the standard ADC. based on the standard ADC example I would think that the input value must stay inside the REF-/+ values but from the example circuit I have for a differential ADC it seems that this is not necessarly the case. So how do I know what the ADC is tied to and how to associate it with the REF values?

Best Answer

For Vr, the formula is based on the information in the datasheet. In the datasheet, it says the differential range will be from -0.5 * Vref to 0.5 * Vref. Vref in your schematic is 2.5V, and both channels - pin is at 2.5V, so the range is from 1.25V to 3.75V, which will be interpreted as -1.25V to +1.25V in the readings (it outputs a signed 16-bit integer format)

The 0°C point is 2.5V, so 2.5V to 3.75V, is the positive half of the range, and 1.25V to 2.5V for negative temperatures. The ADC sees 2.5V as 0V though, hence the use of +1.25V in the Vr formula, and 32678 (i.e. signed 16-bit integer rather than 65536 for full unsigned 16-bit) and we add 2.5V on to get the actual voltage (since the ADC's zero point is at 2.5V)

So for example, if we read 0x661E (26142) from the ADC, we can use the formula:

\$ \dfrac{26142 \cdot 1.25V}{32678} + 2.5V = 1V + 2.5V = 3.5V \$

For Rt, it's just a formula to work out the resistance based on the voltage divider the sensor resistance forms with the 1kΩ resistor. It works by comparing the ratio of voltages across each part of the divider (the fixed 1kΩ and the PT sensor)
From the PT formula, we know R0 is 1kΩ, so at 0°C the sensor will be this resistance, and because we effectively have a voltage divider of 2 1kΩ resistors with 5V at the top, the voltage in the middle should be 2.5V, so the formula should give us 1000 at 2.5V.
Say we had 3V for Vr, we would expect a resistance reading of 1.5kΩ (1.5k is 3/5ths and 1k is 2/5ths of 5V),

If we plug 3V into the formula to check, we should get the predicted result:

\$ \dfrac{3V \cdot 1000}{5V - 3V} = 1.5k\Omega \$