Introduction to digital filtering algorithms for C language source programs (nine kinds)

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

Introduction to digital filtering algorithms for C language source programs (nine kinds)

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

Introduction to digital filtering algorithms for C language source programs (nine kinds)

4. Recursive Average Filtering Method (Also Known as Sliding Average Filtering)

Introduction to digital filtering algorithms for C language source programs (nine kinds)

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.

Monitor Stand Riser

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.


Shenzhen Chengrong Technology Co.ltd is a high-quality enterprise specializing in metal stamping and CNC production for 12 years. The company mainly aims at the R&D, production and sales of Notebook Laptop Stands and Mobile Phone Stands. From the mold design and processing to machining and product surface oxidation, spraying treatment etc ,integration can fully meet the various processing needs of customers. Have a complete and scientific quality management system, strength and product quality are recognized and trusted by the industry, to meet changing economic and social needs .

Laptop Stand for Notebook

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

Posted on