Post Go back to editing

AD7124-8: When enabling the internal temperature sensor the device starts outputting garbage.

Category: Hardware
Product Number: AD7124-8

 Our code is fully working on the EVAL-AD7124-8-PMDZ board, now we are trying to implement it on a custom PCB. We are able to read the 8 thermocouples connected to AIN0-AIN15. However when the internal temperature sensor is enabled the ADC output becomes garbage.

We have tried several different channel, filter and config configurations with no success. What is weird is that when the temperature sensor is enabled many of the other registers reset to default.



added the part number to the subject field
[edited by: JEstayo at 1:14 AM (GMT -4) on 14 Mar 2024]

Thread Notes

  • Hi  ,

    Can you share your schematic/setup and configuration settings for this? This will help us better understand the issue you are having.

    Thanks and regards,

    Rod 

  •  

    PDF

    Attached is the schematic. I do not think that the problem lies with the circuit. I am able to read multiple thermocouples and am getting values that make sense. However when I try and enable the configuration for the internal temperature sensor (config 7) set to channel 15, the data values seem to freeze and there are no longer any changes.

    #ifndef ADCTEMP_H
    #define ADCTEMP_H
    
    #include <Arduino.h>
    #include <STM32FreeRTOS.h>
    #include <SPI.h>
    #include <Wire.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SH110X.h>
    #include <Adafruit_Sensor.h>
    
    #include "inputs_outputs.h"
    #include "global_variables.h"
    #include "taskDisplayUpdate.h"
    #include "taskSwitches.h"
    
    void ad7124_setup();
    int ad7124_setup_check();
    void ad7124_Errors();
    void ad7124_ReadData();
    void printLeadingZeros(int var, int size);
    int ad7124_CheckConvReady();
    void ad7124_offsets();
    void ad7124_gains();
    void adcRegWrite(int regAddress, int bits, int valA, int valB, int valC);
    int adcRegCheck(int regAddress, int bits, int valA, int valB, int valC);
    
    #define comms_read      0b01000000
    #define comms_write     0b00000000
    
    //the address value for a specific registers
    #define comms_reg         0x00    // w
    #define status_reg        0x00    // r
    #define ADC_control_reg   0x01    // rw
    #define data_reg          0x02    // r
    #define IO_control_1_reg  0x03    // rw
    #define IO_control_2_reg  0x04    // rw
    #define ID_reg            0x05    // r
    #define error_reg         0x06    // r
    #define error_EN_reg      0x07    // rw
    #define MCLK_count        0x08    // r
    #define channel_0_reg     0x09    // rw
    #define channel_1_reg     0x0A    // rw
    #define channel_2_reg     0x0B    // rw
    #define channel_3_reg     0x0C    // rw
    #define channel_4_reg     0x0D    // rw
    #define channel_5_reg     0x0E    // rw
    #define channel_6_reg     0x0F    // rw
    #define channel_7_reg     0x10    // rw
    #define channel_8_reg     0x11    // rw
    #define channel_9_reg     0x12    // rw
    #define channel_10_reg    0x13    // rw
    #define channel_11_reg    0x14    // rw
    #define channel_12_reg    0x15    // rw
    #define channel_13_reg    0x16    // rw
    #define channel_14_reg    0x17    // rw
    #define channel_15_reg    0x18    // rw
    #define config_0_reg      0x19    // rw
    #define config_1_reg      0x1A    // rw
    #define config_2_reg      0x1B    // rw
    #define config_3_reg      0x1C    // rw
    #define config_4_reg      0x1D    // rw
    #define config_5_reg      0x1E    // rw
    #define config_6_reg      0x1F    // rw
    #define config_7_reg      0x20    // rw
    #define filter_0_reg      0x21    // rw
    #define filter_1_reg      0x22    // rw
    #define filter_2_reg      0x23    // rw
    #define filter_3_reg      0x24    // rw
    #define filter_4_reg      0x25    // rw
    #define filter_5_reg      0x26    // rw
    #define filter_6_reg      0x27    // rw
    #define filter_7_reg      0x28    // rw
    #define offset_0_reg      0x29    // rw
    #define offset_1_reg      0x2A    // rw
    #define offset_2_reg      0x2B    // rw
    #define offset_3_reg      0x2C    // rw
    #define offset_4_reg      0x2D    // rw
    #define offset_5_reg      0x2E    // rw
    #define offset_6_reg      0x2F    // rw
    #define offset_7_reg      0x30    // rw
    #define gain_0_reg        0x31    // rw
    #define gain_1_reg        0x32    // rw
    #define gain_2_reg        0x33    // rw
    #define gain_3_reg        0x34    // rw
    #define gain_4_reg        0x35    // rw
    #define gain_5_reg        0x36    // rw
    #define gain_6_reg        0x37    // rw
    #define gain_7_reg        0x38    // rw
    
    //the data to be written to a specific register
    #define ADC_control_valA   0b00000101
    #define ADC_control_valB   0b11000100
    // #define ADC_control_valB_s 0b11001000
    #define IO_control_1_valA  0b00000000
    #define IO_control_1_valB  0b00000000
    #define IO_control_1_valC  0b00000000
    #define IO_control_2_valA  0b01010101
    #define IO_control_2_valB  0b01010101
    
        // thermocouples
    #define config_0_valA      0b00001001
    #define config_0_valB      0b11110111
    #define filter_0_valA      0b11111010
    #define filter_0_valB      0b00000011
    #define filter_0_valC      0b11000000
    
    #define channel_0_valA   0b00000000
    #define channel_0_valB   0b00000001
    #define channel_1_valA   0b00000000
    #define channel_1_valB   0b01000011
    #define channel_2_valA   0b00000000
    #define channel_2_valB   0b10000101
    #define channel_3_valA   0b00000000
    #define channel_3_valB   0b11000111
    #define channel_4_valA   0b00000001
    #define channel_4_valB   0b00001001
    #define channel_5_valA   0b00000001
    #define channel_5_valB   0b01001011
    #define channel_6_valA   0b00000001
    #define channel_6_valB   0b10001101
    #define channel_7_valA   0b00000001
    #define channel_7_valB   0b11001111
    
        // internal temp sensor
    #define config_7_valA      0b00001001
    #define config_7_valB      0b11110000
    // #define config_7_valA      0b00001000
    // #define config_7_valB      0b00010000
    
    #define filter_7_valA      0b00011010
    #define filter_7_valB      0b00000000
    #define filter_7_valC      0b00100000
    #define offset_7_valA      0b00000000
    #define offset_7_valB      0b00000000
    #define offset_7_valC      0b00000000
    #define gain_7_valA        0b00000000
    #define gain_7_valB        0b00000000
    #define gain_7_valC        0b00000000
    
    #define channel_15_valA   0b01110010
    #define channel_15_valB   0b00010001
    
        // channel enable/disable
    #define channel_0_EN    0b0
    #define channel_1_EN    0b0
    #define channel_2_EN    0b0
    #define channel_3_EN    0b0
    #define channel_4_EN    0b0
    #define channel_5_EN    0b0
    #define channel_6_EN    0b0
    #define channel_7_EN    0b0
    #define channel_15_EN   0b1
    
    #define error_en_valA    0b00000011
    #define error_en_valB    0b00000000
    #define error_en_valC    0b00000000
    // #define error_en_valA    0b00000000
    // #define error_en_valB    0b00000000
    // #define error_en_valC    0b00000000
    
    //the number of bits to read/write for a specific register
    #define comms_bits        8 
    #define status_bits       8
    #define ADC_control_bits  16
    #define data_bits         24
    #define IO_control_1_bits 24
    #define IO_control_2_bits 16
    #define config_bits       16
    #define filter_bits       24
    #define channel_bits      16
    #define error_en_bits     24
    #define error_bits        24
    
    #endif

    Here is the serial output for the channels 0-3 enabled, with the temperature sensor disabled (serial_output_1) and with the temperature sensor enabled and nothing else changed (serial_output_2).

    Serial init
    SPI init
    SPI init complete
    ID reg: 00010100
    channel 0 setup
    channel 1 setup
    channel 2 setup
    channel 3 setup
    channel 4 setup
    channel 5 setup
    channel 6 setup
    channel 7 setup
    channel 15 setup
    IO control 1 setup
    IO control 2 setup
    config 0 setup
    config 7 setup
    filter 0 setup
    filter 7 setup
    Error enable setup
    ADC control setup
    
    Errors:         00000001        00000000        00000000
    ADC setup completed
    
    data[23:16]     data[15:8]      data[7:0]       status          data raw value
    10000000        00011000        11110110        00000000        8394998.00
    01111111        11101010        10000111        00000001        8383111.00
    01111111        11011110        01010111        00000010        8379991.00
    01111111        11001100        10001101        00000011        8375437.00
    10000000        10101100        11100011        00000000        8432867.00
    01111111        11100011        10001010        00000001        8381322.00
    01111111        11011011        01100001        00000010        8379233.00
    01111111        11001001        01100001        00000011        8374625.00
    10000000        10101001        00110111        00000000        8431927.00
    01111111        11100010        11010100        00000001        8381140.00
    01111111        11011000        11011110        00000010        8378590.00
    01111111        11000111        01101001        00000011        8374121.00
    10000000        10100110        11100101        00000000        8431333.00
    01111111        11100000        11011010        00000001        8380634.00
    01111111        11010111        11110001        00000010        8378353.00
    01111111        11000101        11100111        00000011        8373735.00
    10000000        10100100        11001010        00000000        8430794.00
    01111111        11100000        01000011        00000001        8380483.00
    01111111        11010111        00000010        00000010        8378114.00
    01111111        11000101        00100110        00000011        8373542.00
    10000000        10100100        01011011        00000000        8430683.00
    01111111        11011110        11100111        00000001        8380135.00
    01111111        11010101        01110101        00000010        8377717.00
    01111111        11000011        11000001        00000011        8373185.00
    10000000        10100011        10010101        00000000        8430485.00
    01111111        11011101        11110001        00000001        8379889.00
    01111111        11010011        11011101        00000010        8377309.00
    01111111        11000011        10100001        00000011        8373153.00
    10000000        10100010        01000010        00000000        8430146.00
    01111111        11011101        01110111        00000001        8379767.00
    01111111        11010100        00010111        00000010        8377367.00
    01111111        11000010        01000010        00000011        8372802.00
    Serial init
    SPI init
    SPI init complete
    ID reg: 00010100
    channel 0 setup
    channel 1 setup
    channel 2 setup
    channel 3 setup
    channel 4 setup
    channel 5 setup
    channel 6 setup
    channel 7 setup
    channel 15 setup
    IO control 1 setup
    IO control 2 setup
    config 0 setup
    config 7 setup
    filter 0 setup
    filter 7 setup
    Error enable setup
    ADC control setup
    
    Errors:         00000011        00000000        00000000
    ADC setup completed
    
    data[23:16]     data[15:8]      data[7:0]       status          data raw value
    01111111        11111000        01001011        00000000        8386635.00
    01111111        11010010        10110010        00000001        8377010.00
    01111111        11000011        11111001        00000010        8373241.00
    00000000        00000000        00000000        00000000        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00
    Errors:         00000000        00000000        00000000
    00000000        00000000        00000000        11111111        0.00

  • Hi  ,

    Apologies for the late response. Do you still need help with this? If so, here are my thoughts:

    Can you confirm the following:

    1. For channel_15_valA, you set AINM_15 to Internal Ref and AINP_15 to AIN3 using SETUP 0?
    2. For channel_15_valB, you set AINM_15 to AVSS and AINP_15 to AIN0 using SETUP 0?
    3. And for config_0_valA, you set it to Gain=2 using REFIN2+/- with disabled REF and AIN buffers?
    4. And for config_0_valB, you set it to Gain=128 using Int Ref with enabled AIN+/- and REF- buffers and a disabled REF+ buffer?

    Also, could you help me understand the difference valA and valB or how it is used on your code? 

    Have you also tried referring to this circuit note which may help you setup the AD7124 for a thermocouple measurement system? 

    CN-0384 (Rev. A) (analog.com)

    There is also an AD7124 temperature measurement demo code which you may also refer to. It includes a demo code for thermocouple applications.

    AD7124 Temperature Measurement Demo Example [Analog Devices Wiki]

  • Hi  ,

    Yes, I still need help. I recently had 2 more boards made up. The first is an update to the previous board, which has the AD7124-8 directly soldered. The second has sockets for the EVAL-AD7124-8 board. The same code was loaded onto both boards and the same tests were run. The EVAL board works correctly with the internal temperature displayed and all the thermocouples referenced off it. However on the soldered board all the data get corrupted including for the thermocouples.

    Is there a new revision for this chip with different register values?

    Can you think of any reason enabling the internal sensor would corrupt the configuration of other registers?

  • Hi  ,

    There was a Product/Process Change Notice (PCN) issued on AD7124-4/8. You may refer to this FAQ (AD7124-4/8 Standard Silicon, B-grade, and W-grade - Documents - Precision ADCs - EngineerZone (analog.com)) and see if you have the OLD silicon or the NEW silicon revision. The FAQ also provides the difference between the two revisions. 

    Thanks and regards,

    Rod