-
-
Notifications
You must be signed in to change notification settings - Fork 894
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
Power optimization - Increase SystemTaskPeriod. #1757
base: main
Are you sure you want to change the base?
Conversation
Increase the timeout on the message queue in SystemTask. This reduces the power consumption by 60-70µs in sleep mode.
Build size and comparison to main:
|
Super cool to see all the power optimisations inbound! |
No motion-based wake algorithm will work with this massively increased period. Perhaps it could be set to 4 seconds if it's sleeping and there are no motion wake algorithms enabled? |
Yes, you're both right, this optimization is a bit too aggressive.
That's probably the way to go ! |
Improve the timeout on the queue : by default, the timeout is 100ms, and it's extended to 4s in sleep mode, when no motion based wake up option is enabled.
525f1a2
to
491d3ae
Compare
There are many things that rely on the SystemTask loop period, not just motion. Have you considered all of them so they don't cause issues? Ideally all periodic tasks should be moved away from the message handling loop, so the period can be set to infinite. In your measurement, did you have motion wake up methods enabled, i.e. did UpdateMotion() return early? If not, I'd like to see the power consumption measured again with two different periods, without the automatic period switching, but motion disabled in both tests by disabling motion wake up methods. |
The period cannot be set to Infinite, it must actually be shorter than the period of the watchdog. That's exactly why I chose to run all background tasks in SystemTask : if SystemTask does not run correctly, we cannot guarantee the good state of the system, so we let the watchdog reset the board.
I've just done the measurements :
Note that motion algorithms and low level driver could probably be improved by using the hardware FIFO and the "motion/no-motion" interrupt pin to reduce the power usage. |
Increase the SystemTask period also when the notification mode is set to Sleep (as it also disables the motion-based wake options).
I went through the tasks that are run in the loop and the noteworthy observations are that the system time may only be updated once every four seconds, which could have unintended consequences, and BleDiscoveryTimer is not working as intended. There's a comment that says service discovery is deferred for 3 seconds, but this doesn't seem to be true, and changing the period will impact it further. It should be re-evaluated and probably use a proper timer.
I would like to see the power consumption difference between the different periods set statically, with motion disabled in both tests. The behavior when motion is enabled shouldn't be affected by this PR, so we're only interested in seeing the difference when motion is disabled. Or was this how you measured the 60-70µA difference? |
This are valid concerns. I'll check them and see if I can solve those issue in this PR or if they'll need more work. |
Increase the timeout on the message queue in SystemTask. This reduces the power consumption by 60-70µs in sleep mode.