Trying to implement a real-time data processing feature using Edge Computing on the AVR128DA48

Still on my project, I’m trying to implement a real-time data processing feature using Edge Computing on the AVR128DA48. The goal is to perform basic filtering on the sensor data ( removing noise from the vibration sensor). Here’s my simple filtering code:
int16_t filter_data(int16_t raw_data) {
static int16_t last_data = 0;
return (last_data + raw_data) / 2;
}
int16_t filter_data(int16_t raw_data) {
static int16_t last_data = 0;
return (last_data + raw_data) / 2;
}
I expected the filtered data to be smoother, but I’m still seeing a lot of noise. Is this filtering method too just there(simple) for real-time processing? and how can I implement a more robust filtering algorithm on the AVR128DA48?
2 Replies
Marvee Amasi
Marvee Amasi2mo ago
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;
}
Marvee Amasi
Marvee Amasi2mo ago
Alpha is the smoothing factor that I used there . The smaller the value, the smoother the output but slower to react to changes. A value between 0.05 and 0.3 is usually a good starting point Filtered data is calculated by weighting the new data raw_data and the previous filtered result
Want results from more Discord servers?
Add your server