Post Go back to editing

No meaningful data being read from the ADC register output of the CN0540 using a Teensy 4.1

I am using a Teensy with a default clock of 600MHz and am able to read and write to the registers of the AD7768 successfully. I am also able to read data from the ADC registers. However the readings are just noise. I have attached the probe output when reading data from the ADC output. The signals probed in order from top to bottom are Chip Select/Enable, Clock, MOSI, MISO, DRDY and SYNC_IN. I have scoured AD7768 discussion boards and similar issues with random data being read have been reported; but no solutions provided other than potential grounding problems. I did try working on grounding; but that didn't help.

FYI: When I use the DE-10 to stream data instead of the Teensy, I am getting meaningful data under the same conditions and default filter/register settings.

Parents
  • FormerMember
    0 FormerMember
on Dec 2, 2021 1:39 PM

Hi Girija,

Can you send a picture of your setup when you are using the Teensy?  What are you measuring?  What software are you using when you are probing?  Or are you bit banging with the Teensy trying to setup the registers directly with that?  And if so, what is your order of operations for those commands? 

Looking at your data collection each ADC register read appears to be coming back as 8-bits.  So this being a 24-bit converter requires 3 sequential reads to obtain the complete ADC reading.  If you look at 3 readings in a row you see 0x FE-31-48, 0xFE-31-79, 0xFE-31-1D, 0xFE-31-53  so there is a repeating pattern and the data doesn't appear to be complete noise (the last 8 LSB's are bouncing around a little which could be cause of what you are measuring 0x48-0x1D)

What I would do is come that data with the data from the DE10-Nano and IIO-Oscilloscope and see if things are more closely matched.

Hope this helps solve some things, if not let me know and we can dig in more.

Cheers,

Brandon

  • Picture and Teensy code are attached. Yes; I am bit shifting and reading thrice to get the final result. I am using a Kingst LA1010 Logic Analyzer to probe the pins and using in-built Arduino-SPI commands in the code. For the bench setup, I just shake the CN0532 board to check if the output graphical values indicate the right movements. When I do a similar test with the DE-10 (CN0549) setup, this sanity check indicates that the readings are matching up to the accelerometer movements.

    // the sensor communicates using SPI, so include the library:
    #include <SPI.h>
    #include <SD.h>
    #include <avr/io.h>
    #include <avr/interrupt.h>
    
    const int CardSelect = BUILTIN_SDCARD;
    //Sensor's memory register addresses:
    const int CHIP_TYPE = 0x03;      //8 bit value and reset is 7
    const int PRODUCTID = 0x04;  //8 bit and reset is 1
    const int POWER_CLOCK = 0x15;   //8 bit and reset is 0
    const int ADC_DATA = 0x2C;   //24 bit conversion result
    const byte READ = 0b01000000;     // AD7768's read command
    const byte WRITE = 0b00000000;   // AD7768's write command
    String tempString;
    
    // pins used for the connection with the sensor
    // the other you need are controlled by the SPI library):
    const int dataReadyPin = 2;
    const int chipSelectPin = 10;
    const int button = 4;
    
    void setup() {
      Serial.begin(115200);
      // start the SPI library:
      SPI.begin();
    
      // initalize the  data ready and chip select pins
      pinMode(dataReadyPin, INPUT);
      pinMode(chipSelectPin, OUTPUT);
      pinMode(3, OUTPUT);
     
      digitalWrite (chipSelectPin, HIGH);
      digitalWrite (11, HIGH);
    
      digitalWrite (3, LOW);
      delayMicroseconds (20);
      digitalWrite (3, HIGH);
      
      attachInterrupt(digitalPinToInterrupt(2), blink, CHANGE);
      //attachInterrupt(digitalPinToInterrupt(4), press (myFile), CHANGE);
    
    }
    
    void loop() {
    }
    
    //Read from or write to register from the SCP1000:
    unsigned int readRegister(byte thisRegister, int bytesToRead ) {
      byte inByte = 0;
     
      digitalWrite (11, HIGH);
      // gain control of the SPI port
      // and configure settings
      SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
      
      // take the chip select low to select the device:
      digitalWrite(chipSelectPin, LOW);
    
      int result = SPI.transfer(0x00);
      bytesToRead--;
      // if you still have another byte to read:
      while (bytesToRead > 0) {
        // shift the first byte left, then get the second byte:
        result = result << 8;
        inByte = SPI.transfer(0x00);
      
        // combine the byte you just got with the previous one:
        result = result | inByte;
        // decrement the number of bytes left to read:
        bytesToRead--;
        
      }
      
    
     Serial.println(result);
     
     // take the chip select high to de-select:
      digitalWrite(chipSelectPin, HIGH);
     
     // release control of the SPI port
      SPI.endTransaction();
      
     digitalWrite (3, LOW);
     delayMicroseconds (20);
     digitalWrite (3, HIGH);
    }
    
    
    //Sends a write command to SCP1000
    
    void writeRegister(byte thisRegister, byte thisValue) {
    
      byte dataToSend = thisRegister | WRITE;
    
      // gain control of the SPI port
      // and configure settings
      SPI.beginTransaction(SPISettings(24000000, MSBFIRST, SPI_MODE3));
      // take the chip select low to select the device:
      digitalWrite(chipSelectPin, LOW);
    
      SPI.transfer(dataToSend); //Send register location
      SPI.transfer(thisValue);  //Send value to record into register
    
      // take the chip select high to de-select:
      digitalWrite(chipSelectPin, HIGH);
      // release control of the SPI port
      SPI.endTransaction();
    }
    
    void blink() {
      readRegister(0x2C,3);
    
    }
    
    int press(File myFile) {
      myFile.close();
    }

  • Can we have a chat sometime? I still don't have any luck getting meaningful data out. Turns out the DE-10 system does not allow any of the registers to be configured (so it can only be used in the default settings). Also, there is a mismatch between the pinouts in the schematic and the ones marked on the board for block P8 of the CN0540. I need to understand if I am better off using another product line. Is the CN0540 a beta release?

  • Reply
    • Can we have a chat sometime? I still don't have any luck getting meaningful data out. Turns out the DE-10 system does not allow any of the registers to be configured (so it can only be used in the default settings). Also, there is a mismatch between the pinouts in the schematic and the ones marked on the board for block P8 of the CN0540. I need to understand if I am better off using another product line. Is the CN0540 a beta release?

    Children