Post Go back to editing

AD7731 via Arduino SPI

We're using an Arduino to control an AD7731.  We think the SPI interface is working in that we can 1) trigger a reset by writing four 0xFF bytes and see the RESET pin go low via our logic analyzer and 2) After the reset, we read the Mode register and get back 0x174 as per the data sheet.  Our problem is that when we try to do a continuous conversion read operation, fully differential, AIN1(+) and AIN2(-), 0 - 1.28 V, Mode bytes as follows (MSB first)   00110001  01110100, we can't ever get the RDY pin to go low.  Is there a way to check the operation of the chip so see if conversions are being made and put in the data register at all?  I don't think we fried the chip, but we don't have a way to check.  Also, we are using the AD780 2.5V reference.  We could send you code if that would help.

Thanks,

George

Parents
  • Brendan,

         We tried your suggestion with mixed success. We still don't see the RDY pin go low. I've attached our Arduino code and a screenshot of one section of the output of our logic analyzer. We were able to:

    1. Do a reset by writing 32 1's to the ADC.

    2. Read the mode register and get the default/power-up value (0x174)

    3. Write new mode bytes for continuous read, etc. (see comments in code)

    4. Read back the mode bytes and confirm that the write was accomplished

    successfully.

    Can you see our error or perhaps suggest another test that might be helpful?

    Thanks,  George

    /*Arduino sketch for AD7731 ADC

    This sketch assumes the usual SPI pin assignments found at https://www.arduino.cc/en/Reference/SPI

    for the Mega2560:

    MOSI = 51

    MISO = 50

    SCK = 52

    SS = 53

    */

    #include <SPI.h>

    //Set any handy constants and do variable declarations

    const  int  adcRDY = 30;  //Monitor pin 30 to see when data is ready for reading

    byte mode1, mode2, modedata1, modedata2;        //For mode register bits, mode1 is MSB

    void  setup()  {

      pinMode(adcRDY,INPUT);

      pinMode(MISO,INPUT);

      pinMode(MOSI,OUTPUT);

      pinMode(SCK,OUTPUT);

      pinMode(SS,OUTPUT);                   //this is the chip select line, set low to select chip

      pinMode(40,OUTPUT); digitalWrite(40,LOW);    //We're using pin 40 as a trigger for the logic analyzer

      SPI.begin();

      SPI.setBitOrder(MSBFIRST);

      SPI.setDataMode(SPI_MODE3);    //CPOL = 1, CPHA = 0, POL pin on ADC should be HIGH

      SPI.setClockDivider(SPI_CLOCK_DIV16);  //Serial clock frequency is now 1 MHz

      Serial.begin(9600);  //connection to serial monitor for output and debugging

      Serial.println("past setup");

    }

     

    void  loop()  {

      digitalWrite(40,HIGH);  //Start the logic analyzer

      digitalWrite(SS,HIGH);  //Set SS HIGH in case it matters

      digitalWrite(SS,LOW);  //Set SS LOW to select chip

      SPI.transfer(0xFF); //hardware reset with 4, 8 byte sets of 1's

      SPI.transfer(0xFF);

      SPI.transfer(0xFF);

      SPI.transfer(0xFF);

      delayMicroseconds(100);  //just in case the chip needs time to settle out

      SPI.transfer(0x12);  //Tell comm register that next operation is read from mode register

      modedata1 = SPI.transfer(0x00);  // Read first byte from the mode register

      modedata2 = SPI.transfer(0x00);  // Read second byte from the mode register

      Serial.println("Default mode register bytes are...");

      Serial.println(modedata1,BIN);  //print out mode data bytes to serial monitor

      Serial.println(modedata2,BIN);  //print out mode data bytes to serial monitor

      mode1=0b00110001;    //MSB   Continuous conversion, unipolar, no digital ports, 24 bit data,

      mode2=0b01110100;    //LSB  Vref=2.5V, 0 - 1.28 V scale, no burnout, fully differential, AIN1(-) AIN2(+)

      SPI.transfer(0x02);  //Tells communications register that next operation is write to mode register.

      SPI.transfer(mode1);  //Tell it to take the reading as described by mode's bits

      SPI.transfer(mode2); 

      Serial.println("New mode register bytes are...");

      SPI.transfer(0x12);  //Tell comm register that next operation is read from mode register

      modedata1 = SPI.transfer(0x00);  // Read first byte from the mode register

      modedata2 = SPI.transfer(0x00);  // Read second byte from the mode register

      Serial.println(modedata1,BIN);  //print out mode data bytes to serial monitor

      Serial.println(modedata2,BIN);  //print out mode data bytes to serial monitor

      delay(1000);  //sit here a while to see if RDY ever goes low

      SPI.transfer(0x30);  //stop continuous conversion

      digitalWrite(40,LOW);  //reset level of logic analyzer trigger to get ready for next sweep

      digitalWrite(SS,HIGH); //deselect chip 

      delay(5000);  //wait 5 s before looping

    }

     

    319866a4116221178feca71c97ce4d1b.tiff

Reply
  • Brendan,

         We tried your suggestion with mixed success. We still don't see the RDY pin go low. I've attached our Arduino code and a screenshot of one section of the output of our logic analyzer. We were able to:

    1. Do a reset by writing 32 1's to the ADC.

    2. Read the mode register and get the default/power-up value (0x174)

    3. Write new mode bytes for continuous read, etc. (see comments in code)

    4. Read back the mode bytes and confirm that the write was accomplished

    successfully.

    Can you see our error or perhaps suggest another test that might be helpful?

    Thanks,  George

    /*Arduino sketch for AD7731 ADC

    This sketch assumes the usual SPI pin assignments found at https://www.arduino.cc/en/Reference/SPI

    for the Mega2560:

    MOSI = 51

    MISO = 50

    SCK = 52

    SS = 53

    */

    #include <SPI.h>

    //Set any handy constants and do variable declarations

    const  int  adcRDY = 30;  //Monitor pin 30 to see when data is ready for reading

    byte mode1, mode2, modedata1, modedata2;        //For mode register bits, mode1 is MSB

    void  setup()  {

      pinMode(adcRDY,INPUT);

      pinMode(MISO,INPUT);

      pinMode(MOSI,OUTPUT);

      pinMode(SCK,OUTPUT);

      pinMode(SS,OUTPUT);                   //this is the chip select line, set low to select chip

      pinMode(40,OUTPUT); digitalWrite(40,LOW);    //We're using pin 40 as a trigger for the logic analyzer

      SPI.begin();

      SPI.setBitOrder(MSBFIRST);

      SPI.setDataMode(SPI_MODE3);    //CPOL = 1, CPHA = 0, POL pin on ADC should be HIGH

      SPI.setClockDivider(SPI_CLOCK_DIV16);  //Serial clock frequency is now 1 MHz

      Serial.begin(9600);  //connection to serial monitor for output and debugging

      Serial.println("past setup");

    }

     

    void  loop()  {

      digitalWrite(40,HIGH);  //Start the logic analyzer

      digitalWrite(SS,HIGH);  //Set SS HIGH in case it matters

      digitalWrite(SS,LOW);  //Set SS LOW to select chip

      SPI.transfer(0xFF); //hardware reset with 4, 8 byte sets of 1's

      SPI.transfer(0xFF);

      SPI.transfer(0xFF);

      SPI.transfer(0xFF);

      delayMicroseconds(100);  //just in case the chip needs time to settle out

      SPI.transfer(0x12);  //Tell comm register that next operation is read from mode register

      modedata1 = SPI.transfer(0x00);  // Read first byte from the mode register

      modedata2 = SPI.transfer(0x00);  // Read second byte from the mode register

      Serial.println("Default mode register bytes are...");

      Serial.println(modedata1,BIN);  //print out mode data bytes to serial monitor

      Serial.println(modedata2,BIN);  //print out mode data bytes to serial monitor

      mode1=0b00110001;    //MSB   Continuous conversion, unipolar, no digital ports, 24 bit data,

      mode2=0b01110100;    //LSB  Vref=2.5V, 0 - 1.28 V scale, no burnout, fully differential, AIN1(-) AIN2(+)

      SPI.transfer(0x02);  //Tells communications register that next operation is write to mode register.

      SPI.transfer(mode1);  //Tell it to take the reading as described by mode's bits

      SPI.transfer(mode2); 

      Serial.println("New mode register bytes are...");

      SPI.transfer(0x12);  //Tell comm register that next operation is read from mode register

      modedata1 = SPI.transfer(0x00);  // Read first byte from the mode register

      modedata2 = SPI.transfer(0x00);  // Read second byte from the mode register

      Serial.println(modedata1,BIN);  //print out mode data bytes to serial monitor

      Serial.println(modedata2,BIN);  //print out mode data bytes to serial monitor

      delay(1000);  //sit here a while to see if RDY ever goes low

      SPI.transfer(0x30);  //stop continuous conversion

      digitalWrite(40,LOW);  //reset level of logic analyzer trigger to get ready for next sweep

      digitalWrite(SS,HIGH); //deselect chip 

      delay(5000);  //wait 5 s before looping

    }

     

    319866a4116221178feca71c97ce4d1b.tiff

Children
No Data