A new algorithm for battery voltage filtering

A new algorithm for battery voltage filtering

For the battery voltage collected by ADC before, in order to calculate the electric quantity and prevent the fluctuation of the battery voltage from causing the electric quantity calculation deviation, it will take the sampled battery voltage several times and average it, or roll it with the value taken several times before. On average, this method generally creates an array to store these values, which will occupy a certain amount of memory; today, I learned a new processing method from the customer, and record it.
In fact, the method is very simple to perform first-order low-pass filtering on the battery voltage . The specific function is as follows:
Y(n) = αX(n)+(1-α)Y(n-1);
X(n) represents the current sampling Value;
Y(n-1) represents the calculated value of the last time;
Y(n) represents the calculated value of this time;
α represents the filter coefficient, the larger the value, the larger the proportion of the sampled value this time;

Guess you like

Origin blog.csdn.net/weixin_43704402/article/details/111589157