An Easy Introduction to Electrical Filters(TUTORIAL)

by TheG39 in Circuits > Sensors

586 Views, 2 Favorites, 0 Comments

An Easy Introduction to Electrical Filters(TUTORIAL)

simulation.PNG

Hello there,

Do you want to design an electrical filter to process some noisy signal from a sensor ? Are you just an hobbyist and/or not well versed in designing electrical filters and you are just looking for a quick and easy guide to different filters out there. Then this is the tutorial for you.

We will start with simple concepts on filter design and I will show you how to quickly design a rather complex filter using an easy to use software which offers tools for analyzing a filters performance. LETS GET STARTED!

Supplies

2x 75Kohm resistor

2x 22nF capacitors

2x arduinos or a signal generator and an oscilloscope if you have one

App(optional)Quick electrical filter design in case you want to design a filter in the future

Basic Intro

step.PNG

To design a low pass filter, a capacitor is used to "short" circuit the higher frequency but allow the lower frequencies to pass through. This happens as the impedance of the capacitor is much lower at higher and higher frequencies when compared to lower frequencies. In turn if you had an inductor instead of a capacitor, the inductor's impedance will get higher as you increase the frequency but acts more like a short circuit at lower frequencies.

So the key of designing filters is to know where to place the resistor,capacitor and or inductor to filter out unwanted frequencies.

Follow the diagram shown for a mathematical explanation.

NB: Although you can use inductors, it's much more easier to use capacitors and resistors in place of an inductor as coils tend to be bulkier and more expensive when compared to cheap resistors and capacitors.

Simulation

RC filter.jpg
RC filter.PNG
response.PNG

To obtain the system's response test run a simulation on MATLAB or Octave. For now I am going to test on octave which is free and can be used from a browser octave

For a cutoff frequency of 1.59Hz the values I have selected are 1kOhms and 100uF capacitor configured to form a low pass RC filter.

Run the following script:

R = 1000; C= 100e-6;

h = tf([1/(R*C)], [1 1/(R*C)]);

bode(h);

Note the slope of the magnitude response.The slope happens begins to become more steep at 1.59Hz(-3dB) meaning that if you had a signal of sin(2*pi*1.59*t) the signal will have lost 50% of its power or 0.707*sin(2*pi*1.59*t). This shows that the system is a low pass filter. If the slope happened first and flat lined at higher frequency then it will be a high pass.

Test the Circuit

IMG_20200407_191928_0.jpg

Using one arduino as a signal generator and another as an oscilloscope test the circuit. If you have an oscilloscope and a signal generator use them instead.

For the signal generator (You could use the timer interrupts)

[code]
boolean pinState = false;

long prevReadTime;

void setup() {

pinMode(13, OUTPUT);

digitalWrite(13, pinState);

prevReadTime = millis();

}

void loop() {

if (millis()-prevReadTime >=500){

pinState = !pinState;

digitalWrite(13,pinState);

prevReadTime = millis();

}

}

[/code]

For the oscilloscope

[code]
void setup() {

Serial.begin(9600);

}

void loop() {

Serial.print(analogRead(A0));

Serial.print(",");

Serial.println(analogRead(A1));

}

[/code]

Results

filtering result.PNG

Here are the results that i obtained from my crude setup. Note the blue line is lagging behind the red line.

What's Next

bilinear low pass filter.jpg
CLR filter.jpg
high pass filter.jpg
single frequency narrow band pass filter.jpg
wide band pass filter.jpg
single frequency reject.jpg
Electrical filter design app

If you want to continue on your filter selection journey, I would recommend the following app Quick Electrical Filter design, which has more filters,simulation tools and their responses.Above are some selection of filters in the app.

Have fun