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.

ADS7028: Issue reading data from the ADS7028

Part Number: ADS7028

I am trying to use the ADS7028 IC to use it's special feature in outputting a 16 bit RMS reading from one of it's eight input channels.

I created a circuit board for it and have it hooked up to an Adafruit ESP32 feather development board through it's SPI channel. After hours of debugging I still haven't been able to get any (meaningful) data from the SDO pin from the ADS7028. 

Upon attaching a logic analyzer to the SPI channel, everything on the CS, SDI, and SCLK pins looks as it should be. However, oddly on the SDO pin as soon as I bring the CS pin low to initiate an SPI read or write, the SDO pin immediately starts showing activity, even before the SCLK starts moving. Nothing in my firmware would suggest I'm doing anything wrong with the SPI transfer. I'm really at a loss for what could be going on here.

I can attach board and schematic files, firmware, the output of the logic analyzer, or even just a picture of my setup if that would be helpful in figuring out what this issue might be with the SDO line.


As always thanks for your help!

Ben

  • Hello Ben,

    The bus image you are sharing shows that you are reading the RECENT_CH1_LSB register. 

    This is not where the RMS data will be stored. The RMS data can be read from the (0xC1) RMS_LSB and the  (0xC2) RMS_MSB registers. Since only one channel can be used for RMS, there is a specified register to store this data. 

    Also the RECENT_CH1_LSB register will only be updated if the the STATS_EN bit in the GENERAL_CFG register is set. 

    I hope this helps. If not, I would suggest we go over the device set up configurations to assure the device settings are correct and data is being collected correctly. 

    Regards,

    Cynthia

  • Sorry, I didn't mean to be confusing. Eventually I want to read an RMS voltage, but first, I am just trying to see if I can read the voltage off of one of the channels (in this case channel 1) to make sure the device is operational.


    I'll attach the code that I am running. The part that is confusing to me is that the SDO line is being pulled high as soon as CS goes low. I would have thought that the SDO line would only switch states on the rising or falling edge of the CLK. It seems like that is what is causing me not to get any meaningful data but I am unsure.

    This is the arduino sketch that I'm running. In the setup loop I'm writing to four registers to set up the device so that all the input channels are analog inputs, the device is set to manual mode, and then in the channel register setting it to one to look at channel 1.


    In the main loop I'm reading from register A2 and A3 to look at the MSB and LSB of the latest data from channel 1.




    #include <SPI.h>
    const byte READ = 0b00010000;     // ADS7028's read command
    const byte WRITE = 0b00001000;   // ADS7028's write command
    
    //ADDRESSES
    const byte PIN_CFG = 0x5;
    const byte OPMODE_CFG = 0x4;
    const byte SEQUENCE_CFG = 0x10;
    const byte CHANNEL_SEL = 0x11;
    
    // pins used for the connection with the sensor
    // the other you need are controlled by the SPI library):
    const int chipSelectPin = 10;
    const int testPin = 21;
    
    void setup()
    {
      Serial.begin(9600);
      //SPI Settings
      //SPI.beginTransaction(SPISettings(60000000, MSBFIRST, SPI_MODE0));
      SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE0));
    
      // start the SPI library:
      SPI.begin();
    
      pinMode(chipSelectPin, OUTPUT); // Set GPIO22 as digital output pin
      digitalWrite(chipSelectPin, HIGH);
    
    
      //For manual mode
      //Using PIN_CFG (Section 8.4.2)
      //Configure channels as AIN/GPIO
      delay(10);
      writeRegister(PIN_CFG, 0x00);
      //Select manual mode
      //CONV_MODE = 00b
      delay(10);
      writeRegister(OPMODE_CFG, 0x00);
      //SEQ_MODE = 00b
      delay(10);
      writeRegister(SEQUENCE_CFG, 0x00);
      //Configure desired channel ID in MANUAL_CHID field
      //Select channel 1
      delay(10);
      writeRegister(CHANNEL_SEL, 0b00000001);
      delay(100);
      
    }
    
    void loop(){
      byte MSB = 0x00;
      byte LSB = 0x00;
      uint16_t analogData = 0;
    
      LSB = readRegister(0xA2);
      delay(5);
      MSB = readRegister(0xA3);
      analogData = ((MSB << 8) | LSB);
      
      Serial.print("Data is: ");
      Serial.println(analogData);
    
      delay(500);  // delay of one second
    }
    
    
    
    
    
    unsigned int readRegister(byte thisRegister) {
      byte dummyData = 0b00000000;
      byte inByte = 0; //incoming data from ADS7038
      byte buffer[] = {READ, thisRegister, dummyData}; 
      unsigned int result = 0;   // result to return
    
      //Bring CS low to initiate read
      digitalWrite(chipSelectPin, LOW);
    
      //Initiate transfer
      SPI.transfer(buffer, sizeof(buffer));
    
      //Bring CS high to decode read command
      digitalWrite(chipSelectPin, HIGH);
      delayMicroseconds(1);
      
      //Bring CS low to read requested register data
      digitalWrite(chipSelectPin, LOW);
      inByte = SPI.transfer(0x00);
      result = result | inByte;
      
    
      //End of SPI read
      digitalWrite(chipSelectPin, HIGH);
      return (result);
    }
    
    void writeRegister(byte thisRegister, byte thisValue) {
    
      byte buffer[] = {WRITE, thisRegister, thisValue}; 
      digitalWrite(chipSelectPin, LOW);
      SPI.transfer(buffer, sizeof(buffer));
      digitalWrite(chipSelectPin, HIGH);
    }




  • The digital bus will go into tri-state when CS is high, thus the state of SDO can remain high or low, based on the past state it was in before CS went high. The state of SDO will not affect the new frame of data, thus it should not have an affect on the accuracy of the device output.

    Thank you for sharing code, but what would be best is an oscilloscope shot of the digital bus, including, CS, SDI, SDO, SCLK. this will help in debugging by confirming that what is expected to be transmitted is in fact what is occurring on the bus. Please share the frame with the concern. 

    In manual mode, the ADC measurement data is not stored in any registers. The RECENT registers are only updated in autonomous mode; this also needs to be enabled by setting the STATS_EN bit in the GENERAL_CFG register. To read data in manual mode the device only needs a new frame with the correct number of clock pulses, and will be available in N+2 frames.

    Regards

    Cynthia