Assume that the data is read from an 8-bit analog-to-digital (AD) converter. If a higher-order AD is used, the data type can be defined as integer. The function responsible for reading the data is called get_ad()
.
1. Limited Secondary Filtering
2. Median Value Filtering Method
/* N value can be adjusted based on actual requirements */
/* Sorting using the bubble sort method */
#define N 11
char filter()
{
char value_buf[N];
char count, i, j, temp;
for (count = 0; count < N; count++)
{
value_buf[count] = get_ad();
Delay();
}
for (j = 0; j < N - 1; j++)
{
for (i = 0; i < N - j; i++)
{
if (value_buf[i] > value_buf[i + 1])
{
temp = value_buf[i];
value_buf[i] = value_buf[i + 1];
value_buf[i + 1] = temp;
}
}
}
return value_buf[(N - 1) / 2];
}
3. Arithmetic Average Filtering Method
4. Recursive Average Filtering Method (Also Known as Sliding Average Filtering)
5. Median Average Filtering Method (Also Known as Anti-Pulse Interference Average Filtering)
/* This method combines median and average techniques to reduce noise and pulse interference */
#define N 12
char filter()
{
char count, i, j;
char value_buf[N];
int sum = 0;
for (count = 0; count < N; count++)
{
value_buf[count] = get_ad();
Delay();
}
for (j = 0; j < N - 1; j++)
{
for (i = 0; i < N - j; i++)
{
if (value_buf[i] > value_buf[i + 1])
{
char temp = value_buf[i];
value_buf[i] = value_buf[i + 1];
value_buf[i + 1] = temp;
}
}
}
for (count = 1; count < N - 1; count++)
{
sum += value_buf[count];
}
return (char)(sum / (N - 2));
}
These filtering methods are commonly used in embedded systems and real-time applications to improve signal quality by reducing noise and eliminating outliers. Each approach has its own advantages and trade-offs, so choosing the right one depends on the specific application and performance requirements.
Computer Monitor Stand, the multi-point silicone support surface is more non-slip, and the multi-point soft silicone design prevents the computer from scratching while anti-slip. Laptop Stand Amazon is lightweight design, the weight of about 10kgs is equivalent to the weight of a large number of mobile phones, easy to store and go whenever you want.
Monitor Stand Riser,Metal Desk Monitor Stand Riser,Dual Monitor Riser Stand,Universal Monitor Stand Riser
Shenzhen ChengRong Technology Co.,Ltd. , https://www.laptopstandsupplier.com