I've noticed that the module's LEDs will flicker between states if it is on the edge of thresholds for charging during normal use. As it was implemented, single ADC readings were used to inform device decisions. It seems as noise in the ADC readings might result in single readings being inaccurate for informing the module's LED and charging states. I've decided to implement a simple moving average algorithm to smooth out any fluctuations.
Simply put, the MCU will collect ADC readings as they become available and immediately index them into a FILO queue. As new data becomes available, the oldest ADC data will be overwritten by the newest addition. A simple average is calculated using the data in this queue every time new data replaces old data. This average is then used to inform any decisions to change the LED state or cease/begin charging.
As the MCU is currently configured, it will collect new ADC readings and perform this averaging every 100 ms.
Zachary Murtishi
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.