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.

ADS122C04: problems in configuring ADS122C04 in Arduino IDE

Part Number: ADS122C04

dear all,

I am not able to set the configuration registers of the converter chip ADS122C04 using arduino via I2C.

Arduino has the Wire libary for i2c communication. The code contains the following

1-reset the chip (one byte)

2-write register command (WREG) and register data (figure 59 of the data sheet) for all four registers

3- start conversion (one byte)

In sum, ten (10) bytes are sent in one i2c frame using an array of bytes as follows:

  //--------------------------------------------------------------------

int ADR_THeiz_Austritt = 0x40;                                                  //hex Adress of the device 

byte InitArray[10] = {6, 64, 54, 68, 10, 72, 5, 76, 112, 8};    //configuration array

 

     Wire.beginTransmission(ADR_THeiz_Austritt);            //  talk to Slave

     Wire.write(InitArray,10);                                                    // bytes array is sent to slave on ACK handshaking           

      status = Wire.endTransmission();                                   //status see https://www.arduino.cc/en/Reference/WireEndTransmission

      Serial.print("Status Initialisierung = ");

      Serial.println(status);

  //--------------------------------------------------------------------

status is a byte, which indicates the status of the transmission:

0:success

1:data too long to fit in transmit buffer

2:received NACK on transmit of address

3:received NACK on transmit of data

4:other error

 after configuration, when reading the value of e.g. register 0, the result was 0 !!

A second attempt was performed with a for loop

  //--------------------------------------------------------------------

  for (int i=0; i<10; i++)

  {

    Wire.beginTransmission(ADR_THeiz_Austritt);

    Wire.write(InitArray[i]);                                                      

    //delay(10);

  status = Wire.endTransmission();                                       

  Serial.print("status Initialisierung ");

  Serial.print(i);                     //print the array element no

      Serial.println(status);     //print the status of transmision

      }

  //--------------------------------------------------------------------

the print function result was the following: 00, 10, 23, 30,43,50,63,70,83,90 which means:

i=0, InitArray[i]=6, status =0 --> Reset of chip successfull

i=1, InitArray[i]=64, status =0 --> adressing Register 0 successfull

i=2, InitArray[i]=54, status =3 -->  value for Register 0 not transmitted !! (the same applies for all registers)

i=9, InitArray[i]=8, status =0 --> start chip successfull

My question: do you know why I am not able to put a value in the registers?

thanks a lot!

ilyes

  • Hi Ilyes,

    Welcome to the E2E forum!  The best method of checking communication issues is by using an oscilloscope or logic analyzer to make sure that what you think is happening in code is actually being transmitted.

    In your second code iteration you are addressing and writing one byte at a time and the WREG command actually is a 2-byte transaction.  The RESET command is a one byte command, so that device communication will work.  However when writing the registers you issue the write command, then issue a stop before the data are transmitted.  When you send the data in the next transmission, the action is unknown and will be rejected.

    Best regards,

    Bob B