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.

ADS1263: code example

Part Number: ADS1263
Other Parts Discussed in Thread: ADS1262

as suggest by Chris, I go ahead but nothing get resolved. Issue is still there basic problem from my point of view when I see the example given by TI

  1. How to configure that which ADC get initialized and where to read its data as ADC had 11 channels no. in it
  2. no timing diagram is provided in data sheet (this definitely give easy way to us to know its working)
  3. i had done some initialization and as below but don't know where the issue is

////////////////////////// INCLUDE FILE ////////////////////////////////////////
#include "ADS1263.h"

////////////////////////// PIN DECLARATIONS ////////////////////////////////////
sbit defADC1263_RESETPin   at GPIOE_ODR.B2;
sbit defADC1263_STARTPin   at GPIOE_ODR.B3;
sbit defADC1263_CSPin      at GPIOE_ODR.B4;
sbit defADC1263_DRDYPin    at GPIOE_ODR.B5;

sbit defADC1263_SCKPin     at GPIOB_ODR.B3;   //
sbit defADC1263_DOUTPin    at GPIOB_ODR.B4;   //
sbit defADC1263_DINPin     at GPIOB_ODR.B5;   //

char j;

/*
  ADS1262.h - Library for ADS1262 Shield Arduino Firmwar.
  Created by Protocentral, December 27, 2013.
  Released into the public domain.
*/
char* ads1262_Read_Data(){
    static char SPI_Dummy_Buff[6];
    defADC1263_CSPin_Clr;

    for (j = 0; j < 6; ++j){
        SPI_Dummy_Buff[j] = SPI3_Read (CONFIG_SPI_MASTER_DUMMY);
    }
    defADC1263_CSPin_Set;
    return SPI_Dummy_Buff;
}

void ads1262_Init(){
    GPIO_Digital_Output(&GPIOB_BASE, _GPIO_PINMASK_3 | _GPIO_PINMASK_5);
    GPIO_Digital_Output(&GPIOE_BASE, _GPIO_PINMASK_2 | _GPIO_PINMASK_3 | _GPIO_PINMASK_4);
    GPIO_Digital_Input (&GPIOE_BASE, _GPIO_PINMASK_5);
    GPIO_Digital_Input (&GPIOB_BASE, _GPIO_PINMASK_4);
    
//defADC1263_RESETPin_Set;
//defADC1263_STARTPin_Set;
//defADC1263_CSPin_Set;
//defADC1263_SCKPin_Set;
//defADC1263_DINPin_Set;
//while(1);
    // start the SPI library:
//    SPI.begin();
//    SPI.setBitOrder(MSBFIRST);
    //CPOL = 0, CPHA = 1
//    SPI.setDataMode(SPI_MODE1);
    // Selecting 1Mhz clock for SPI
//    SPI.setClockDivider(SPI_CLOCK_DIV8); // DIV16

    // hs
//    SPI2_Init();

SPI3_Init();
    ads1262_Reset();
    Delay_ms(100);
    // ads1262_Disable_Start();
    // ads1262_Enable_Start();

    ads1262_Hard_Stop();
    // ads1262_Start_Data_Conv_Command();
    // ads1262_Soft_Stop();
    Delay_ms(50);
    //  ads1262_Stop_Read_Data_Continuous();                                        // SDATAC command
    Delay_ms(300);

    ads1262_Reg_Write(POWER, 0x11);                 //Set sampling rate to 125 SPS
    Delay_ms(10);
    ads1262_Reg_Write(INTERFACE, 0x05);        //Lead-off comp off, test signal disabled
    Delay_ms(10);
    ads1262_Reg_Write(MODE0, 0x00);                //Lead-off defaults
    Delay_ms(10);
    ads1262_Reg_Write(MODE1, 0x80);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(MODE2, 0x06);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(INPMUX, 0x01);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(OFCAL0, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(OFCAL1, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(OFCAL2, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(FSCAL0, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(FSCAL1, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(FSCAL2, 0x40);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(IDACMUX, 0xBB);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(IDACMAG, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(REFMUX, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(TDACP, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(TDACN, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(GPIOCON, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(GPIODIR, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(GPIODAT, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(ADC2CFG, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(ADC2MUX, 0x01);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(ADC2OFC0, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(ADC2OFC1, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(ADC2FSC0, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
    ads1262_Reg_Write(ADC2FSC1, 0x40);        //Ch 1 enabled, gain 6, connected to electrode in
    Delay_ms(10);
     ads1262_Start_Read_Data_Continuous();
    Delay_ms(10);
    ads1262_Enable_Start();
}

void ads1262_Reset(){
    defADC1263_RESETPin_Set;
    Delay_ms(100);                                        // Wait 100 mSec
    defADC1263_RESETPin_Clr;
    Delay_ms(100);
    defADC1263_RESETPin_Set;
    Delay_ms(100);
}

void ads1262_Disable_Start(){
    defADC1263_STARTPin_Clr;
    Delay_ms(20);
}

void ads1262_Enable_Start(){
    defADC1263_STARTPin_Set;
    Delay_ms(20);
}

void ads1262_Hard_Stop (void){
    defADC1263_STARTPin_Clr;
    Delay_ms(100);
}


void ads1262_Start_Data_Conv_Command (void){
    ads1262_SPI_Command_Data(START);                                        // Send 0x08 to the ADS1x9x
}

void ads1262_Soft_Stop (void){
    ads1262_SPI_Command_Data(STOP);                   // Send 0x0A to the ADS1x9x
}

void ads1262_Start_Read_Data_Continuous (void){
    ads1262_SPI_Command_Data(RDATAC);                                        // Send 0x10 to the ADS1x9x
}

void ads1262_Stop_Read_Data_Continuous (void){
    ads1262_SPI_Command_Data(SDATAC);                                        // Send 0x11 to the ADS1x9x
}

void ads1262_SPI_Command_Data(unsigned char data_in){
    char cdata[1];
    //data[0] = data_in;
    defADC1263_CSPin_Clr;
    Delay_ms(2);
    defADC1263_CSPin_Set;
    Delay_ms(2);
    defADC1263_CSPin_Clr;
    Delay_ms(2);
    SPI3_Write (data_in);
    Delay_ms(2);
    defADC1263_CSPin_Set;
}

//Sends a write command to SCP1000
void ads1262_Reg_Write (unsigned char READ_WRITE_ADDRESS, unsigned char DATA){
    char dataToSend;
    // now combine the register address and the command into one byte:
    dataToSend = READ_WRITE_ADDRESS | WREG;

    defADC1263_CSPin_Clr;
    Delay_ms(2);
    defADC1263_CSPin_Set;
    Delay_ms(2);
    // take the chip select low to select the device:
    defADC1263_CSPin_Clr;
    Delay_ms(2);

    SPI3_Write (dataToSend); //Send register location
    SPI3_Write (0x00);                //number of register to wr
    SPI3_Write (DATA);                //Send value to record into register

    Delay_ms(2);
    // take the chip select high to de-select:
    defADC1263_CSPin_Set;
}

char ADCS_DRDY_Status(){
    char ucStatus;
    if(defADC1263_GetPinStatusDRDY == 0)               // monitor Data ready(DRDY pin)
    {
        ucStatus = 1;
    }
    else {
        ucStatus = 0;
    }
    return ucStatus;
}

There is some ADS1263 example code that was released along with the TIPD188 reference design. Please, refer to the "TIPD188 Firmware" download, under the "Software" section. I hope that helps you out!

Best regards,
Chris

  • Hi Himanshu,

    Can you post a screen shot of your communication detail? Nothing in your code jumps out at me as being 'wrong', but it seems like you are trying to talk to an Arduino device while Chris pointed you to code written for an MSP430.
  • Hi,

    Thanks for your reply, now I am able to see some data on terminal, the thing that i had done so far now

    1. I am not using arduino, I am using stm cortex 4 as controller 
    2. I had crosscheck adc pin with controller all routed correctly
    3. I had checked spi communication pin
    4. Now i am able to see data of ADC but its is not correct firstly data is coming with negative value, for example if channel 1 is at 500 mv than after reading. ADC out is in neg and with reverse counts

    I had set ADC channel no to

    ads1262_Reg_Write(INPMUX, 0b00001100);

    what wrong i am doing do let me know c and h file of ADC is attached with circuit diagram. Physically I am using ads1262

    0552.adc.h

    7534.adc.c
    ////////////////////////// INCLUDE FILE ////////////////////////////////////////
    #include "ADS1263.h"
    
    ////////////////////////// PIN DECLARATIONS ////////////////////////////////////
    sbit defADC1263_RESETPin   at GPIOE_ODR.B2;
    sbit defADC1263_STARTPin   at GPIOE_ODR.B3;
    sbit defADC1263_CSPin      at GPIOE_ODR.B4;
    sbit defADC1263_DRDYPin    at GPIOE_ODR.B5;
    
    sbit defADC1263_SCKPin     at GPIOB_ODR.B3;   //
    sbit defADC1263_DOUTPin    at GPIOB_ODR.B4;   //
    sbit defADC1263_DINPin     at GPIOB_ODR.B5;   //
    
    char j;
    
    
    /*
      ADS1262.h - Library for ADS1262 Shield Arduino Firmwar.
      Created by Protocentral, December 27, 2013.
      Released into the public domain.
    */
    char* ads1262_Read_Data(){
        static char SPI_Dummy_Buff[6];
        defADC1263_CSPin_Clr;
    
        for (j = 0; j < 6; ++j){
            SPI_Dummy_Buff[j] = SPI3_Read (CONFIG_SPI_MASTER_DUMMY);
        }
        defADC1263_CSPin_Set;
        return SPI_Dummy_Buff;
    }
    
    
    void ads1262_Init(){
      // initalize the spi gpio
      GPIO_Digital_Output(&GPIOB_BASE, _GPIO_PINMASK_3);    // SCK
      GPIO_Digital_Input (&GPIOB_BASE, _GPIO_PINMASK_4);    // DOUT
      GPIO_Digital_Output(&GPIOB_BASE, _GPIO_PINMASK_5);    // DIN
      
      // initalize the  data ready and chip select pins:
      GPIO_Digital_Input (&GPIOE_BASE, _GPIO_PINMASK_5);    // data ready input line
      GPIO_Digital_Output(&GPIOE_BASE, _GPIO_PINMASK_4);    // chip enable output line
      GPIO_Digital_Output(&GPIOE_BASE, _GPIO_PINMASK_3);    // start
      GPIO_Digital_Output(&GPIOE_BASE, _GPIO_PINMASK_2);    // Power down output
    
        // start the SPI library:
    //    SPI.begin();
    //    SPI.setBitOrder(MSBFIRST);
        //CPOL = 0, CPHA = 1
    //    SPI.setDataMode(SPI_MODE1);
        // Selecting 1Mhz clock for SPI
    //    SPI.setClockDivider(SPI_CLOCK_DIV8); // DIV16
         Delay_ms(1000);
    
        SPI3_Init();
        
    // Set SPI1 to the Master Mode, data length is 8-bit, clock = Peripheral/64, clock IDLE state low and data transmitted at the first clock edge transition, MSB transferred first, Slave Select Disabled :
    // SPI3_Init_Advanced(_SPI_FPCLK_DIV64, _SPI_MASTER | _SPI_8_BIT | _SPI_CLK_IDLE_LOW | _SPI_FIRST_CLK_EDGE_TRANSITION | _SPI_MSB_FIRST | _SPI_SS_DISABLE | _SPI_SSM_ENABLE | _SPI_SSI_1, &_GPIO_MODULE_SPI1_PA567);
    
        ads1262_Reset();
        Delay_ms(100);
        ads1262_Disable_Start();
        ads1262_Enable_Start();
        ads1262_Hard_Stop();
        ads1262_Start_Data_Conv_Command();
        ads1262_Soft_Stop();
        Delay_ms(50);
        ads1262_Stop_Read_Data_Continuous();                                        // SDATAC command
        Delay_ms(300);
    
        ads1262_Reg_Write(0x00, 0x40);
        Delay_ms(10);
        ads1262_Reg_Write(POWER, 0x11);                 //Set sampling rate to 125 SPS
        Delay_ms(10);
        ads1262_Reg_Write(INTERFACE, 0x05);        //Lead-off comp off, test signal disabled
        Delay_ms(10);
        ads1262_Reg_Write(MODE0, 0x01);                //Lead-off defaults
        Delay_ms(10);
        ads1262_Reg_Write(MODE1, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(MODE2, 0b00011001);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(INPMUX, 0b00001100);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(OFCAL0, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(OFCAL1, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(OFCAL2, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(FSCAL0, 0x40);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(FSCAL1, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(FSCAL2, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(IDACMUX, 0xBB);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(IDACMAG, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(REFMUX, 0x00);         //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(TDACP, 0x00);          //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(TDACN, 0x00);          //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(GPIOCON, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(GPIODIR, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(GPIODAT, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(ADC2CFG, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(ADC2MUX, 0x01);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(ADC2OFC0, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(ADC2OFC1, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(ADC2FSC0, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(ADC2FSC1, 0x40);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Start_Read_Data_Continuous();
        Delay_ms(10);
        ads1262_Enable_Start();
    }
    
    void ads1262_Reset(){
        defADC1263_RESETPin_Set;
        Delay_ms(100);                                        // Wait 100 mSec
        defADC1263_RESETPin_Clr;
        Delay_ms(100);
        defADC1263_RESETPin_Set;
        Delay_ms(100);
    }
    
    void ads1262_Disable_Start(){
        defADC1263_STARTPin_Clr;
        Delay_ms(20);
    }
    
    void ads1262_Enable_Start(){
        defADC1263_STARTPin_Set;
        Delay_ms(20);
    }
    
    void ads1262_Hard_Stop (void){
        defADC1263_STARTPin_Clr;
        Delay_ms(100);
    }
    
    
    void ads1262_Start_Data_Conv_Command (void){
        ads1262_SPI_Command_Data(START);                                        // Send 0x08 to the ADS1x9x
    }
    
    void ads1262_Soft_Stop (void){
        ads1262_SPI_Command_Data(STOP);                   // Send 0x0A to the ADS1x9x
    }
    
    void ads1262_Start_Read_Data_Continuous (void){
        ads1262_SPI_Command_Data(RDATAC);                                        // Send 0x10 to the ADS1x9x
    }
    
    void ads1262_Stop_Read_Data_Continuous (void){
        ads1262_SPI_Command_Data(SDATAC);                                        // Send 0x11 to the ADS1x9x
    }
    
    void ads1262_SPI_Command_Data(unsigned char data_in){
        char cdata[1];
    //    data[0] = data_in;
        defADC1263_CSPin_Clr;
        Delay_ms(2);
        defADC1263_CSPin_Set;
        Delay_ms(2);
        defADC1263_CSPin_Clr;
        Delay_ms(2);
        SPI3_Write (data_in);
        Delay_ms(2);
        defADC1263_CSPin_Set;
    }
    
    void ads1262_Reg_Read (unsigned char READ_WRITE_ADDRESS){
        char dataToSend;
        // now combine the register address and the command into one byte:
        dataToSend = READ_WRITE_ADDRESS | RREG;
    
        defADC1263_CSPin_Clr;
        Delay_ms(2);
        defADC1263_CSPin_Set;
        Delay_ms(2);
        // take the chip select low to select the device:
        defADC1263_CSPin_Clr;
        Delay_ms(2);
    
        SPI3_Write (dataToSend); //Send register location
        SPI3_Write (0x00);                //number of register to wr
        Delay_ms(2);
    
        for (j = 0; j < 4; ++j){
    //        SPI3_Read();
        }
        // take the chip select high to de-select:
        defADC1263_CSPin_Set;
    }
    
    
    //Sends a write command to SCP1000
    void ads1262_Reg_Write (unsigned char READ_WRITE_ADDRESS, unsigned char DATA){
        char dataToSend;
        // now combine the register address and the command into one byte:
        dataToSend = READ_WRITE_ADDRESS | WREG;
    
        defADC1263_CSPin_Clr;
        Delay_ms(2);
        defADC1263_CSPin_Set;
        Delay_ms(2);
        // take the chip select low to select the device:
        defADC1263_CSPin_Clr;
        Delay_ms(2);
    
        SPI3_Write (dataToSend); //Send register location
        SPI3_Write (0x00);                //number of register to wr
        SPI3_Write (DATA);                //Send value to record into register
    
        Delay_ms(2);
        // take the chip select high to de-select:
        defADC1263_CSPin_Set;
    }
    
    char ADCS_DRDY_Status(){
        char ucStatus;
        if(defADC1263_GetPinStatusDRDY == 0)               // monitor Data ready(DRDY pin)
        {
            ucStatus = 0;
        }
        else {
            ucStatus = 1;
        }
        return ucStatus;
    }

  • Hi Himanshu,

    Looking at your schematic, I see that AGND and DGND are not connected. This likely could be causing communications problems as AGND and DGND need to be shorted.

    Also, how are you configuring your SPI interface? In your code you have commented out some important SPI settings. The ADS1262 operates in SPI mode 1, so make sure that you are not trying to read the data in mode 0.

    Best regards,
    Chris

  • Hi Chris,

    Thanks for the comment, I had defined SPI again as suggested and as below and confirming the connection between AGND and DGND is shorted with 0 ohm resistance

    // Set SPI3 to the Master Mode, data length is 8-bit, clock = Peripheral/64, clock IDLE state low and data transmitted at the first clock edge transition, MSB transferred first, Slave Select Disabled :
    
    SPI3_Init_Advanced(_SPI_FPCLK_DIV2, _SPI_MASTER | _SPI_8_BIT | _SPI_CLK_IDLE_LOW | _SPI_FIRST_CLK_EDGE_TRANSITION | _SPI_MSB_FIRST | _SPI_SS_DISABLE | _SPI_SSM_ENABLE | _SPI_SSI_1, &_GPIO_MODULE_SPI3_PB345);
    
    Delay_ms(1000);

    Ihad check the output and it's like, 

    for 1.204 volts

    -2029.459228
    ,-2032.367431
    ,-2028.249389
    ,-2029.996826
    ,-2032.908813
    ,-2028.727905
    ,-2030.877563
    ,-2033.414794
    ,-2032.586791
    ,

    for 0.5 volts

    -2364.539550
    ,-2362.093994
    ,-2363.292480
    ,-2361.949951
    ,-2362.846191
    ,

  • Hi Himanshu,

    SPI mode 1 should use "_SPI_SECOND_CLK_EDGE_TRANSITION", as data is sampled on the falling (second) edge of SCLK. Try adjusting the mode and seeing if that changes your results.

    Also, can you share the hexadecimal data that you are reading from the ADC and possibly some oscilloscope screenshots of the SPI communication during a data read? The floating point values don't give me much information since I cannot see how these values are calculated nor can I infer what the ADC output code was for a given value.

    Thanks,
    Chris
  • Hi Chris,

    Hope you doing good,

    As you suggested I had change the SPI configuration as per below code

    SPI3_Init_Advanced(_SPI_FPCLK_DIV8, _SPI_MASTER | _SPI_8_BIT | _SPI_CLK_IDLE_LOW | _SPI_SECOND_CLK_EDGE_TRANSITION | _SPI_MSB_FIRST | _SPI_SSM_ENABLE | _SPI_SS_DISABLE | _SPI_SSI_1, &_GPIO_MODULE_SPI3_PB345);
    Delay_ms(1000);

    Now I am heading with below output

    set voltage is 0.5volts

    calculated ascii is -0.037588

    and hex on which calculation is done is 0xFF, 0xFF, 0x81, 0xE0, 

    main part of code where claculation is done is as below

    #define PGA 1                     // Programmable Gain = 1
    #define VREF 2.500                 // Internal reference of 2.048V
    #define VFSR VREF/PGA
    #define FSR (((long int)1<<23)-1)
    
    //ads1262 PC_ADS1262;     /                // class
    
    float volt_V=0;
    float volt_mV=0;
    volatile int i;
    volatile char SPI_RX_Buff[10];
    volatile long ads1262_rx_Data[10];
    volatile static int SPI_RX_Buff_Count = 0;
    volatile char *SPI_RX_Buff_Ptr;
    volatile int Responsebyte = -1;
    volatile signed long sads1262Count = 0;
    volatile signed long uads1262Count=0;
    double resolution;
    int data;
    
    
    char ReadADC(){
        char ADC_READY = 0;
    
        if(ADCS_DRDY_Status() == 0)                   // monitor Data ready(DRDY pin)
        {
            SPI_RX_Buff_Ptr = ads1262_Read_Data();    // read 6 bytes conversion register
            Responsebyte = 1 ;
            ADC_READY = 1;
        }
    
        if(Responsebyte == 1)
        {
            for(i = 0; i <5; i++)
            {
                SPI_RX_Buff[SPI_RX_Buff_Count++] = *(SPI_RX_Buff_Ptr + i);
            }
            Responsebyte = -1;
        }
    
        if(SPI_RX_Buff_Count >= 5)
        {
            ads1262_rx_Data[0]= (unsigned char)SPI_RX_Buff[1];  // read 4 bytes adc count
            ads1262_rx_Data[1]= (unsigned char)SPI_RX_Buff[2];
            ads1262_rx_Data[2]= (unsigned char)SPI_RX_Buff[3];
            ads1262_rx_Data[3]= (unsigned char)SPI_RX_Buff[4];
    
            uads1262Count = (signed long) (((unsigned long)ads1262_rx_Data[0]<<24)|((unsigned long)ads1262_rx_Data[1]<<16)|(ads1262_rx_Data[2]<<8)|ads1262_rx_Data[3]);//get the raw 32-bit adc count out by shifting
            sads1262Count = (signed long) (uads1262Count);      // get signed value
            resolution = (double)((double)VREF/pow(2,31));       //resolution= Vref/(2^n-1) , Vref=2.5, n=no of bits
            volt_V     = (resolution)*(float)sads1262Count;     // voltage = resolution * adc count
            volt_mV    = volt_V*1000.0;                           // voltage in mV
        }
        SPI_RX_Buff_Count = 0;
        return ADC_READY;
    }
    
    ////////////////////////// FUNCTION DECLARATION ////////////////////////////////
    void main(void){
        vMain_PowerOnInit();
    
        while(1){
            USB_Polling_Proc();               // Call this routine periodically
            kk = HID_Read();
            if (kk != 0){
                if (ReadADC()==1){
                    sprintf (writebuff, "%lf\n\r,", volt_mV);
                }
                else
                    strcpy (writebuff, "adc not ready");
    
    writebuff[20]=ads1262_rx_Data[0];
    writebuff[21]=ads1262_rx_Data[1];
    writebuff[22]=ads1262_rx_Data[2];
    writebuff[23]=ads1262_rx_Data[3];
    
                HID_Write(writebuff, 64);
            }
            
            if (SecFlag==1){
                SecFlag = 0;
            }
        }
    }
    /******************************************************************************/

  • Hi Himanshu,

    Himanshu Sharma14 said:

    calculated ascii is -0.037588

    and hex on which calculation is done is 0xFF, 0xFF, 0x81, 0xE0, 

    0xFFFF81E0 corresponds to "-3228 codes" in decimal and with an LSB size of 1.164 nV/code, you should be calculating a voltage of -37.588 uV.

    If your calculated value is in units of "mV" then your calculation would appear to be correct.

    Are you measuring a single-ended 0.5V signal? Also, which input pins are you connecting to?

    You've shown two different ADC configurations...

    The code snippet above showed:  "ads1262_Reg_Write(INPMUX, 0x01);"
    However, the attached "adc.c" file shows: "ads1262_Reg_Write(INPMUX, 0b00001100);"

    In the first case, you are measuring the differential voltage between AIN0 and AIN1.
    In the second case, you are measuring between AIN0 and AVDD/4 (~1.25V).

    For a single-ended signal, I would recommend measuring between AIN0 and AINCOM, and also enabling the VBIAS level-shifter. In this way, your difference input voltage will be 0.5V - 2.5V = -2V, and so the ADC's output code should be somewhere around 0x9999999A.

    For troubleshooting, you can also try enabling the internal test DAC and programming the INPMUX register to connect to the test DAC to see if your output codes correspond properly with different input voltages.

    Best regards,
    Chris

  • Hi Chris,

    As suggested by you (For a single-ended signal, I would recommend measuring between AIN0 and AINCOM, and also enabling the VBIAS level-shifter. In this way, your difference input voltage will be 0.5V - 2.5V = -2V, and so the ADC's output code should be somewhere around 0x9999999A.)

    I had selected AN0 and AINCOM and enable level shifter below is code

    SPI3_Init_Advanced(_SPI_FPCLK_DIV8, _SPI_MASTER | _SPI_8_BIT | _SPI_CLK_IDLE_LOW | _SPI_SECOND_CLK_EDGE_TRANSITION | _SPI_MSB_FIRST | _SPI_SSM_ENABLE | _SPI_SS_DISABLE | _SPI_SSI_1, &_GPIO_MODULE_SPI3_PB345);
        Delay_ms(1000);
         
        ads1262_Reset();
        Delay_ms(100);
        ads1262_Disable_Start();
        ads1262_Enable_Start();
        ads1262_Hard_Stop();
        ads1262_Start_Data_Conv_Command();
        ads1262_Soft_Stop();
        Delay_ms(50);
        ads1262_Stop_Read_Data_Continuous();                                        // SDATAC command
        Delay_ms(300);
    
        ads1262_Reg_Write(0x00, 0x40);
        Delay_ms(10);
        ads1262_Reg_Write(POWER, 0x13);                 //Set sampling rate to 125 SPS
        Delay_ms(10);
        ads1262_Reg_Write(INTERFACE, 0x05);        //Lead-off comp off, test signal disabled
        Delay_ms(10);
        ads1262_Reg_Write(MODE0, 0x01);                //Lead-off defaults
        Delay_ms(10);
        ads1262_Reg_Write(MODE1, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(MODE2, 0b00001001);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(INPMUX, 0b00001010);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(OFCAL0, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(OFCAL1, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(OFCAL2, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(FSCAL0, 0x40);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(FSCAL1, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(FSCAL2, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(IDACMUX, 0b00001010);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(IDACMAG, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(REFMUX, 0x00);         //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(TDACP, 0x00);          //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(TDACN, 0x00);          //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(GPIOCON, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(GPIODIR, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(GPIODAT, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(ADC2CFG, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(ADC2MUX, 0x01);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(ADC2OFC0, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(ADC2OFC1, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(ADC2FSC0, 0x00);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Reg_Write(ADC2FSC1, 0x40);        //Ch 1 enabled, gain 6, connected to electrode in
        Delay_ms(10);
        ads1262_Start_Read_Data_Continuous();
        Delay_ms(10);
        ads1262_Enable_Start();

    And my application is to measure single ended signal, I had set 2Volts on AN0 channel and now I am receiving 0x00,0x00,0x63,0xC8 hex with calculated float result of 0.029738 with old calculation

    But this time I am getting all result from result in positive from 50 mv to 2 volts

  • Hi Himanshu,

    I just noticed this in your code:

    ads1262_Reg_Write(FSCAL0, 0x40); // This is a non-default value
    Delay_ms(10);
    ads1262_Reg_Write(FSCAL1, 0x00);
    Delay_ms(10);
    ads1262_Reg_Write(FSCAL2, 0x00); // This is a non-default value
    Delay_ms(10);

    FSCAL2 should be set to 0x40, not FSCAL0.

    This is effectively multiplying all of your conversion results by "1/65536". If you multiply 2V by this ratio, you get out roughly the 0.029 mV that you are currently measuring.

    Best regards,
    Chris

  • Hi Chris,

    I really appreciate your support, finally it look like in some shape and getting what required. 

    Now I set 0.5 Volts and receiving

    ,449.095672
    ,448.987640
    ,449.113128
    ,449.004852
    ,449.105346
    ,449.113616
    ,449.061584
    ,449.098815
    ,448.967285
    ,449.150543

    Is result can be more improve as I am expecting ~18-19 bits at 1k samples?

    the layout part of IC is done as per TI layout guidance.

    I had took 100 sample and result is as below it look like its not even 16 bit resolution, did I missed something?

  • Hi Himanshu,

    Would you be able to try measuring the noise performance with the ADC's inputs shorted to a mid-supply voltage? (For example, select AINCOM for both positive and negative inputs while enabling the VBIAS level-shifter).

    It is likely that the 0.5V signal is contributing a significant amount of noise, so measuring the noise performance with the inputs shorted removes this noise source from the circuit. If you still see poor performance with the inputs shorted, then the next step would be to troubleshoot the power supplies or PCB layout to see if either of those are coupling noising into the device.

    Best regards,
    Chris
  • I had change the mux selection as suggested as

    ads1262_Reg_Write(INPMUX, 0b10101010);

    data is as below look like its noisy

    0.30175
    0.297206
    0.299609
    0.299567
    0.294709
    0.296665
    0.301401
    0.303395
    0.303014
    0.29589
    0.299432
    0.307081
    0.289952
    0.293127
    0.300508
    0.298458
    0.299627
    0.3025
    0.302227
    0.299877

    layout is designed as per layout mention in datasheet and as below

  • I had tested the same with transformer base power supply but same response

  • Hi Himanshu,

    When testing the noise you also replaced C72 with a 0-Ohm resistor, correct?
    If so, then this is probably the best noise performance you will be able to achieve with the current layout.

    Is your PCB only 2-layers?
    A good layout for the ADS1262 is more difficult to achieve with only two PCB layers to work with, as you have to avoid routing tracings as on the bottom layer to leave as much space as possible for a ground plane below the device and all of the connecting signals.

    With the current layout there are a couple of issues that could be contributing to the additional noise:
    - The ground plane appears to be cutout around the ADC, which makes all connecting traces more inductive.
    - The cutouts in the top layer ground fill make the ground plane less effective.
    - The analog ground and digital grounds are connected with a longer trace than necessary. It is best to tie these pins together right below the device.
    - The SCLK trace is not routed above a ground plane and it is also routed through a via. This signal is prone to having many fast edges which can ring when the trace is inductive. To avoid this ringing and to reduce clock noise from coupling into other signals, it is best to route the SCLK signal over the ground plane, keep this trace as short as possible, and avoid unnecessary vias on this trace.
    - Routing traces below the ADC (without an inner ground plane layer) may also lead to noise coupling between traces.

    I wish I had more helpful suggestions, but there isn't much more you can do with the current PCB to improve the noise performance. You could try to blue wire DGND to AVSS with as short of a wire as possible to reduce the impedance between these pins, but with the ground plane layer being cutout as much as it is, this still may not help to reduce trace inductance on all of the connecting signals.

    Best regards,
    Chris
  • Thanks Chris,

    Will consider these points in future and will try to implement the suggestion, if get improvement will let you know

    Thanks & Regards,

    Himanshu