# Experimenting with inductors blog Part 2: Filters and design of LPF for extracting sine wave from square wave

Posted by rsjawale24 in Experimenting with Inductors on Feb 17, 2020 12:31:00 PMThis is the second blog in my experimenting with inductors challenge. In my last blog, I talked about Fourier series and how we can prove it experimentally using filters.

In the 2nd part of the blog I'm going to cover the following topics-

**Basics of filters,****How to write the transfer function of a filter,****How to identify the response of filter,****Bode plot and****Implementing a low pass filter circuit for fourier series experiment**

## What is a filter?

A filter is a frequency selective circuit, which means it can allow or block a signal of certain frequency. It depends on the nature of filter whether it will allow the signal to pass or block the signal which also explains why it is named as a filter. The frequency above or below which the filter allows or blocks the signal is called as the cutoff frequency of the filter. To be more specific, cutoff frequency is defined as the frequecny at which a signal's amplitude becomes 3dB less than the maximum amplitude or half the voltage of it'd maximum voltage.

Filter circuits can be made using the three basic components - R, L and C.

A filter should compulsorily have a reactive component or a component whose impedance changes with frequency. Which means the combinations of RC, RL and LC can act as filter.

In practice there are various types of filters, **Low Pass Filter (LPF), High Pass Filter(HPF), Band Pass Filter(BPF) and Band reject filter** I will cover some of them here.

**Low Pass Filter (LPF)**

A low pass filter, as the name suggest will pass/allow signal of a frequency lower than the cutoff frequency of the filter. For example, if a LPF has a cutoff frequency of 1kHZ, it will allow all the signals of frequency lower than 1kHz but will attenuate the signals above 1kHZ. A low pass filter can be implemented using either RC or LC or RL.

Figure below shows RC LPF, LC LPF and the formula for cutoff frequency.

From the formulas, it is clear that the cutoff frequency of the filter varies on the values of R and C or L and C chosen.

**High Pass Filter(HPF)**

A HPF as the name suggests is a filter circuit that will block all the signals with frequencies below a certain frequency and allow the signals with higher frequency.

Since, this is just the opposite of LPF, a HPF can be made by interchanging the positions of R and C in RC low pass filter and L and C in LC low pass filter.

Below is the circuit diagram for RC HPF and LC HPF

Note that the formula for the cutoff frequency for HPF remains the same as LPF. Only by interchanging the positions of the R and C or L and C are interchanged.

**Band Pass Filter(BPF)**

As the name suggests a band pass filter will allow a band of frequencies to pass and reject all other frequencies. A simple BPF can be made by cascading a HPF and LPF.

First, the HPF will block lower frequencies and then a LPF can block the higher frequencies.

For example, a HPF with cutoff frequency of 1kHz will pass all signals above 1kHz and then a LPF with cutoff frequency of 1.1kHz cascaded with the HPF will block all the frequencies above 1.1kHz but allow frequencies below 1.1kHz. This way we have a circuit which is allowing a band from 1kHz to 1.1kHz to pass. The bandwidth is equal to 1.1kHz-1kHz = 0.1kHz or 100Hz.

** How to identify whether the filter is low pass, high pass, band pass or band reject?**

A very easy method of doing so is by checking the circuit for open/short condition by assuming the frequencies to be 0 and infinite. For example, the first RC filter at 0 frequency, the capacitor will act as an open circuit, which means whatever signal is applied at the input will be passed to the output. Whereas, for high frequency, the capacitor will have some reactance which can be calculated by Xc = 1/j*2*pi*C, where f is the operating frequency and C is value of Capacitance.

Now, by using voltage division rule, there will be some voltage drop across the C due to it's reactance, and hence it will offer impedance to the current flow.

Similarly, for LC LPF, the L will act as short circuit for 0Hz/lower frequency and C will act as open circuit. For higher frequency the inductor will provide very high reactance, XL = j*2*pi*f*L

Another method of doing so is by writing the **transfer function** of the given circuit. To write the transfer function, we first need to draw the laplace equivalent circuit of the filter.

**How to write the transfer function of a filter**

Transfer function of any electrical circuit is an equivalent circuit representation using some mathematical transform or it gives the relation between input and output of the circuit in transform domain.

Laplace transform of L and C -

In Laplace domain, an inductor can be replaced by sL where,

s =j*w,

w = frequency in radians,

L = inductance

Whereas, a capacitor can be replaced by 1/sC.

After replacing the L and C in the filter circuit with it's Laplace equivalent, a relation between output voltage and input voltage can be written using basic voltage or current division rule.

The photo below shows the Laplace domain circuit for RC filter and output and input voltage relations

The final **Vo(s)/Vi(s) is called as the transfer function**(TF) of the filter. Now putting** s=j*w** and varying w one can calulate the **magnitude of Vo(s)/Vi(s)** value for given R*C.

If you plot the **magnitude of Vo(s)/Vi(s) Vs. frequency** , this plot is called as a **bode plot**. By looking at a bode plot, one can very easily identify the filter circuit.

**Order of filter**

The **power of 's'** in the TF gives the order of the filter. Or the **number of poles** of the TF gives the order of TF.

For finding the poles of a TF, **equate the expression in the** **denominator to 0 and solve for s**.

For example, in he above TF, the power of s is 1 or TF has one pole (1+sRC = 0 => s=-1/RC) at frequency =fc, which means that an RC filter is a **first order filter**.

The order of filter determines the **rate** at which the signal will undergo **attenuation** at the cutoff frequency. For every pole, the attenuation is** -20dB/decade**, for 2 poles at same frequency, the attenuation rate is -40dB/decade which means more sharper attenuation at the cutoff frequency.

Similarly, a simple LC filter will always have an **order of 2**. You can try writing the TF for LC filter.

## Implementating a LC low pass filter and extracting the fundamental frequency sien wave from square wave

I have implemented a low pass filter to **filter out a sine wave out of a square wave**. As we all saw in my last blog that a **square wave is made up of sum of inifinte harmonics of sine wave.**

Which means, we can produce a sine wave from a square wave if we are able to somehow separate the individual harmonics. The filter circuits help in filtering the frequencies and separating the harmonics.

### Design

Firstly, I chose a L from the Kemet Inductors Kit, 2.2mH L and then a standard value of C (in my case C = 0.01 uF).

Then, using the formula the cutoff frequency is obtained as 33.9kHz.

Using a signal generator, I generated a square wave of 33.9 kHz. The screenshot below of DSO shows the square wave output from the signal generator.

Now, this square wave contains a fundamental sine wave of 33.9 kHz and harmonics of the 33.9kHz wave. I tried filtering the fundamental sinusoid from the square wave by using the LC LPF above.

First, I used only a single LC LPF (order 2) and

This is what I obtained after filtering the above square wave

As it can be seen on the DSO, the output of the filter is a sine wave of the same frequency as the input (There's a small frequecy deviation as the signal generator is not stable).

But as it can be seen that the signal doesn't look like a perfect sine wave, I cascaded another LC LPF with same L and C value to create a 4th order LPF which can give a much sharper attenuation of -80dB/decade

I obtained the below output using 4th order LC LPF.

The sine wave is less distorted and frquency is also same. Here, we have succesfully, extracted the sine wave of fundamental frequency from a sqaure wave.

**This circuit can also be used as a sqaure to sine converter.**

One can construct BPFs and separate other harmonics too, but that would require lots of inductors and capacitors.

Hence, I have succesfully **demonstrated the fourier series** by separating the fundamental frequency from the square wave. One can separate other harmonics too.

Remember engineering is always fun when done practically and one needs to be passionate enough to implement thoery in practical applications.

Also, don't forget to check out the video of the Tenma LCR meter.

## Comments