Measuring Temperature and Resistance on the Auber Instruments RTD using the ADS1247 and Arduino

Just wanted to see if I could get some real readings from the prototype design that I’ll use in the Arduino / Silvia Duetto Project. It’s alive!

I should say that I’m using the Callendar-Van Dusen equation and not a linear approximation to estimate temperature. The A2DResRatio value must be set and calculated as appropriate given the RREF, RBIAS and PGA setting used with the ADS1247.

For best results, view this in HD and with fullscreen!

Code:

#include <SPI.h>

//A2D Values
const double A2DConstA = 3.9083E-3;
const double A2DConstB = -5.775E-7;
const double A2DResRatio = 5.587936114E-6;
const double A2DResOffset = 150;

unsigned long A2DVal = 0x0;

void setup()
{
//A2D Setup
//Turn on SPI Bus
SPI.setClockDivider(SPI_CLOCK_DIV16);
SPI.setDataMode(0x04);
delay(2000);
SPI.begin();
SPI.transfer(0x06); //Reset
delay(3);
SPI.transfer(0x16); //SDATAC
SPI.transfer(0x4B); //Set IDAC1 Register (0Bh) Write 01h - Output reference current on ANIN0,1
SPI.transfer(0x00);
SPI.transfer(0x01);
SPI.transfer(0x4A); //Set IDAC0 Register (0Ah) Write 07h - Select 1.5mA reference current for RTD
SPI.transfer(0x00);
SPI.transfer(0x07);
SPI.transfer(0x43); //Set SYS0 Register (03h) Write 52h - PGA:32, Sample at 20sps
SPI.transfer(0x00);
SPI.transfer(0x52);
SPI.transfer(0x42); //Set MUX1 Register (02h) Write 30h - Select internal reference always on, internal ref connected to REF0 pins. Use 33h if wanting an on chip temp read.
SPI.transfer(0x00);
SPI.transfer(0x30);
SPI.transfer(0x40); //Set MUX0 Register (00h) Write 01h
SPI.transfer(0x00);
SPI.transfer(0x08);

//Enable Serial
Serial.begin(115200);
}

void loop()
{
//Reset A2D Storage Value
A2DVal = 0x0;

SPI.transfer(0x12); //Issue RDATA
A2DVal |= SPI.transfer(0xFF);
A2DVal <<= 8;
A2DVal |= SPI.transfer(0xFF);
A2DVal <<= 8;
A2DVal |= SPI.transfer(0xFF);

Serial.println(DtoT(A2DtoD(A2DVal)),2);

delay(1000);
}

double A2DtoD (long A2D)
{
if (A2D & 0x800000) {A2D |= ~0xFFFFFF;}
return A2D;
}

double DtoT(double A2D)
{
return -1 * ( A2DConstA / ( 2 * A2DConstB ) - sqrt( 25 * A2DConstA * A2DConstA + A2DConstB * ( A2D * A2DResRatio + A2DResOffset ) - 100 * A2DConstB ) / ( 10 * A2DConstB ) );
}

double DtoR(double A2D)
{
return A2D*A2DResRatio+A2DResOffset;
}

2 Replies to “Measuring Temperature and Resistance on the Auber Instruments RTD using the ADS1247 and Arduino”

  1. Hey Josh,
    I could probably answer my own question if i were patient enough to wait till i got the chip and started experimenting…. but I’m not. I’ve read through the data sheet and the example you based your setup on, and i pretty much follow all the math but I’m stuck on how you determined your A2DResRatio and A2DResOffset. Also i read there from the data sheet there are several offset related registers in the chip which can be used, is your offset related to one of them and you just decided to do in-software adjustment?

    1. Hey!

      Sorry about the delay in getting back to you – for some reason, I wasn’t receiving any sort of notifications on the blog!

      The Resistor Ratio is basically a determination of what each lowest significant bit (LSB) equates to if you were to take the full voltage spectrum that the ADC will experience and divide it by (2^23 – 1) gradations. Based on the topology that I use in my circuit, the value can be calculated as follows:

      ( (Rbias * 2 * Iidac) / ( 2 ^ 23 - 1) ) / ( Iidac * PGA )

      Where Rbias is the Bias resistance that I use to generate the voltage drop across the positive and negative pins – in this case, it is 750 ohms, and Iidac is the total IDAC current in Amperes that the ADC will generate across the bias resistor. PGA is the current PGA setting – in this case, 32.

      The Rbias was selected so that the changes in voltage that my PT100 RTD, when multiplied by 32 (the PGA setting) would generate as close to a full range as possible.

      The registers on board are specific for certain features that I take advantage of: IDAC, PGA, single shot reads, etc.

      I hope that helps!

Leave a Reply