Marvee Amasi
Marvee Amasi
Trying to implement a real-time data processing feature using Edge Computing on the AVR128DA48
EMA filter smooths signals by applying a weighting factor to the most recent data point, it will reduce the effect of noise. update your filtering code using an EMA filter:
int16_t filter_data(int16_t raw_data) {
static int16_t filtered_data = 0;
float alpha = 0.1; // Smoothing factor (0 < alpha <= 1, lower values = smoother)

filtered_data = (int16_t)(alpha * raw_data + (1.0 - alpha) * filtered_data);
return filtered_data;
}
int16_t filter_data(int16_t raw_data) {
static int16_t filtered_data = 0;
float alpha = 0.1; // Smoothing factor (0 < alpha <= 1, lower values = smoother)

filtered_data = (int16_t)(alpha * raw_data + (1.0 - alpha) * filtered_data);
return filtered_data;
}
3 replies