This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to sample an accelerometer at high rate with minimal cpu usage

To reduce power, I'm trying to find the best approach to minimize the cpu load when sampling an accelerometer at a high rate, e.g. 1.6Khz. Is there a way to DMA a sensors fifo buffer/output registers into ram ? Either with the nRF51 or nRF52. Any other alternatives for reduced cpu usage ?

So far all I've come up with is : in order to fetch a predetermined number of samples, M, wait for an N sample fifo buffer on the sensor to almost fill up, then periodically (timer or event based), read the fifo before the fifo fills up and starts to overwrite and loose data. Repeat until you get M samples. This helps (the bigger the fifo the better), but less or no cpu involvement would be ideal.

Somewhat related is the effect of the softdevice. Assume either no connection, or a connection exists and no/minimal data packets are being sent or received on the ble connection (sampling the sensor and concurrently sending/receiving data is not required).

Thanks

Parents
  • I guess you will need the CPU at some point in order to do anything with the data you collect? But other then that you should be good using DMA. Depending on which interface you have with the sensor you may need the nRF52 as it has DMA for more peripherals than the nRF51. You can have DMA with both SPI and TWI/I2C on the nRF52. Please refer to the spec for details.

  • Thanks for the response. Yes, the cpu is needed to process a set of samples at some point, but the cost of reading a set of samples using the cpu (timer expires, read, repeat) is comparable to the cost of computing on that sample set, so eliminating the cpu from the reading process for the entire sample set will improve battery life nicely.

    The sensor has one set of registers that need to be read for one sample, read either at the sensors ODR or notified by an event, or when the fifo is filling up enough (if using a fifo on the sensor).

    I'm not sure how to setup a dma transfer to read a set of samples from the sensor as described (using i2c or spi). Can you point to me to something similar to get an idea ?

    Thanks

Reply
  • Thanks for the response. Yes, the cpu is needed to process a set of samples at some point, but the cost of reading a set of samples using the cpu (timer expires, read, repeat) is comparable to the cost of computing on that sample set, so eliminating the cpu from the reading process for the entire sample set will improve battery life nicely.

    The sensor has one set of registers that need to be read for one sample, read either at the sensors ODR or notified by an event, or when the fifo is filling up enough (if using a fifo on the sensor).

    I'm not sure how to setup a dma transfer to read a set of samples from the sensor as described (using i2c or spi). Can you point to me to something similar to get an idea ?

    Thanks

Children
No Data
Related