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.

ADS1263: High Sampling frequency on Raspberry Pi 4 model B

Part Number: ADS1263

Good afternoon,

I have only a few months of experience in programming and measuring with electronic devices. I recently bought a RPi hat ADS1263 (https://www.waveshare.com/18983.htm). My aim is to measure accelerations at about 14k SPS with a Raspberry Pi, and log these accelerations into a csv file, for further analysis. The problem is that I am currently stuck at about 600 SPS (not stable).

I have looked deeply into the datasheet, and the python libraries and couldn't find any parameter that would have an influence, except by changing the data rate ; even when selecting a data rate of 1200 SPS, or higher, I still have less than 600 SPS.

I suppose the problem comes from my code, but I couldn't find any code or indication on the internet. So here is my question: What are the parameters I should modify in the python libraries, and what code structure should I use?

I suspect the problem is that I put the reading function into a loop, and that the frequency at which the loop is achieved depends on the RPi, not on the ADC ; however I don't know how else I am suppose to read and log the values.

Currently, my code is structured as following:

Initialization of the module (function ADC.ADS1263_init() )

While (duration < 5s):

      reading function (ADC.ADS1263_GetChannalValue)

      Value added to an array

Array to csv file

Module exit (ADC.ADS1263_Exit() )

I would be amazingly grateful if someone had a piece of code, or at least concrete indications on how to achieve 14k SPS measurements.

Thank you very much

Thomas

  • Hi Thomas,

    Some questions for you:

    1. What data rate and filter option did you choose for your application?
    2. Are you using continuous conversion mode or pulse convert mode?
    3. Are you multiplexing through channels or measuring one channel continuously?

    The ADC conversion latency will generally not be 1/ODR for the first conversion, where ODR = output data rate. See Table 9-13 in the ADS1263 datasheet. For example, if you choose 1200 SPS and Sinc4 filter, the first conversion result would be available in 3.758ms. This is equal to ~266 SPS, and accounts for the digital filter settling as well as some internal overhead time to begin a conversion. Second and subsequent conversions do arrive at 1/ODR in continuous conversion mode (not pulse convert mode however). Therefore, depending on how you are sampling, you should not necessarily expect a conversion latency of 1/ODR

    I will also mention that TI does not manufacture the Waveshare board you are using so our support for this board is limited. We can try to help diagnose any ADC issues, though these might be hard to decouple from the board design.

    -Bryan

  • Hello Bryan, thank you very much for your reply.

    1. For the data rate, I selected 1200 SPS. As for the filter, I had seen in the datasheet that the filter FIR is selected by default (and not relevant over 20SPS), and even looking deeply into the libraries I haven't found the way to change it for Sinc4 for example... Indeed finding how to change the filter is probably a key factor here.

    2. I am using continuous conversion mode, because it is the mode configured by default, and same as for the filter, I haven't found the function to change it...

    3. I suppose I am measuring one channel continuously, because I am using the function "GetChannelValue(Channel)" and not the function "GetAllChannelsValue", that is also available.

    I had read (I think on this forum) that the first conversion would take more time, for me it isn't a problem.

    Do you have any idea on what python function I should be using to change the filter? And in your opinion, do you think it would solve my problem?

    Thank you

    Thomas

  • As a complement, here is a part of the code of the python library:

    #The configuration parameters of ADC, gain and data rate
    def ADS1263_ConfigADC(self, gain, drate):
      MODE2 = 0x80
      MODE2 |= (gain << 4) | drate
      self.ADS1263_WriteReg(ADS1263_REG['REG_MODE2'], MODE2)
      if(self.ADS1263_ReadData(ADS1263_REG['REG_MODE2'])[0] == MODE2):
        print("REG_MODE2 success")
      else:
        print("REG_MODE2 unsuccess")

      REFMUX = 0x24
      self.ADS1263_WriteReg(ADS1263_REG['REG_REFMUX'], REFMUX)
      if(self.ADS1263_ReadData(ADS1263_REG['REG_REFMUX'])[0] == REFMUX):
        print("REG_REFMUX success")
      else:
        print("REG_REFMUX unsuccess")

      MODE0 = ADS1263_DELAY['ADS1263_DELAY_0s']
      self.ADS1263_WriteReg(ADS1263_REG['REG_MODE0'], MODE0)
      if(self.ADS1263_ReadData(ADS1263_REG['REG_MODE0'])[0] == MODE0):
        print("REG_MODE0 success")
      else:
        print("REG_MODE0 unsuccess")

    ######

    I suppose that the definition of MODE1 is missing, as it seems to be the mode in which the filter is defined (page 92 of the datasheet https://www.waveshare.com/w/upload/2/2a/Ads1262.pdf). However I have no idea how to define MODE1 in order to choose the filter...

  • Hi Thomas,

    I am not aware of any existing libraries (in python or any other coding language) for the ADS1263. And since this code is third-party, we typically only offer limited support. If you do need help writing specific functions for the Raspberry pi, python, etc., I would suggest posting in the MCU's forum.

    If you are able to begin writing new functions or modifying existing ones, I would start by reading back the ADC registers to see what values are stored there after initialization. This will give us a good idea of how the ADC is behaving once conversions are started, and then how you can/should modify the register settings in order to get the functionality you need.

    It would also help to know how the MCU starts the ADC conversion process: with the START pin, via the START/STOP commands, etc.? Does this just occur once at the beginning of the conversion process, or does the MCU continually toggle the pin or send the commands?

    Then, you should look for how the MCU knows when data is ready and how that data is requested from the ADC: are they using the DRDY pin, or some other method?

    Answering some of these questions will certainly help figure out what, if anything, is going on with this device. If you have a logic analyzer that would certainly help diagnose these issues faster.

    -Bryan