Dual ADS1220 chip select problem

Hello,

I am working on two ADC ADS1220 who measure diffrential ouput from wheatstone bridges. I have three wheatstone bridges and ADS1220 has 4 channels and I can pair two of the channel to measure diffrential output. hence I am using second ads1220 to measure third wheatstone bridge output.

Now the problem is that I am able to measure when using single ads1220 in single channel mode i.e I can measure singular output and can cycle through the channel for all the measurement but when I select diffrential measurement I can get some value in 10^5 . This is just part of the problem. when using 2 ads1220 with chip select, I get varying output even without changing bridge resistance also in power of 10^5 and sometimes i get familier results.

Here is the code which I am working on, I have not written entire code so please be open to any suggestion since I am novice in programming

#include <Protocentral_ADS1220.h>

#include <SPI.h>
#include <Arduino.h>

#define PGA          1                 // Programmable Gain = 1
#define VREF         2.048            // Internal reference of 2.048V
#define VFSR         VREF/PGA
#define FULL_SCALE   (((long int)1<<23)-1)

//#define ADS1220_CS_PIN    7
//#define ADS1220_DRDY_PIN  6

Protocentral_ADS1220 pc_ads1220;
volatile long adc_data;
volatile bool drdyIntrFlag = false;
uint8_t delim1 = 0x2f;

      uint8_t m_config_reg0;
      uint8_t m_config_reg1;
      uint8_t m_config_reg2;
      uint8_t m_config_reg3;

      uint8_t Config_Reg0;
      uint8_t Config_Reg1;
      uint8_t Config_Reg2;
      uint8_t Config_Reg3;

//uint8_t m_drdy_pin_0=6;
//uint8_t m_cs_pin_0=7;
//uint8_t m_drdy_pin_1=3;
//uint8_t m_cs_pin_1=2;

#define ADS1220_0_CS_PIN    7
#define ADS1220_0_DRDY_PIN  6
#define ADS1220_1_CS_PIN    3
#define ADS1220_1_DRDY_PIN  2

const uint8_t ADC_PINMAP[2][2] = {{ADS1220_0_CS_PIN, ADS1220_0_DRDY_PIN}, {ADS1220_1_CS_PIN, ADS1220_1_DRDY_PIN}}; 

 
//void drdyInterruptHndlr(){
//  drdyIntrFlag = true;
//}


//void enableInterruptPin(){
//  attachInterrupt(digitalPinToInterrupt(ADS1220_DRDY_PIN), drdyInterruptHndlr, FALLING);
//}

void setupSingleShot(uint8_t adc)
{
        pc_ads1220.begin(ADC_PINMAP[adc][0],ADC_PINMAP[adc][1]);
   
        pc_ads1220.set_data_rate(DR_1000SPS);
        pc_ads1220.PGA_OFF();
        pc_ads1220.set_VREF(VREF_REFP0);

        pc_ads1220.set_conv_mode_single_shot(); //Set Single shot mode  
}
void setupContinuous(uint8_t adc)
{
        pc_ads1220.begin(ADC_PINMAP[adc][0],ADC_PINMAP[adc][1]);
   
        pc_ads1220.set_data_rate(DR_1000SPS);
        pc_ads1220.PGA_OFF();
        pc_ads1220.set_VREF(VREF_REFP0);

        pc_ads1220.set_conv_mode_continuous();  
}

void setup()
{
    Serial.begin(115200);

    pinMode(ADC_PINMAP[0][0], OUTPUT);
    pinMode(ADC_PINMAP[0][1], INPUT);
    pinMode(ADC_PINMAP[1][0], OUTPUT);
    pinMode(ADC_PINMAP[1][1], INPUT);

    digitalWrite(ADC_PINMAP[0][0],HIGH);
    digitalWrite(ADC_PINMAP[1][0],HIGH);

    for(uint8_t adc = 0; adc < 2; adc++)
    {
      setupContinuous(adc);
    }
}

int32_t Read_Data_Samples(uint8_t adc)
{
    static byte SPI_Buff[3];
    int32_t mResult32=0;
    long int bit24;

     while((digitalRead(ADC_PINMAP[adc][1])) != LOW);

    digitalWrite(ADC_PINMAP[adc][0],LOW);                         //Take CS low
    delayMicroseconds(1);
    for (int i = 0; i < 3; i++)
    {
      SPI_Buff[i] = SPI.transfer(SPI_MASTER_DUMMY);
    }
    delayMicroseconds(1);
    digitalWrite(ADC_PINMAP[adc][0],HIGH);                  //  Clear CS to high

    bit24 = SPI_Buff[0];
    bit24 = (bit24 << 8) | SPI_Buff[1];
    bit24 = (bit24 << 8) | SPI_Buff[2];                                 // Converting 3 bytes to a 24 bit int

    bit24= ( bit24 << 8 );
    mResult32 = ( bit24 >> 8 );                      // Converting 24 bit two's complement to 32 bit two's complement

    return mResult32;
}
void writeRegister(uint8_t address, uint8_t value, uint8_t adc)
{
    digitalWrite(ADC_PINMAP[adc][0],LOW);
    delayMicroseconds(1);
    SPI.transfer(WREG|(address<<2));
    SPI.transfer(value);
    delayMicroseconds(1);
    digitalWrite(ADC_PINMAP[adc][0],HIGH);
}
void select_mux_channels(int channels_conf,uint8_t adc)
{
    m_config_reg0 &= ~REG_CONFIG0_MUX_MASK;
    m_config_reg0 |= channels_conf;
    writeRegister(CONFIG_REG0_ADDRESS,m_config_reg0,adc);
}

void loop()
{
  
//long int t1 = millis();
// for (int i= 0; i<=1000; i++)
//  { 
    uint8_t buf;
    const uint8_t MUX_CHANNELS[] = {MUX_AIN0_AIN1, MUX_AIN2_AIN3};
    for(uint8_t adc=0; adc < 2; adc++)
    {
        for(uint8_t channel=0; channel < 2; channel++)
        {
            if((1 != adc) || (1 != channel))
            {
                select_mux_channels(MUX_CHANNELS[channel], adc);
                adc_data=Read_Data_Samples(adc);

                buf = (adc_data >> 24)  & 255;
                Serial.write(buf);
                buf = (adc_data >> 16) & 255;
                Serial.write(buf);
                buf = (adc_data >> 8) & 255;
                Serial.write(buf);
                buf = adc_data & 255;
                Serial.write(buf);
                delayMicroseconds(5);
            }
        }
    }
/*
    select_mux_channels(MUX_SE_CH0, 0);
    adc_data=Read_Data_Samples(0);


    buf = (adc_data >> 24)  & 255;
    Serial.write(buf);
    buf = (adc_data >> 16) & 255;
    Serial.write(buf);
    buf = (adc_data >> 8) & 255;
    Serial.write(buf);
    buf = adc_data & 255;
    Serial.write(buf);
  
    delayMicroseconds(1);

    select_mux_channels(MUX_SE_CH1, 0);
    adc_data=Read_Data_Samples(0);

    buf = (adc_data >> 24)  & 255;
    Serial.write(buf);
    buf = (adc_data >> 16) & 255;
    Serial.write(buf);
    buf = (adc_data >> 8) & 255;
    Serial.write(buf);
    buf = adc_data & 255;
    Serial.write(buf);

    delayMicroseconds(1);

    select_mux_channels(MUX_SE_CH0,1);
    adc_data=Read_Data_Samples(1);

    
    buf = (adc_data >> 24)  & 255;
    Serial.write(buf);
    buf = (adc_data >> 16) & 255;
    Serial.write(buf);
    buf = (adc_data >> 8) & 255;
    Serial.write(buf);
    buf = adc_data & 255;
    Serial.write(buf);

    delayMicroseconds(1);
    
    select_mux_channels(MUX_SE_CH1,1);
    adc_data=Read_Data_Samples(1);
       

    buf = (adc_data >> 24)  & 255;
    Serial.write(buf);
    buf = (adc_data >> 16) & 255;
    Serial.write(buf);
    buf = (adc_data >> 8) & 255;
    Serial.write(buf);
    buf = adc_data & 255;
    Serial.write(buf);
*/
    
Serial.write(0x2F);
Serial.write(0x41);
Serial.write(0x2F);
//   }
//    long int t2 = millis();

//     Serial.print("Time taken by the task: "); Serial.print(t2-t1); Serial.println(" milliseconds");
}

Please edit your post to put the correct device number in it, or ask the moderators to do it if you cannot.
Thanks
C

1 Like

Okay. Next step. Your description hints to me that you're struggling with analog connections(I may be wrong). Please post a complete schematic of your circuit, so that we may ascertain whether you're wiring something wrongly.
Thanks
C

I have no experince in programming so I would like to ask you some question here, I apolozise if they are too basic:

Can I programm a device without source file from arduino? I am using source file from protocentral for ADS1220 but is it possible to set register in of the device for ADS1220 with out src file?

If yes can you give me example here? for ads1220 if possible.

Hi,
Thanks for the schematic.
What is the reason for all the 47R resistors in series with the ADC signal lines?
Have you placed bypass capacitors at all the Wheatstone bridge arrays?

Have you wired your bridges so the wires are not sharing current from other hardware.
That is the 5V excitation and gnd connections connected directly to the power supply, ie star configuration.

Tom.... :smiley: :+1: :coffee: :australia:

47R are recommended by datasheet,
what bypass resistors can you point out in schematic image?
Actually the schematic is complete representation of my circuit. I know what star config means but what i tried to do is achieve ratiometeric measurement by sharing excitation source volttage with analog power supply of the adc in order to cancel out any drift. But i do not understand what you are trying to say here by saying "Have you wired your bridges so the wires are not sharing current from other hardware."

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.