Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BMA421: Use internal FIFO for smoothing #1145

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

StarGate01
Copy link
Contributor

@StarGate01 StarGate01 commented May 18, 2022

This PR has been broken out of #1132 / #1050.

The BMA421 acceleration chip has an internal FIFO buffer. This buffer is now used to calculate the smoothed output signal. This generates a cleaner signal, and provides the FIFO data for further processing (see #1133). The sampling rate has been increased to 200 Hz, which gives roughly 20 samples per Infinitime sensor loop (100ms cycle).

Copy link
Contributor

@Riksu9000 Riksu9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current way works fine, but accessing more data can be useful in the future.

More frequent data and some history would be useful in the raise to wake gesture for example. This also raises the question of how much data should be stored and at what frequency, considering the memory limitations.

I'm assuming the fifo array gets overridden each time the values are processed and the amount of data can vary, which can be problematic when using this data elsewhere. I would expect there to be something like a circular buffer.

Comment on lines 72 to 96
accel_conf.odr = BMA4_OUTPUT_DATA_RATE_100HZ;
accel_conf.odr = BMA4_OUTPUT_DATA_RATE_200HZ;
accel_conf.range = BMA4_ACCEL_RANGE_2G;
accel_conf.bandwidth = BMA4_ACCEL_NORMAL_AVG4;
accel_conf.perf_mode = BMA4_CIC_AVG_MODE;
accel_conf.perf_mode = BMA4_CONTINUOUS_MODE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these changes have an impact on power usage? Do we need such frequent data?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

200 Hz is the maximum data rate which can be read by the watch, since the FIFO is able to capture 32 samples at most, and the sensor cycle time is 100 ms. This gives 20 samples per cycle at a sample rate of 200 Hz. I chose this sample rate because I needed the best possible data for #1133 .

BMA4_CIC_AVG_MODE and BMA4_CONTINUOUS_MODE should make no difference in power consumption, since the internal sample rate stays the same, the AVG mode just averages the samples together. I theory, operating the sensor in continuous mode even offloads some calculations from the sensor chip.

According to the datasheet at https://datasheet.lcsc.com/lcsc/1912111437_Bosch-Sensortec-BMA425_C437656.pdf , the power consumption in normal mode is not correlated to the sampling frequency. This is only the case in low power mode, which was not used here before and still is not used.

Comment on lines 42 to 52
// Initialize interface
auto ret = bma423_init(&bma);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally don't think most of these added comments are required to explain what is happening.

@StarGate01
Copy link
Contributor Author

Hey @Riksu9000 I am picking this project back up, and slowly rebasing all my PRs which will take some time.

This one is quite easy. I have cleaned up the comments as you suggested.

Copy link

Build checks have not completed. Possible reasons for this are:

  1. The checks need to be approved by a maintainer
  2. The branch has conflicts
  3. The firmware build has failed

@StarGate01 StarGate01 marked this pull request as draft May 13, 2024 14:18
@Riksu9000
Copy link
Contributor

Hi. I'm sorry, but I'm not active on this project anymore. You'll need to discuss this with @JF002.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants