This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADS1248 Data Conversion Issue

Other Parts Discussed in Thread: ADS1248

Hi,

I'm attempting at using the ADS1248 with an Arduino to measure the temperature of a 3 Wire RTD. I've set up my circuit as per the Figures 110 and 114 in the data sheet with the only major change being that both AVDD and DVDD are connected to 5V supply as the SPI signals are being generated by the UNO (which are at 5V). 

I am able to successfully write and read from the registers and have followed the setting of the registers exactly as per the Table 49 of the data sheet. 

Additionally, I am using the pseudo code as a reference to write my code and have more or less followed the same. 

Here is my problem, though:

I am able to measure the RTD resistance and actually using the CVD equation even get the temperature. However, when I move the RTD sensor toward a heat source, the resistance and the temperature does not change and then suddenly jumps - the jump is from 22 to 31 deg C. When removing it away from the heat source, the temperature remains high and then once again jumps back to the SAME 22 degC.

The code I'm using for the loop function of my Arduino looks something like this:

void loop() 
{ 
      if(digitalRead(DRDY)==LOW)
      {
           Serial.println("DRDY was LOW");
           Data_Read = 0x0;
           
           Serial.println("Data Found. \nSetting CS pin LOW");
           digitalWrite(CS,LOW);
           delay(0.5);

           Serial.println("\nIssuing the RDATA command");
           SPI.begin();
           SPI.transfer(0x12);


           Data_Read |= SPI.transfer(0xFF); //Write NOP, Read First Byte and Mask to Data_Read
           Data_Read <<= 8; //Left Bit-Shift Data_Read by 8 bits
           Data_Read |= SPI.transfer(0xFF); //Write NOP, Read Second Byte and Mask to Data_Read
           Data_Read <<= 8;
           Data_Read |= SPI.transfer(0xFF); //Write NOP, Read Third Byte and Mask to Data_Read 
           Data_Read <<= 8;


           Data = ((double)Data_Read/(double)16777216)*(double)820;

           
           Temp_Data = -1 * ( A2DConstA / ( 2 * A2DConstB ) - sqrt( 25 * A2DConstA * A2DConstA + A2DConstB * ( Data ) - 100 * A2DConstB ) / ( 10 * A2DConstB ) );

           Serial.println(Temp_Data,20);

           digitalWrite(CS,HIGH); 
}

digitalWrite(CS,LOW);

}

This is something I found weird while checking the individual 8 bits being read from the 24 bit data, if the variable 'Data_Read' was not initialized and set to 0x0, I was actually able to read the resistance and the temperature (albeit with the random jumps from 22 to 31) but on the suggestion of someone I decided to initialize it to 0x0 and noticed that after doing that the first and second read of the 8 bits of data, there was nothing but 0s. The conversion of that data was not at all close to the temperature.

In order to take care of this, I decided to clock in two extra NOP commands to the ADS1248 before reading the data just to be able to get my information but I know this is not correct as it is now 40 clock cycles which is wrong. 

Apart from this, I also tried using a fixed resistance of 141ohms (3x47 ohm resistors in series) to measure the resistance and the result was a pretty accurate 140.9 ohms so I believe I am somewhere on the right path but can't figure out what I'm doing wrong at this time. I additionally measured the variation of the resistance of the RTD with varying temperatures and observed it changing but didn't see the change being recorded by my setup.

I apologize for the overload of information and the fact that this might be all over the place. Please let me know if you need any additional information from my side. I will admit I'm a bit of a juvenile in this field but would really appreciate your help in getting this sorted out. 

Joe

  • Joe,


    I'm not sure where the problem is, but I can suggest some ideas for debugging.

    First, can you post a length of conversion results? It might help to just get the 24 bit values first (converted to decimal is ok). It's easier not to have to deal with the conversion. I was curious about the nature of the problem, if you were getting exactly the same value out of the ADC each time, or if the value varied a little.

    I would also get a scope shot of the SPI lines (DIN, DOUT, SCLK, /CS), just to make sure that you're reading back the correct 24 bit data. A logic analyzer would be ideal (and you could grab /DRDY as well). You shouldn't have to clock in extra NOPs to get the data and you should be able to see the correct values coming out of the ADC lines. Make sure that /CS isn't returning high with each byte transaction (/CS should remain low for the complete data transaction). Since you're able to read and write to the device, you should have figured this out, but I'm mentioning this again, just in case.

    At this point it looks more like there's a problem with the arduino code and not the device. I've got limited experience with arduino, so I may not be able to help you as easily. However, check what I've written above and it may help you to get a solution.


    Joseph Wu
  • Hi Joseph,

    OK. I've decided to include the results from both the cases - where I initialize the 24 bit 'Data Read' variable to 0x0 for each loop and one where I don't do it.

    The loop function I included is basically the function that is called repetitively called each time. A pseudo code version of the its working is very similar to that included in the Data Sheet. 

    if DRDY is low

    Initialize Data_Read = 0x0

    Set Chip Select LOW

    Issue RDATA command

    Issue NOP thrice to get the 24 bit data which is stored and left shifted 8 bits each time and ORed back into 'Data_Read'

    Get the RTD resistance stored in variable 'Data' using the formula RTD Resistance = ((24 bit code)*820)/(2^24)

    Get the Temperature using temperature = -a/2b + sqrt(25a^2 + b*RTDResistance - 100*b) where a = 3.9083E-3 and b = -5.775E-7 this is just a solution of a second order polynomial using the CVD equation where Ro = 100. 

    Set Chip Select HIGH

    Set CHIP Select LOW

    Now, when I include the initializing of Data_Read = 0x0 so that it is initialized to 0x0 whenever DRDY is determined as LOW, this is the data I get:

    24 Bit Data in Decimal:34
    Converted Resistance Value:0.00166177749633789062
    Temperature:-246.85717773437500000000
    24 Bit Data in Decimal:34
    Converted Resistance Value:0.00166177749633789062
    Temperature:-246.85717773437500000000
    24 Bit Data in Decimal:34
    Converted Resistance Value:0.00166177749633789062
    Temperature:-246.85717773437500000000
    24 Bit Data in Decimal:34
    Converted Resistance Value:0.00166177749633789062
    Temperature:-246.85717773437500000000
    24 Bit Data in Decimal:34
    Converted Resistance Value:0.00166177749633789062
    Temperature:-246.85717773437500000000
    24 Bit Data in Decimal:35
    Converted Resistance Value:0.00171065330505371093
    Temperature:-246.85693359375000000000
    24 Bit Data in Decimal:35
    Converted Resistance Value:0.00171065330505371093
    Temperature:-246.85693359375000000000
    24 Bit Data in Decimal:35
    Converted Resistance Value:0.00171065330505371093
    Temperature:-246.85693359375000000000
    24 Bit Data in Decimal:35
    Converted Resistance Value:0.00171065330505371093
    Temperature:-246.85693359375000000000
    24 Bit Data in Decimal:35
    Converted Resistance Value:0.00171065330505371093
    Temperature:-246.85693359375000000000
    24 Bit Data in Decimal:35
    Converted Resistance Value:0.00171065330505371093
    Temperature:-246.85693359375000000000
    24 Bit Data in Decimal:35
    Converted Resistance Value:0.00171065330505371093
    Temperature:-246.85693359375000000000
    24 Bit Data in Decimal:35
    Converted Resistance Value:0.00171065330505371093
    Temperature:-246.85693359375000000000
    24 Bit Data in Decimal:34
    Converted Resistance Value:0.00166177749633789062
    Temperature:-246.85717773437500000000
    24 Bit Data in Decimal:34
    Converted Resistance Value:0.00166177749633789062
    Temperature:-246.85717773437500000000
    24 Bit Data in Decimal:34
    Converted Resistance Value:0.00166177749633789062
    Temperature:-246.85717773437500000000
    24 Bit Data in Decimal:34
    Converted Resistance Value:0.00166177749633789062
    Temperature:-246.85717773437500000000
    24 Bit Data in Decimal:34
    Converted Resistance Value:0.00166177749633789062
    Temperature:-246.85717773437500000000
    24 Bit Data in Decimal:34
    Converted Resistance Value:0.00166177749633789062
    Temperature:-246.85717773437500000000
    24 Bit Data in Decimal:34
    Converted Resistance Value:0.00166177749633789062
    Temperature:-246.85717773437500000000

    But when I comment out that portion which means that each time the DRDY is determined as LOW, the Data is directly updated over the existing Data_Read, this is the data I am getting:

    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228259
    Converted Resistance Value:108.90795898437500000000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2293795
    Converted Resistance Value:112.11108398437500000000
    Temperature:31.13134765625000000000
    24 Bit Data in Decimal:2293795
    Converted Resistance Value:112.11108398437500000000
    Temperature:31.13134765625000000000
    24 Bit Data in Decimal:2293795
    Converted Resistance Value:112.11108398437500000000
    Temperature:31.13134765625000000000
    24 Bit Data in Decimal:2293795
    Converted Resistance Value:112.11108398437500000000
    Temperature:31.13134765625000000000
    24 Bit Data in Decimal:2293795
    Converted Resistance Value:112.11108398437500000000
    Temperature:31.13134765625000000000
    24 Bit Data in Decimal:2293795
    Converted Resistance Value:112.11108398437500000000
    Temperature:31.13134765625000000000
    24 Bit Data in Decimal:2293795
    Converted Resistance Value:112.11108398437500000000
    Temperature:31.13134765625000000000
    24 Bit Data in Decimal:2293795
    Converted Resistance Value:112.11108398437500000000
    Temperature:31.13134765625000000000
    24 Bit Data in Decimal:2293795
    Converted Resistance Value:112.11108398437500000000
    Temperature:31.13134765625000000000
    24 Bit Data in Decimal:2293795
    Converted Resistance Value:112.11108398437500000000
    Temperature:31.13134765625000000000
    24 Bit Data in Decimal:2293795
    Converted Resistance Value:112.11108398437500000000
    Temperature:31.13134765625000000000
    24 Bit Data in Decimal:2293795
    Converted Resistance Value:112.11108398437500000000
    Temperature:31.13134765625000000000
    24 Bit Data in Decimal:2293795
    Converted Resistance Value:112.11108398437500000000
    Temperature:31.13134765625000000000
    24 Bit Data in Decimal:2293794
    Converted Resistance Value:112.11103820800781250000
    Temperature:31.13110351562500000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000
    24 Bit Data in Decimal:2228258
    Converted Resistance Value:108.90791320800781250000
    Temperature:22.86962890625000000000

    Now, this data is:

    a)On the surface - really good.

    b) If you look closer, you will notice that weird jump from 22.86 directly to 31.13 - I just touched the sensor with my finger but even then it took the device two readings to eventually reach the value of 31.13

    c) This is what a plot of the output looks like when I used a heater - 

    Some more heating...

    And then on removing it from the source, a steep drop:

      

    Which seems almost correct but I feel like without initializing the 'Data_Read' variable and setting it to '0x0' each time DRDY goes low, means I am ORing the last 8 bits of my current Data_Read with the first byte being read during the first 8 of the 24 clock cycles. Which would mean that this data above that seems "relatively" correct actually consists of:

    First Byte - Third Byte of the last read, ( I say this because the first byte being read is are all zeros and ORing anything to it, would give us the existing Byte which would be the third byte of the last read) 

    Second Byte - Zeros

    Third Byte - The "new" last byte of data being read.

    This just makes the data corrupted in theory or at least according to my understanding but at the same time, it looks so good, I don't want to believe its wrong but also the sudden jump in data is something that concerns me here. Is this OK? I was hoping to have a finer resolution in the determined data. :/

    Now the SPI waveforms. Unfortunately, I do not have a logic analyzer but have included the oscilloscope readings:

    DOUT and CLK:

    DIN and CLK

    CS and CLK:

    My concerns are about my conversion of data also I'm concerned about the resolution of the values that I'm getting - the random jumping doesn't seem right and the delay is making me wonder if I need to have any additional commands  - Just to be sure, I'm going to include my setup code as well here. I've commented most of my actions which I hope helps you decipher what I'm actually doing:

    #include <SPI.h>
    #include <SoftwareSerial.h>
    
    SoftwareSerial chat(5, 6); // RX, TX
    
    const int CS = 10; // Chip Select
    const int START = 9; // Start
    const int RESET = 8; // Reset
    const int DRDY = 7; // Drdy
    unsigned long Data_Read=0x0;
    double Data=0;
    double Temp_Data=0;
    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;
    int text;
    
    void setup() 
    {
    
    delay(500);
    //Enable Serial
    Serial.begin(115200);
    chat.begin(115200);
    delay(1000); // delay 1s to stabilize serial ports
    //Serial.println("Beginning Serial Communication");
    
    // Bluetooth Setup
    chat.print("$$$"); //Enter Command Mode
    delay(1000);
    chat.print("SF,1\n"); //Master
    delay(1000);
    chat.print("R,1\n");
    delay(1000);
    chat.print("$$$"); //Enter Command Mode
    delay(1000);
    chat.print("SM,1\n"); //Master
    delay(1000);
    chat.print("SA,0\n"); //Set authentication off
    delay(1000);
    chat.print("R,1\n");
    delay(1000);
    chat.print("$$$"); //Enter Command Mode
    delay(1000);
    chat.print("C,0006667CA0F8\n");
    delay(1000);
    
    //Begin setup
    chat.println("Beginning ADS1248 Setup");
    delay(1000);
    
    //Enabling the arduino pins for input and output
    chat.println("Setting CS,START,RESET and DRDY pins");  
    pinMode(CS, OUTPUT);
    pinMode(START, OUTPUT);
    pinMode(RESET, OUTPUT);
    pinMode(DRDY, INPUT);
      
    //SPI Setup for clock and Data Mode
    chat.println("Setup for SPI Clock and Data Mode");
    SPI.setClockDivider(SPI_CLOCK_DIV16); //1MHz Bus Speed
    SPI.setDataMode(0x04); //SPI_MODE1
    
    delay(2000); //Give you time to open up the Serial monitor as it will restart the Arduino but not ADS1247
    
    // Beginning SPI Communication
    chat.println("Beginning Serial Communication");
    SPI.begin(); //Turn on the SPI Bus
    
    //Setting START HIGH
    chat.println("Setting START High");
    digitalWrite(START, HIGH);
    delay(500);
    
    //Setting RESET HIGH
    chat.println("Setting RESET High");
    digitalWrite(RESET, HIGH);
    
    // Enabling Chip Select 
    chat.println("Setting CS LOW to enable Chip Select");
    digitalWrite(CS, LOW);
    
    delay(500);
    
    // Resetting the ADS1248 to make sure changes are effective
    chat.println("Reset to ensure changes are effective");
    SPI.transfer(0x06); //Reset the ADS1248
    delay(2); //Minimum 0.6ms required for Reset to finish.
    
    // Issuing SDATAC to stop continuous conversions
    chat.println("SDATAC to stop conversions");
    SPI.transfer(0x16); //Issue SDATAC
    
    chat.println("\n\nENTERING REGISTER SETUP MODE\n\n");
    //----------------------------------------------------------
    // REGISTER (00)H - MUX0
    chat.print("Register 00: ");
    // Setting the MUX0 Register (00)h to (0A)h to enable AIN1 and AIN2 as analog inputs
    SPI.transfer(0x40); //Set MUX0 Register (00h) Write (0A)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x0A);
    
    delay(50);
    
    //Reading Register (00)h
    SPI.transfer(0x20); //Read Register 0x0
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    Serial.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (01)H - BIAS VOLTAGE REGISTER
    chat.print("\nRegister 01: ");
    // Setting the BVR Register (01)h to (01)h
    SPI.transfer(0x41); //Set BVR Register (01h) Write (00)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x00);
    
    delay(50);
    
    //Reading Register (01)h
    SPI.transfer(0x21); //Read Register 0x1
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (02)H - MUX1 REGISTER
    chat.print("\nRegister 02: ");
    // Setting the MUX1 Register (02)h to (20)h to setup the internal reference and to set up REFP0 and REFN0 as inputs
    SPI.transfer(0x42); //Set MUX1 Register (02h) Write (20)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x20);
    
    delay(50);
    
    //Reading Register (02)h
    SPI.transfer(0x22); //Read Register 0x2
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (03)H - SYS0 REGISTER
    chat.print("\nRegister 03: ");
    // Setting the SYS0 Register (03)h to (22)h
    SPI.transfer(0x43); //Set SYS0 Register (03h) Write (22)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x22);
    
    delay(50);
    
    //Reading Register (03)h
    SPI.transfer(0x23); //Read Register 0x3
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (04)H - OFC REGISTER
    chat.print("\nRegister 04: ");
    // Setting the OFC Register (04)h to (00)h
    SPI.transfer(0x44); //Set OFC Register (04h) Write (00)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x00);
    
    delay(50);
    
    //Reading Register (04)h
    SPI.transfer(0x24); //Read Register 0x3
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (05)H - OFC REGISTER
    chat.print("\nRegister 05: ");
    // Setting the OFC Register (05)h to (00)h
    SPI.transfer(0x45); //Set OFC Register (05h) Write (00)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x00);
    
    delay(50);
    
    //Reading Register (05)h
    SPI.transfer(0x25); //Read Register 0x3
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (06)H - OFC REGISTER
    chat.print("\nRegister 06: ");
    // Setting the OFC Register (06)h to (00)h
    SPI.transfer(0x46); //Set OFC Register (06h) Write (00)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x00);
    
    delay(50);
    
    //Reading Register (06)h
    SPI.transfer(0x26); //Read Register 0x3
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (07)H - FSC REGISTER
    chat.print("\nRegister 07: ");
    // Setting the FSC Register (07)h to (40)h
    SPI.transfer(0x47); //Set FSC Register (07h) Write (40)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x40);
    
    delay(50);
    
    //Reading Register (07)h
    SPI.transfer(0x27); //Read Register 0x3
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (08)H - FSC REGISTER
    chat.print("\nRegister 08: ");
    // Setting the FSC Register (08)h to (00)h
    SPI.transfer(0x48); //Set OFC Register (08h) Write (00)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x00);
    
    delay(50);
    
    //Reading Register (08)h
    SPI.transfer(0x28); //Read Register 0x3
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (09)H - FSC REGISTER
    chat.print("\nRegister 09: ");
    // Setting the FSC Register (09)h to (00)h
    SPI.transfer(0x49); //Set OFC Register (09h) Write (00)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x00);
    
    delay(50);
    
    //Reading Register (09)h
    SPI.transfer(0x29); //Read Register 0x3
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (0A)H - IDAC0 REGISTER
    chat.print("\nRegister 0A: ");
    // Setting the IDAC0 Register (0A)h to (06)h
    SPI.transfer(0x4A); //Set IDAC0 Register (0A)h Write (06)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x06);
    
    delay(50);
    
    //Reading Register (2A)h
    SPI.transfer(0x2A); //Read Register 0x3
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (0B)H - IDAC1 REGISTER
    chat.print("\nRegister 0B: ");
    // Setting the IDAC1 Register (0B)h to (03)h to set AIN0 and AIN3 as the current sources
    SPI.transfer(0x4B); //Set IDAC1 Register (0B)h Write (03)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x03);
    
    delay(50);
    
    //Reading Register (2B)h
    SPI.transfer(0x2B); //Read Register 0x3
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (0C)H - GPIOCFG REGISTER
    chat.print("\nRegister 0C: ");
    // Setting the GPIOCFG Register (0C)h to (00)h 
    SPI.transfer(0x4C); //Set GPIOCFG Register (0C)h Write (00)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x00);
    
    delay(50);
    
    //Reading Register (2C)h
    SPI.transfer(0x2C); //Read Register 0x3
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (0D)H - GPIODIR REGISTER
    chat.print("\nRegister 0D: ");
    // Setting the GPIODIR Register (0D)h to (00)h 
    SPI.transfer(0x4D); //Set GPIOCFG Register (0C)h Write (00)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x00);
    
    delay(50);
    
    //Reading Register (2D)h
    SPI.transfer(0x2D); //Read Register 0x3
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    // REGISTER (0E)H - GPIODAT REGISTER
    chat.print("\nRegister 0E: ");
    // Setting the GPIOCFG Register (0E)h to (00)h 
    SPI.transfer(0x4E); //Set GPIOCFG Register (0E)h Write (00)h
    SPI.transfer(0x00); //Number of bytes to be written - 1
    SPI.transfer(0x00);
    
    delay(50);
    
    //Reading Register (2E)h
    SPI.transfer(0x2E); //Read Register 0x3
    SPI.transfer(0x00); //N - 1 Bytes To Be Read
    chat.print(SPI.transfer(0xFF),HEX); 
    //----------------------------------------------------------
    
    //Sending the SYNC command to initiate ADC conversions
    chat.println("\nSYNC to begin conversions");
    SPI.transfer(0x04); //Issue SYNC
    SPI.transfer(0x04);
    delay(500);
    
    //Setting CS HIGH to reset serial interface
    chat .println("\n\n\nSetting CS HIGH to reset Serial Interface");
    digitalWrite(CS,HIGH); //Issue SYNC
    
    }

    Have I followed the right approach? Once again I apologize if this is all over the place but its kinda overwhelming when I'm right at the cusp of getting this but just feel like there's something off and I can't determine what it is.

    I hope this information should be able to help you to help me. Let me know if you need any additional data. 

  • Joe,


    I'm not absolutely sure, but it looks as if you are reading the data back faster than the ADC is putting it out. I believe that the output data register is cyclic. If you read the output data, and then read it again, while the ADC hasn't updated with a new value, it will repeat the old data. In your output data, the output code looks like it stays the exact same value for several readings which indicates that has happened.

    To be sure, you could use the oscilloscope to capture the /DRDY pin to see what the data output is, and compare that with your SCLK or DOUT values. This would show you when the reads are happening compared to the ADC data rate. What is your current output data rate set to? I would try to increase that rate to see if you can get a better timing.


    Joseph Wu
  • Hi Joseph,

    OK. So, I tried to look into your comment about the reading speed vs the conversion speed. I was wondering if there need to be any additional delays beyond those mentioned in the pseudo code? I read in the data sheet that once DRDY goes LOW, the CLK has to be held low for a minimum amount of time so that the converted result is made available in the output register? Do, I need to do something like this?

    Regarding the SPI speed, I have kept it at 1MHz. I checked the results again (now only assuming that the variable used to store the 24 bit code is initialized to 0 before each read as this would obviously be the correct one) and surprisingly noticed that there was a more fluid change of (albeit junk) values:

    A24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:141

    Converted Resistance Value:0.00689148902893066406

    Temperature:-246.84448242187500000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:95

    Converted Resistance Value:0.00464320182800292968

    Temperature:-246.85009765625000000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:149

    Converted Resistance Value:0.00728249549865722656

    Temperature:-246.84350585937500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:72

    Converted Resistance Value:0.00351905822753906250

    Temperature:-246.85253906250000000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:144

    Converted Resistance Value:0.00703811645507812500

    Temperature:-246.84423828125000000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:131

    Converted Resistance Value:0.00640273094177246093

    Temperature:-246.84594726562500000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:48

    Converted Resistance Value:0.00234603881835937500

    Temperature:-246.85522460937500000000

    24 Bit Data in Decimal:61

    Converted Resistance Value:0.00298142433166503906

    Temperature:-246.85400390625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:129

    Converted Resistance Value:0.00630497932434082031

    Temperature:-246.84594726562500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:42

    Converted Resistance Value:0.00205278396606445312

    Temperature:-246.85620117187500000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:36

    Converted Resistance Value:0.00175952911376953125

    Temperature:-246.85693359375000000000

    24 Bit Data in Decimal:103

    Converted Resistance Value:0.00503420829772949218

    Temperature:-246.84912109375000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:160

    Converted Resistance Value:0.00782012939453125000

    Temperature:-246.84228515625000000000

    24 Bit Data in Decimal:125

    Converted Resistance Value:0.00610947608947753906

    Temperature:-246.84643554687500000000

    24 Bit Data in Decimal:34

    Converted Resistance Value:0.00166177749633789062

    Temperature:-246.85717773437500000000

    These values were obtained by touching the sensor with my finger. It seemed much better than the earlier attempts where it would not budge for at least 2 reads - I'm not sure what I changed here or if it is actually any good.

    The DRDY pin vs the SCLK is shown below. I think it seems OK:

    But it was the consecutive DRDY outputs that looked a little bit off to me:

    Should they be uneven like this? Is this the cause of my problems and should I be changing something?

    Also, if these aren't the problems, could something be wrong with my hardware? I tried changing the sensor today to another PT100 of another manufacturer only to get the SAME results. :( - The SAME code output as well. Once again, I took some fixed resistors as a test case and tried to measure them using my setup and they seemed pretty accurate. This entire thing is really confusing me. Please help.

  • Also, Joseph, I'm not sure about this but I was a bit confused that the result is in 24 bits of binary twos complement format. I'm not sure but do I need to convert this into any other format before trying to get the equivalent analog value?

    Thanks so much for your help!
  • Hi Joseph,

    OK. I have a break through. I think I resolved the issue buuuuuuuuuut I'm going to need your help in verifying the change I've done to the code is OK.

    It turns out that I may have been a little too enthusiastic and set ALL of my registers to a default value or 0x0 even those that I probably didn't need such as the FSC, OFSC and GPIO registers. It turns out that commenting all of them made my problems disappear - relatively.

    This is the data I'm getting now:

    28.41601562500000000000
    28.41796875000000000000
    28.42041015625000000000
    28.42309570312500000000
    28.42211914062500000000
    28.42480468750000000000
    28.42578125000000000000
    28.43286132812500000000
    28.42895507812500000000
    28.42578125000000000000
    28.43090820312500000000
    28.43212890625000000000
    28.43383789062500000000
    28.43408203125000000000
    28.43530273437500000000
    28.43798828125000000000
    28.44140625000000000000
    28.43798828125000000000
    28.44189453125000000000
    28.44311523437500000000
    28.44409179687500000000
    28.44580078125000000000
    28.44189453125000000000
    28.44189453125000000000
    28.44580078125000000000
    28.44482421875000000000
    28.44824218750000000000
    28.45214843750000000000
    28.45214843750000000000
    28.44531250000000000000
    28.44750976562500000000
    28.45019531250000000000
    28.45312500000000000000
    28.45410156250000000000
    28.45214843750000000000
    28.45385742187500000000
    28.45410156250000000000
    28.45947265625000000000
    28.46044921875000000000
    28.45727539062500000000
    28.46093750000000000000
    28.45629882812500000000
    28.46093750000000000000
    28.46142578125000000000
    28.45703125000000000000
    29.01806640625000000000
    28.64111328125000000000
    28.89746093750000000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    29.42529296875000000000
    29.39721679687500000000
    29.39013671875000000000
    29.39111328125000000000
    29.40112304687500000000
    29.49560546875000000000
    29.58959960937500000000
    29.65942382812500000000
    29.72583007812500000000
    29.77734375000000000000
    29.81738281250000000000
    29.85424804687500000000
    29.88964843750000000000
    29.91894531250000000000
    29.94482421875000000000
    29.97778320312500000000
    30.00097656250000000000
    30.06616210937500000000
    31.28100585937500000000
    30.14575195312500000000
    30.17187500000000000000
    30.17578125000000000000
    30.19726562500000000000
    30.19799804687500000000
    30.21533203125000000000
    30.24902343750000000000
    30.25048828125000000000
    30.24731445312500000000
    30.23828125000000000000
    30.23095703125000000000
    30.23632812500000000000
    31.34765625000000000000
    30.27026367187500000000
    30.22412109375000000000
    30.22924804687500000000
    30.23925781250000000000
    30.24633789062500000000
    30.25585937500000000000
    30.25048828125000000000
    30.25756835937500000000
    30.26513671875000000000
    30.27514648437500000000
    30.28002929687500000000
    30.29833984375000000000
    30.30639648437500000000
    30.31445312500000000000
    30.32666015625000000000
    30.33129882812500000000
    30.33691406250000000000
    30.35156250000000000000
    30.35864257812500000000
    30.36303710937500000000
    30.36840820312500000000
    30.38159179687500000000
    30.38183593750000000000
    30.39501953125000000000
    30.40185546875000000000
    30.40698242187500000000
    30.41357421875000000000
    30.41918945312500000000
    30.42431640625000000000
    30.42700195312500000000
    30.43481445312500000000
    30.43823242187500000000
    30.44531250000000000000
    30.44921875000000000000
    30.45532226562500000000
    30.46411132812500000000
    30.46313476562500000000
    30.46728515625000000000
    30.47412109375000000000
    30.47607421875000000000
    30.48022460937500000000
    30.48901367187500000000
    30.49218750000000000000
    30.49194335937500000000
    30.49951171875000000000
    30.50317382812500000000
    30.50708007812500000000
    30.51123046875000000000
    30.51538085937500000000
    30.51806640625000000000
    30.52514648437500000000
    30.52734375000000000000
    30.53173828125000000000
    30.53051757812500000000
    30.53320312500000000000
    30.53857421875000000000
    30.54028320312500000000
    30.55126953125000000000
    30.54248046875000000000
    30.55541992187500000000
    30.55664062500000000000
    30.55273437500000000000
    30.55224609375000000000
    30.56054687500000000000
    30.56274414062500000000
    30.56542968750000000000
    30.56445312500000000000
    30.56835937500000000000
    30.56591796875000000000
    30.56835937500000000000
    30.57763671875000000000
    30.57739257812500000000
    30.57373046875000000000
    30.57641601562500000000
    30.58032226562500000000
    30.58251953125000000000
    30.58862304687500000000
    30.58349609375000000000
    30.58666992187500000000
    30.58789062500000000000
    30.58984375000000000000
    30.59057617187500000000
    30.59375000000000000000
    30.59667968750000000000
    30.59545898437500000000
    30.59790039062500000000
    30.60278320312500000000
    30.60571289062500000000
    30.60351562500000000000
    30.59985351562500000000
    30.60205078125000000000
    30.60742187500000000000
    30.60571289062500000000
    30.60888671875000000000
    30.60400390625000000000
    30.60693359375000000000
    30.60888671875000000000
    30.60961914062500000000
    30.61572265625000000000
    30.61474609375000000000
    30.61474609375000000000
    30.61645507812500000000
    30.61645507812500000000
    30.61962890625000000000
    30.61889648437500000000
    30.61987304687500000000
    30.61914062500000000000
    30.62304687500000000000
    30.62060546875000000000
    30.61791992187500000000
    30.62402343750000000000
    30.62304687500000000000
    30.62670898437500000000
    30.62182617187500000000
    30.62500000000000000000
    30.62255859375000000000
    30.62646484375000000000
    30.62695312500000000000
    30.62792968750000000000
    30.62475585937500000000
    30.62719726562500000000
    30.63061523437500000000
    30.65307617187500000000
    30.64184570312500000000
    30.64306640625000000000
    30.62963867187500000000
    30.62646484375000000000
    30.62695312500000000000
    30.62207031250000000000
    30.63061523437500000000
    30.63574218750000000000
    30.64355468750000000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    30.47631835937500000000
    30.40185546875000000000
    30.36352539062500000000
    30.35693359375000000000
    30.34960937500000000000
    30.34423828125000000000
    30.33935546875000000000
    30.33862304687500000000
    30.32983398437500000000
    30.32373046875000000000
    30.31445312500000000000
    30.30029296875000000000
    30.28857421875000000000
    30.28344726562500000000
    30.27001953125000000000
    30.26806640625000000000
    30.25805664062500000000
    30.27001953125000000000
    30.31225585937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000
    917.59741210937500000000

    The highlighted part is a little unsettling - even though its just temporary and the values seem to be gradually increasing afterwards I just wanted to check with you to see if this is once again a part of my code messing up or just  something due to the data acquisition part like the sensor leads not sitting well on my breadboard or something like that.

    Also, is it fine that those registers are left with their default values then? Or should I go about setting some of them. Please let me know.

    Otherwise I believe the temperature rise being recorded here is pretty decent given that it just my finger temperature being recorded here. 

  • Joe,

    I still think this is a problem in your code. What it looks like to me is that you have some sort of problem in the timing of reading data. It would helped  them to have the raw data instead of the converted values.

    In this case I would look at the  DRDY in relation to the SCLK and DOUT. Again you will need the oscilloscope or a logic analyzer. That way you can see the data coming out of the ADC directly and compare them to the raw data values.

    Since you're getting long stretches of correct data in between stretches of incorrect data I suspect that you have some sort of timing error where maybe the data read isn't completely synchronized to DRDY, and the read is interrupted by a new data. It's likely to be some sort of similar error.  Again, look at the signals on a scope, try to catch the error that way.

    Joseph Wu

  • Joe,


    I suppose it's possible to have a loose connection that's giving these errors. However I still think you should be looking at the digital signals through a scope.


    Joseph Wu
  • Hi Joseph,

    I  checked the bit data and this is what I was getting:

    Converted Resistance Value:111.18186187744140625000

    Temperature:28.73266601562500000000

    24 Bit Data in Decimal:1000101011010111000101

    Converted Resistance Value:111.18058776855468750000

    Temperature:28.72924804687500000000

    24 Bit Data in Decimal:11111111111111111111111

    Converted Resistance Value:409.99993896484375000000

    Temperature:917.59741210937500000000

    24 Bit Data in Decimal:11111111111111111111111

    Converted Resistance Value:409.99993896484375000000

    Temperature:917.59741210937500000000

    Additionally, to check if it was a possibility of a loose connection, I pulled out one of the leads of the RTD and noticed that I was able to generate the unwanted output:

    24 Bit Data in Decimal:11111111111111111111111

    Converted Resistance Value:409.99993896484375000000

    Temperature:917.59741210937500000000

    24 Bit Data in Decimal:11111111111111111111111

    Converted Resistance Value:409.99993896484375000000

    Temperature:917.59741210937500000000

    24 Bit Data in Decimal:11111111111111111111111

    Converted Resistance Value:409.99993896484375000000

    Temperature:917.59741210937500000000

    24 Bit Data in Decimal:11111111111111111111111

    Converted Resistance Value:409.99993896484375000000

    Temperature:917.59741210937500000000

    I know this doesn't rule out the possibility of something being wrong with the code but was wondering if there was a definite reason for getting an output of FFFFFF from the ADC. From my understanding this would be because the input has reached the maximum possible output of the ADC, right? which is +VREF which is VRTDxGain but that isn't possible unless there is an open circuit? I'm not sure but was just thinking about other possibilities apart from code - which I will still look into along with the outputs of the oscilloscope.

    But otherwise, thank you so much Joseph for your help!

    I do have one additional query for which I have been perusing the forums for previous answers but haven't really found any concrete solution but I'm hoping you would be able to assist me here instead of creating another question. I understand that the ADS1248 can take a total of 4 3 Wire RTD sensors. Is there any existing schematic on how to connect such an arrangement? If not, from what I've determined, I understand that I could use the inputs AIN0 to AIN7 as inputs for the four sensors and tie the third lead of the RTDs to the SAME RREF across REFP0 and REFN0.  My confusion lies in the current source arrangement. I have noted that there are two current source outputs IEXC1 and IEXC2 but if I were to connect them to the leads of each of the RTDs would it maintain the same working? I only imagine the current flowing through the RTD being measured and the RREF being different because of this.

    This is a sketch of what I would do. Is it correct?

    Or should I be activating the excitation currents for the RTD being measured? My confusion there lies in whether the filter circuit would be a hindrance.

    Once again, please let me know if I should ask a separate question for this. Thanks!

  • Joe,


    Sorry but I was out on Friday.

    The result that you are getting 11111111111111111111111 is not FFFFFFh but rather 7FFFFFh. This is the positive full scale value. This means that the input is at the value or greater than the value of the reference. It likely means that the input is over ranged at that time or that the reference is much smaller than expected at that time.

    The diagram that you show for the RTDs is half right. The negative inputs for each channel is correctly connected to each other and routed to the reference resistor. However, the IDAC currents should be routed through the input mux to measure four RTDs.

    As shown there's no way in your diagram to separate the IDAC currents from one RTD to another. To be able to make four 3-wire RTDs work, you must route the IDAC currents through the AINx channels independently. To measure RTD1, route the IDAC currents to AIN0 and AIN1, to measure RTD2, route the IDAC currents to AIN2 and AIN3, and so on. The problem with this configuration is that it is sensitive to series resistance mismatches, so you likely won't be able to use filter circuitry at the analog inputs without adding a lot of error.


    Joseph Wu
  • Joe,

    Here's a diagram showing an ADS1248 configuration with four 3-wire RTDs:

    Joseph Wu

  • Hi Joseph,

    Thank you so much for the information.

    1. Regarding the erratic data, I understand that means that VRTD*Gain value is going higher than VREF which is causing the problem. Am I correct? Is there still a timing issue that I should be considering in my code? I kind of want to believe its the loose connections on my prototype which is just a bread board with too many wires. Should I still be looking into the code though?

    2. Thanks so much for the schematic. I kind of figured out over the weekend that if I wanted to use filter circuits at the inputs, I would only be able to use a maximum of two 3 Wire RTDs per IC. If I were to remove the filter circuits, my understanding is that I would just have to activate the IDAC current sources at the respective inputs at which the measurement is being taken and this way be able to measure 4 3 wire RTDs per IC.

    3. If my understanding is correct as per point 2, I will need to use multiple ADS1248 ICs as I have a total of 12 sensors to measure in a very noisy environment (I'm measuring the temperature off of magnets in an electromagnetic field). I wanted to know if I could use the same reference filter circuit and reference resistance for all the ADCs? I figure I would only need to use the reference resistance to hold the VREF value and if I could avoid redundancies.

    Thanks once again for all your help!

    Joe

  • Joe,


    I should also mention that the 15Ω resistors shown in the diagram represent the wire resistances for each of the three wires.

    Note that they should be relatively equal and that the two IDAC currents, if matched should cancel two of the line resistances. The third line resistance is not part of the measurement, and merely makes a small shift in the common-mode voltage.


    Joseph Wu
  • Joe,

    1. That could be the case, but I'm not sure. With full scale readings, I would guess there's an intermittent open circuit.

    2. If you need the filtering at the front end, you'll likely only be able to use 2 RTDs (and maybe one other two wire alternate measurement). I show a diagram below of how to hook it up. You can use the two IEXC pins and other unused analog inputs to route the current externally to the pins. This will bypass any filter resistance.

    3. If I understand you, yes, you could use the same filter circuit and reference for each of the measurements. It might slow you down, because you can only make one measurement at the time. However, you could use the exact same reference for both ADCs.

    Joseph Wu

  • Hi Joseph,

    I'm including a rough schematic considering a total of four RTDs and two ADS1248. The individual CS pins are held low with an inverting demux. The DRDY pins are being read individually (and will be polled) using the individual inputs of the microcontroller. The START and RESET pins will be set high and will be common for all the ADS1248.

    But most importantly, based on our former discussion, I am not making ANOTHER reference resistor filter circuit for the second ADS1248. Is this OK?

    Other than that, please let me know if there are any contentions with the circuit.

  • Joe,


    In general, your schematic looks ok. I can't think of any reason why you shouldn't be able to share the reference resistor, except that it might be difficult to layout. Most of the time, the capacitances will be placed close to the device inputs, and you may not be able to do that in this setup, so noise pickup might be an issue. I didn't take a detailed look at the multiplexer governing the /CS, but I think it should work. I did have a couple of comments though.

    First, you need to attach VREFCOM to ground. Here VREFCOM is floating for both devices, and an AC ground connection is required.

    Note that you are using the internal oscillator for both devices. That means that the clocks for the devices won't match. You might have problems if you absolutely need to sychronize the timing and are just letting the device free run. However, you can set the device and input to be measured, run a SYNC command and then wait for the next /DRDY indication.

    I see that you have some filter resistors on the reference inputs. In general, I don't think they're really necessary for the performance. Most of the time, I've used just some basic capacitance across the reference input. However it's fine to leave the full filter in.

    Other than that, I don't see any other issues with the schematic.


    Joseph Wu
  • Hi Joseph,

    Before I begin (with what I hope should be possibly the last among my problems for now), I would really like to thank you for all your support in helping me out and with your promptness has definitely assisted me in expediting my work - And this is literally the first time I'm doing something like this! I've setup my prototype and this is the data that I am getting:

    CS1:CH1	   CS1:CH2	   CS2:CH1	   CS2:CH2
    27.97		28.30		25.41		25.08
    27.93		28.28		25.41		25.08
    27.90		28.24		25.38		26.60
    27.86		28.20		25.37		26.73
    27.85		28.18		25.38		32.24
    27.82		28.18		25.34		29.60
    27.79		28.18		25.34		27.67
    27.80		28.16		33.77		26.69
    27.77		28.64		29.69		26.16
    27.95		-8.14		26.50		25.89
    35.07		32.86		25.06		25.68
    29.92		35.04		24.85		25.55
    27.82		32.92		25.03		25.46
    26.96		30.22		25.17		25.37
    26.80		28.93		25.24		25.26
    26.77		28.23		25.26		25.19
    26.81		27.82		25.29		25.15
    26.91		27.55		25.31		25.09
    27.05		27.39		25.30		25.04
    27.21		27.33		25.27		24.99
    27.37		27.30		25.25		24.96
    27.46		27.28		25.25		24.94
    27.62		27.29		25.25		24.92
    27.69		27.28		25.22		24.90
    27.77		27.26		25.21		24.88
    27.82		27.22		25.23		24.86
    27.89		27.25		25.22		24.85
    27.95		27.25		25.19		24.82
    27.99		27.27		25.13		24.78
    27.97		27.31		25.14		24.79
    28.04		27.38		25.16		24.79
    28.08		27.46		25.16		24.80

    The first two columns are from a chip - CS1 and the last two from the chip CS2 and each has two sensors attached to it - CH1 and CH2. 

    While this result is satisfying - I'm noticing that there is about 3-4 degC off between the two ADS1248 devices being read - the first one is giving a temperature of about 27-28degC for both the sensors and the other around 24-25degC. 

    I guess this could be because of where they are located but all my sensors are attached to relatively the same area and I am a little doubtful its a sensor location issue - though I am not ruling it out.

    Alternatively - could this be a coding issue?

    Here's what my complete result data including conversions looks like:

    -------------------------------CS1: CHANNEL 1:----------------------------

    Register 00: A
    Register 0B: 3
    SYNC to begin conversions

    Setting CS HIGH to reset Serial Interface
    24 Bit Data in Binary:1000101011101100100001
    Converted Resistance Value:111.24764251708984375000
    Temperature:28.90234375000000000000
    -------------------------------CS1: CHANNEL 2:----------------------------

    Register 00: 2E
    Register 0B: 47
    SYNC to begin conversions

    Setting CS HIGH to reset Serial Interface
    24 Bit Data in Binary:1000101001111010011111
    Converted Resistance Value:110.89095306396484375000
    Temperature:27.98193359375000000000

    -------------------------------CS2: CHANNEL 1:----------------------------

    Register 00: A
    Register 0B: 3
    SYNC to begin conversions

    Setting CS HIGH to reset Serial Interface
    24 Bit Data in Binary:1000100101000110111111
    Converted Resistance Value:109.92907714843750000000
    Temperature:25.50122070312500000000
    -------------------------------CS2: CHANNEL 2:----------------------------

    Register 00: 2E
    Register 0B: 47
    SYNC to begin conversions

    Setting CS HIGH to reset Serial Interface
    24 Bit Data in Binary:1000100100001001011001
    Converted Resistance Value:109.73640441894531250000
    Temperature:25.00463867187500000000

  • Joe,


    I'm still not sure about these larger errors. It could still be the circuit itself or it could be part of the code in reading the data. Maybe a photo of your setup might give me a hint. EMI is a possible problem if you have other electronics nearby.

    For the general difference between the two devices, I'll need a bit more information to find this error. First what kind of RTD are you using? What is the value of the IDAC current? Then show the calculation that you use to get these numbers. That's why I'd rather deal with the output code of the ADC data, and not the temperature data that was converted from a code.

    The point of these questions is to relate these values back to a voltage value. It could be an offset error or a gain error. I'd note that the difference between 25°C and 28°C for a PT100 device is the equivalent of 1 Ω. While this seems like a large amount for a wire, there are plently of problems that could account for that much resistance in a breadboarded circuit.

    Also you might want to try taking these measurements again. However, before making these measurements, I would definitely run a self offset calibration to make sure that the offset isn't a factor.


    Joseph Wu
  • Hi Joseph,

    I was about to reply with the requested information but I decided to just check the VREF across the RREF for both the ICs and I noted that the VREF for the 27degC one was about 0.5V and on checking the current it was as expected about 0.6mA only. For your reference, the RREF being 820 should have a VREF of 1.6V for the 2mA current flowing through it - this was seen perfectly on the IC giving 25degC. 

    Before proceeding any further, I am thinking of first replacing that IC as I suspect something may be wrong with it - is this a possibility?

    The thing is that the code bsing used for both the ICs and the respective inputs is being done by the SAME function and the only thing that is changing is the addresses of the ICs from the chip select demux from my schematic. The writing of the registers is going perfectly using this method and I am able to read the values back as well. This way I know I am setting the current excitation for both the ICs to 1 mA and 0.6mA is definitely wrong.

    Otherwise is there any reason this is happening?

  • Joe,


    It is certainly possible that the device is damaged and that you'll need to replace it with a new one. However, I always recommend poking around it with a multimeter first. Figure out which measurements make sense and which do not. With a breadboarded circuit, it's possible there's a mistake or a missed connection.

    I can't think of any reason why the IDAC current would be off, except if the internal reference itself is off. I would include that into the measurements you make on your board. Make sure that you have some capacitance between VREFOUT and VREFCOM so that the reference doesn't oscillate.


    Joseph Wu