-
-
Notifications
You must be signed in to change notification settings - Fork 959
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
src/drivers/Bma421.cpp
Outdated
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
src/drivers/Bma421.cpp
Outdated
// Initialize interface | ||
auto ret = bma423_init(&bma); |
There was a problem hiding this comment.
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.
cc72c02
to
6b2d9d8
Compare
bce82e6
to
3af0804
Compare
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. |
Build checks have not completed. Possible reasons for this are:
|
Hi. I'm sorry, but I'm not active on this project anymore. You'll need to discuss this with @JF002. |
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).