Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed from November 25 through December 2. Thank you for your patience.

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.

ADS1256: Getting random spikes while switching input mux of ADS1256

Part Number: ADS1256

Hello Everyone
Hope all are having great time.
Its my first time asking for a query on forums so please excuse me if I faulter on any of the precedent.

I'm using ADS1256  waveshare board with Raspberry Pi 4B. I have modified the code provided by waveshare, Basically added the timing constraints. Its working fine for single channel outputs but for multi channel outputs its throwing random spikes in the output of upto 2 mV. The bigger spikes are usually of same magnitude so I think I'm violating some delay constraint But I can't figure out where because I have put the delays as per datasheet only. Even if I made delays excessively large on purpose, The problem still remains. 
Here's the relevant code snippet

/******************************************************************************
function: Set the channel to be read
parameter:
Channal : Set channel number
Info:
******************************************************************************/


void ADS1256_SetDiffChannal(UBYTE Channal)
{
if (Channal == 0){
ADS1256_WriteReg(REG_MUX, (0 << 4) | 1); //DiffChannal AIN0-AIN1

}
else if(Channal == 1){
ADS1256_WriteReg(REG_MUX, (2 << 4) | 3); //DiffChannal AIN2-AIN3

}
else if(Channal == 2){
ADS1256_WriteReg(REG_MUX, (4 << 4) | 5); //DiffChannal AIN4-AIN5

}
else if(Channal == 3){
ADS1256_WriteReg(REG_MUX, (6 << 4) | 7); //DiffChannal AIN6-AIN7

}
}


******************************************************************************/
static UDOUBLE ADS1256_Read_ADC_Data(void)
{
UDOUBLE read = 0;
UBYTE buf[3] = {0,0,0};


DEV_Digital_Write(DEV_CS_PIN, 0);
DEV_Delay_us(1);

ADS1256_WaitDRDY();
DEV_SPI_WriteByte(CMD_RDATA);
DEV_Delay_us(7);
buf[0] = DEV_SPI_ReadByte();
buf[1] = DEV_SPI_ReadByte();
buf[2] = DEV_SPI_ReadByte();


read = ((UDOUBLE)buf[0] << 16) & 0x00FF0000;
read |= ((UDOUBLE)buf[1] << 8); /* Pay attention to It is wrong read |= (buf[1] << 8) */
read |= buf[2] ;

DEV_Digital_Write(DEV_CS_PIN, 1);
return read;
}

/******************************************************************************
function: Read ADC specified channel data
parameter:
Channel: Channel number
Info:
******************************************************************************/
UDOUBLE ADS1256_GetChannalValue(UBYTE Channel)
{
UDOUBLE Value = 0;
ADS1256_WaitDRDY();

if(Channel>=4){
return 0;
}
if(channel ==1){
ADS1256_SetDiffChannal(Channel);

Value = ADS1256_Read_ADC_Data();
}
else{
ADS1256_SetDiffChannal(Channel);

DEV_Delay_us(4);
ADS1256_WriteCmd(CMD_SYNC);
DEV_Delay_us(4);
ADS1256_WriteCmd(CMD_WAKEUP);

DEV_Delay_us(1);
Value = ADS1256_Read_ADC_Data();
}

return Value;
}

/******************************************************************************
function: Read data from all channels
parameter:
ADC_Value : ADC Value
Info:
******************************************************************************/
void ADS1256_GetAll(UDOUBLE *ADC_Value)
{
UBYTE i;
for(i = 0; i<channel; i++){
ADS1256_WaitDRDY();
ADC_Value[i] = ADS1256_GetChannalValue(i);
}

}

Here's Snapshot of output on 2 channels

I hope I could describe the problem well. If there's anything missing please point it out, I'd add it ASAP. 
Thank You Everyone!

  • Hi Pankaj Kumar,

    The best way to determine if you are meeting the ADC timing requirements is to look at your digital signals with a logic analyzer. It will be very difficult to just look at the code and make sure the timing is met.

    Note that TI does not offer support for the Waveshare board since this is not developed by TI. If you have issues with that board or the code, please contact the board manufacturer.

    -Bryan

  • Hey Bryan
    Thank you for replying.
    I have found the issue. Its the delay after RDATA comand and WaitDRDY function before that  is source of spikes. They were reduced If I increase the delay from 7 us to 100 us or so. You're right probably this has something to do with board. Unfortunately I don't have logic analyzer to exactly pinpoint the delays but I'll get one now.
    Thanks once again

    Cheers!
    ~Pankaj