The Classroom

RLC Filters

Ins-and-outs of RLC Filter Design

DIYODE Magazine

Issue 62, September 2022

This article includes additional downloadable resources.
Please log in to access.

Log in

There are a lot of different ways we could start talking about this Classroom due to the sheer variety of RLC filters and the applications of each type. We covered filters back in Issue 15 - nearly four years ago now - so it’s probably time for a refresher! Let’s start at the basics and work up from there. We’ll also go through some other filter variants and explain the ins-and-outs of each.

What is a filter?

The engineers reading this are probably rolling their eyes and skipping a few pages right now, but for the rest of us the word ‘filter’ in the context of electronics may be quite mystifying. After all, aren't they those things you put underneath ground coffee and pour boiling water over?

Conceptually, they actually aren’t much different. A coffee filter prevents grains of coffee from passing through to your hot cuppa, while allowing the coffee-infused water to pass. When we talk about a filter in electronics, we’re typically talking about a circuit that may pass, block or even amplify specific frequencies in a signal.

Describing any periodic signal (i.e. repeating at a constant rate) in electronics is done with one or more sine waves added together, described with a set of properties. At its most basic, they are described by Frequency and Amplitude. Frequency is the number of ‘cycles’ a wave goes through per second, and is measured in Hertz. Amplitude is the maximum distance the wave travels from its rest position. In the context of a signal, this is typically measured in Volts. If a wave oscillates between -1V and 1V, we can say it has an amplitude of 1V because its ‘rest’ position is 0V.

These properties are used in almost every form of analysis when it comes to AC waves in electronics, so it’s important that we have a good grasp on the basics before we delve into some of the more detailed mathematics.

One other important aspect of electronic signals is recognising that in the real world, all signals have both an AC and DC component to them. You could easily have a wave that oscillates around 2V, and goes up to 3V and down to 1V as a sine wave. This has a 2V DC component and a 1V sine wave added together!

Ideally, a purely AC sine wave would be centred on 0V, but in the real world this would never be the case. Inaccuracies from generation, measurement and electromagnetic influences would cause the signal to oscillate around a slightly different value. In practice, when we generate signals on our function generators, we see at most a few millivolts above or below 0V.

We wanted to rehash the basics of waves here because manipulating them is the whole purpose of filters.

Why are filters important?

Before we continue, we think it’s very important to discuss why filters are useful, rather than just the ‘what’ and ‘how’. Even though filters are used in all sorts of electronic circuits, often hidden away from the end-user, there are many instances where a discerning electronics DIYer will find filters invaluable.

Designing a speaker system for your car or home cinema, for example, may require certain frequencies sourced to specific speakers. A subwoofer or woofer will sound the best when given low frequencies for that ‘bass thump’ while a tweeter for treble notes will require a much higher frequency range. The filters used for splitting the frequencies into specific ranges in an audio context are called audio crossovers, and can be as simple as an inductor and a capacitor.

During our time working with Arduino-based circuits, we’ve had many noisy power supplies that cause all sorts of issues. What we mean by noisy is that the power supplies don’t put out a constantly stable output, which causes the voltage to fluctuate. Digital and analog electronics are both affected by this, but it can be alleviated by using filters to remove the noise at different frequencies.

The electronics in your phone, computer and virtually every other wireless device will use some form of filter to only select the correct frequencies to be amplified and used, while rejecting noise. Learning about filters in electronics is a great way to understand the core ideas surrounding resonant frequencies (which we discussed in greater detail in our Classroom on Resonance).

The Bode Plot

We might be jumping in the deep end here, but we think it’s good to start off with Bode Plots. Bode Plots are a good way of visually communicating both qualitative and quantitative information about a filter's performance. However, it’s also initially quite confusing and, if interpreted incorrectly, may lead to further misunderstanding about what a filter actually does.

A Bode Plot, at its most basic level, is simply a plot to show how a given filter responds to different frequencies. Along the X-axis is frequency, which increases from left to right. Very low frequencies such as 100Hz can be seen on the left side, while high frequencies such as 100MHz (a million times higher than 100Hz!) can be seen on the right side. This can be displayed as a linear scale, having values such as 100Hz, 200Hz, 300Hz and so on up to 1000Hz for example, or, more commonly, displayed as a logarithmic scale. A logarithmic scale allows us to fit useful data on the graph across very wide frequencies at the expense of confusing some beginners. The best way to understand a logarithmic scale is to remember each new major gridline represents a new order of magnitude, i.e. 10 times bigger than the previous gridline’s value.

Along the Y-axis is Magnitude, or Frequency Response. The higher this is, the more signal the filter lets through. It uses decibels (dB) for its measurement, which is once again a logarithmic measurement. Looking at the graph below, you may notice that these magnitude values are all negative - but that can’t be right, we can’t reduce a signal so much that it becomes negative! It’s a good approach to thinking about what this quantity represents, but unfortunately it’s a bit more nuanced than that.

Let’s imagine for instance that we have a 1V amplitude sine wave at 1kHz (i.e. 1000 cycles per second) going into our circuit. The specific circuit in question is not 100% relevant right now, so let’s just imagine it as a black box. We have to come up with some measurement that characterises how much of this signal propagates from the input to the output.

First of all, let’s say that at 1KHz the signal makes it through to the other side completely unaffected. That is, we see a 1V sine wave on the output too.

How could we describe this behaviour? We could just use a simple ratio of Output vs Input. In other words, we divide the output by the input. In this case, our ratio would equal:

This works pretty well on initial inspection. If we have an output of 2V instead, our ratio becomes 2/1 = 2. This is typically measured in Volts per Volt, or V/V. Many op-amp circuits will use equations like this to demonstrate what the ‘multiplier’ from the input to the output is.

However, measurements like this have limitations.

Many circuits we work with electronics - filters especially - can drastically increase or reduce voltages. We’re not talking about a few volts, some circuits may multiply a voltage or reduce a voltage by over 1000x depending on the configuration.

Additionally, many filters do not have a linear response as the frequency changes. What we mean by this is that if we

double the frequency of a voltage we’re feeding into a filter, we won’t necessarily see double the ratio on the output. This makes predicting their behaviour difficult if we don’t have a suitable measurement unit.

This is why working in decibels is so useful. Looking at the equation below, you may recognise the voltage gain equation, but inside a ‘log10’ function. This is a logarithmic function, which describes the magnitude of the number. On the most basic level, it will count the number of digits in a number (minus the first place). For example, log10(1) = 0, and log10(1000) = 3.

We also multiply the whole thing by 20 before we have a final value. This might seem like an arbitrary number, and unfortunately the reason is mostly out of scope of this Classroom. If you’re interested, we’ve left some links in the resources about this.

Okay, let’s go back to our 1V wave example. What happens when we feed it into the Gain equation?

We end up with 0dB. This simply means there is no gain - the signal comes out as it went in with no change. What about if our circuit outputs 0.5V from a 1V input wave?

We get around -6dB. As a rule of thumb, if we increase or decrease a signal by 6dB, we double or halve its magnitude respectively. This is known as an ‘octave’.

Finally, what happens when our circuit amplifies our input signal by 10 times?

We get 20dB on the dot. When it comes to a voltage gain, every 20dB represents one order of magnitude. If we had an amplifier that multiplied the input signal by 100, for example, it could be represented as a 40dB gain. 20dB is known as a ‘decade’ and is by far one of the most useful applications for this scale, which we’ll see shortly as we start delving into real filters.

Low-Pass Filter

This is the first filter we’re investigating in this Classroom, and is useful for a wide variety of applications. As the name suggests, it allows low frequencies to pass through, while attenuating (i.e. reducing the strength of) high frequencies.

Let’s look at a very simple example: A resistor connected in series with a capacitor.

This is known as a passive RC low-pass filter. RC is just short-hand for resistor and capacitor, while ‘passive’ refers to the fact we’re only using passive components to build it. It is possible to build ‘active’ filters that use amplification with op-amps, but we’ll touch on that later.

Before we jump into the calculations, let’s take a look at why this circuit is laid out in this way. Initially understanding the ‘why’ is more important than the ‘what’ for these types of circuits. Capacitors, by their nature, try to oppose changing voltages by creating a current through themselves. If you apply a DC signal to a capacitor - i.e. a single, constant voltage - current will appear to flow for a very short amount of time before stopping completely.

From a physics perspective, this occurs because there are no longer any free electrons available on the capacitor plates to continue creating a current on the wires connected to it. Once the capacitor has fully charged, there is no way to force current through it.

However, this analysis also applies to AC signals too. In an AC signal, we’re applying constantly changing voltage to the capacitor. Since neither of the plates gets a chance to fully charge or discharge, any electron entering the capacitor will cause exactly one electron on the other side to exit, creating a current through the capacitor as if it was just a wire.

Going back to our RC filter, we now need to think about what purpose the resistor serves. First, let’s imagine we’ve hooked up a purely DC (i.e. very low or zero frequency) voltage to our RC low pass filter, 2V for example.

In the first diagram, we can see the capacitor is acting as an open circuit, because the capacitor has fully charged. We can imagine the capacitor as a resistor with infinite resistance. So the whole circuit effectively consists of just the resistor, which won’t affect the voltage on the output.

However, in the second diagram you can see that we have a higher frequency. While we’re not specifying an exact value, just imagine it as being at least a few thousand times higher than the first diagram.

In Issue 60, we briefly brushed over capacitive reactance in the Resonant Circuits classroom. Here is the same equation, where f is the input frequency, and C is the capacitance. You’ll notice by increasing frequency, the value of Xc overall decreases. This can be thought of as the resistance of the capacitor at a circuit frequency. So, as we increase frequency, the capacitor conducts more and more current away from the output towards ground, decreasing the output amplitude. Theoretically, as the frequency approaches infinity, the capacitive reactance approaches zero, becoming a short-circuit.

The RC Low-pass filter is probably the most simple filter to visualise, and is a good building block to understanding more complex configurations.

High-Pass Filter

As the name might suggest, a high pass filter is similar to a low pass filter in its characteristics however it attenuates low frequency signals rather than high frequency signals. In terms of a simple passive RC filter, it just needs the resistor and capacitor swapped around!

This circuit can be analysed similarly to the low-pass filter. At low frequencies or with a purely DC voltage, the capacitor blocks the voltage entirely, since its plates will be fully charged and will not allow current to flow. So, the resistor in the high-pass filter causes the output voltage to drop to 0V as the resistor brings it to ground.

As we increase the frequency though, the capacitor will begin to propagate the signal more and more until we pass the cutoff frequency. At this point, the capacitor will act as a short-circuit, and the resistor will serve little purpose. And voila, the signal will make it through unimpeded!

Let’s look at this from a capacitive reactance perspective again. Refer to the previous equation if you’d like to check our reasoning. At low frequencies, the reactance is high or even (theoretically) infinite. This allows no current to flow, so the other resistor in the circuit must bring the output voltage to 0V.

At high frequencies, the reactance drops to zero, causing the voltage to make it through to the output with no change.

High-pass filters really just operate inversely to low-pass filters, both in behaviour and physical configuration. It’s worth noting that both passive RC low-pass and high-pass filters aren’t used in the real-world as often as one might expect - while cheap and sometimes helpful for non mission-critical situations, they have some flaws that make using them in many applications difficult or unpredictable. We’ll elaborate on these issues shortly. However, for initial study and to understand the ins-and-outs of filters, they are perfect!

Cutoff Frequency

We mentioned Cutoff Frequency briefly before, so why is this important? Although the definition can sometimes change depending on the filter type, for the purposes of this article we can say Cutoff Frequency is the frequency at which a filter’s power throughput drops to 50% of its maximum. Because power is a little unintuitive to work with at first, we’re just going to work with voltage in this Classroom - so, the cutoff frequency equates to a voltage of 70.7% of the maximum. For those curious, this is because current also falls to 70.7% at the cutoff frequency. Because Current x Voltage = Power, 70.7% x 70.7% = 50%, as we’d expect.

As we’ll explain shortly, the cutoff frequency is the point at which our circuit's magnitude response also reaches -3dB.

This frequency isn’t magical or unknown, either. Most common types of filters have equations that can easily calculate the cutoff frequency for a given set of components. For a basic RC passive filter, this frequency is:

For an RLC filter, the cutoff frequency is:

Although it’s quite similar to the RC filter, we’ll see later that because this filter resonates at this frequency, it can create potentially undesirable gain ‘spikes’ at this frequency too.

Bandpass and Bandstop Filters

Bandpass filters are our next filter to look at, and they can essentially be visualised as just a low-pass and high-pass filter combined.

This circuit’s construction is actually very logical, we’re simply putting a high-pass filter in series with a low-pass filter! By carefully choosing cutoff frequencies for each filter, we can cut off all high frequencies in one filter stage, then cut off all low frequencies in the next filter stage. All that’s left is the middle ‘band’ of frequencies.

A circuit like this might be useful where a specific frequency is required to be filtered, such as in an AM radio, or perhaps a specific fundamental frequency of a signal is desired.

There are also band-stop or ‘notch’ filters, which work inversely to the bandpass filter, removing a specific frequency from the input. Technically speaking, there is actually a slight distinction between them as notch filters are more selective than a standard bandstop filter. Where a bandstop filter might work to remove a range of troublesome frequencies from a signal, a notch filter may only remove a very specific frequency.

Active Filters

Now we’re talking real business! For applications in real products, Active filters are almost ubiquitous for low to medium frequency signals. Passive filters are still very useful for high-frequency filtering where the inductor size can be very small, but their inaccuracy and power losses limit their use.

But what is an active filter? An active filter uses passive components in combination with components producing amplification in order to augment performance. Most commonly, we see op-amps assisting in creating better filter responses. Speaking of which, we’re assuming that you are familiar with the basics of op-amp behaviour. If you’re a bit rusty, we have a number of explanations in DIYODE, such as in Issue 7 and 13.

Let’s look at a basic low-pass active filter.

Wait a minute! This looks remarkably similar to our first passive RC low-pass filter! That’s because it is, and it works exactly the same way, with the exception of an op-amp configured as a buffer on the output.

Op-amps are prized for their ability to convert a high-impedance input into a low-impedance output. Why would this be useful? Our main problem with our previously discussed set of passive RC filters is that, as we change the output load, the frequency response changes. However, if we hook it up to an op-amp that (theoretically) won’t draw current from its inputs, the filter will operate without worrying about supplying current to any sizable load.

Meanwhile, the op-amp has its own output circuitry that can drive a few milliamps without interfering with the input circuit connected to it. In this case, we’ve shown an op-amp connected as a non-inverting buffer. This is nerd talk for saying that the op-amp just replicates whatever voltage it’s given.

If we plotted the Bode Plot for this filter, you’d notice it’s the same as the original RC low-pass filter. And of course, this circuit can be connected to any passive filter to replicate its functionality without compromising the performance with a heavier load.

But this is only scratching the surface with regards to what op-amps can do when they team up with filters. Let’s add two extra resistors to make the op-amp amplify the signal. If you haven’t seen this configuration before, it’s a simple non-inverting amplifier that, depending on the ratio of resistors used, will multiply the voltage at the input.

Unlike all passive filters we’ve looked at so far, this filter actually produces amplification in the pass-band. Before our cutoff frequency, our circuit is producing a healthy 20dB of gain - recall from our Bode plot introduction that this is about equal to a 10x increase in signal magnitude. After that, the gain drops off until the output signal becomes attenuated (i.e. the gain is less than 0).

The main thing to keep in mind about this active filter is that while the cutoff frequency is still applicable, it’s not fixed at -3dB. It’s technically 3dB below the maximum gain of the op-amp - so still around 17dB. If you need to reduce a signal significantly before your chosen cutoff frequency, you may need to pick a lower frequency to make sure the op-amp isn’t amplifying frequencies you don’t want.

Since we’re going into some more complex filter configurations, and not all of us are doing mathematics degrees, we’re going to keep the equations light and understandable. For filters involving an op-amp at unity gain - in other words, the op-amp is just copying the voltage at the input - most frequency response calculations can just be applied as if the op-amp wasn’t there.

For filters with amplification though, there are a couple other parameters that may be of interest. For the op-amp circuit with gain, it is also possible to tune the op-amps gain to a desired value with this equation:

Where R2 is the feedback resistor from the op-amp’s output back to its input, and R1 is the resistor bridging the op-amp’s input to ground. Av just tells you how many times bigger the voltage is at the output compared to the input. For example, if we wanted a gain of 11, a fairly common gain for circuits like this, we could use resistor values of 1kΩ and 10kΩ for R1 and R2 respectively:

This is gain only for the op-amp itself, so we need to factor in the rest of the circuit too.

This equation factors in both the DC gain of the op-amp, and the RC circuit before it. ‘Fc’ is the cutoff frequency, ‘F’ is the input frequency to find a gain for, and Av is just our previously found DC gain. This equation can be plotted on a graph to visually see its gain versus frequency, or it can be applied directly to a certain set of circuit values.

Higher-order Filters

What if we wanted a stronger filter? All filters we’ve looked at so far, even the active ones, are all first-order filters. This means that for every decade of frequency we increase, the filter responds with a 20dB change in its response. While this might be useful, in some applications a stronger rolloff may be desired. For every additional order of filter, the response is increased by another 20dB/decade. For instance, a third order filter would have a rolloff of 60dB/decade.

But how do we increase the order of a filter? Naively, we could create a second-order filter like below, cascading two RC filters together one after the other. Since we’re effectively filtering a signal twice, we should get double the attenuation once we pass the cut-off frequency.

While this reasoning is not technically incorrect, it’s not quite as cut and dried. The components in the second stage of the filter load and affect components in the first stage, which change their response. It requires a large set of calculations to fully predict its behaviour, which isn’t worth it for an inferior filter like this.

Additionally, the cutoff attenuation is doubled. Instead of only getting -3dB at the cutoff frequency, the second stage doubles this to end up with -6dB! This makes this filter a pain to work with, even if you buffer the stages with an op-amp like we were doing before.

RLC Filters

RLC circuits are often used as one of the most common filters, usually referring to any circuit that has all three passive components - a resistor, inductor and capacitor. There are various configurations that RLC filters are seen in, all of which are useful in electronic design.

They are a second order filter thanks to the use of two reactive components, the inductor and capacitor. We’re going to not include the resistor until we get the basics down. To begin with, we're looking at a low-pass LC filter.

This Bode plot looks very different from the other passive filters we’ve seen so far! Let’s look at the left side, where a flat plateau is visible. Since it’s hanging around at 0dB, and the phase is virtually 0 degrees, we know the signal isn’t affected at all. Looking at the circuit, we can see why this is the case. At low frequencies, the inductor becomes a short circuit while the capacitor becomes an open circuit.

At high frequencies, the inductor begins to oppose the current flowing through it and, if our frequency was high enough, can be considered an open-circuit. Meanwhile, the capacitor is happily short-circuiting the high-frequency voltage across it, causing the output of the filter to drop to 0V.

Of course, these are only the extremes of our filter. What’s all that spiky business happening in the middle of the Bode plot? Those who are somewhat familiar with inductors and capacitors may have already guessed what this is - it’s the resonant frequency of the LC circuit!

We won’t be going over the concept of resonance again as we covered it a couple months back, but once we hit the resonant frequency of this circuit, a very sharp and obvious amplification occurs. Since we’re feeding an oscillating signal into the circuit at exactly the right frequency that the LC circuit resonates at, every cycle of the signal will put more and more energy into the circuit, causing the voltage to rise rapidly.

However, this behaviour isn’t set in stone - it can change depending on the load connected to the filter.

As can be seen above, depending on whether the output load is 50Ω or 2000Ω, the circuit functionality can dramatically change. At 2000Ω, we see around a 6dB gain at the cutoff frequency, while with 50Ω our signal is attenuated by 26dB!

Depending on the application, it may be desirable to minimise or maximise this resonance. As energy cycles between the inductor and the capacitor, any resistance in the path will reduce the effects of resonance. It’s possible to quantify the process of minimising or maximising the resonance through the ‘quality factor’ of a filter.

This is typically abbreviated with just ‘Q’. While we did talk about Q-factors in the Resonance classroom, in filters it also has another interesting application. Values of Q that are larger than 0.5 mean that the circuit is ‘under-damped’, i.e. the oscillations between the inductor and capacitor occur at least once. Very large values of Q lead to more oscillations, and Q equals infinity theoretically means the circuit will oscillate forever!

Values of Q that are smaller than 0.5 mean that the circuit is ‘overdamped’, as the resistance is now high enough that the circuit’s response becomes rather sluggish. Refer to the diagram below to see this in action.

A value of exactly 0.5 means that the circuit is ‘critically damped’. This means an appropriate set of components have been chosen such that the circuit is just on the border of not oscillating, but still remains as responsive as possible. If you’re designing an RLC filter with all components in series, the equation below will come in handy to make your filter critically damped. You can rearrange the equation to solve for R if you’re looking for an appropriate Q-factor.

It’s worth noting that this configuration can be reversed in order to make this low-pass filter a high-pass filter, where the capacitor is connected directly to the input and the inductor is connected as a shunt to ground.

Transfer Functions

A transfer function describes how strongly an input will propagate to the output. It’s a critical bit of maths that allows you to derive a huge amount of information about a filter.

Most filter layouts will have some form of transfer function, either derived from the components themselves or an approximation. Many of these you can just look up on Google. If you have a filter layout you’re planning to use, there is most likely a reference design online that you can adapt and calculate component values for your own needs.

We unfortunately won’t be going into all of the derivation in this Classroom - there are entire textbooks written on this subject so we’ll be simplifying quite a lot of the explanation. It’s still important to understand the transfer function because it’s where the shape of any filter response comes from! Let’s revisit our simple RC lowpass filter and run through an example of how to use them. It’s transfer function is as follows:

Okay, let’s break it down. Let’s set our capacitor (C) to 10nF and our resistor (R) to 1000Ω. That’s two of the three letters substituted in. What about ‘s’? This is where things can get a little tricky.

‘s’ is a complex number consisting of j (the imaginary number equal to sqrt(-1)) multiplied by ω, which is a frequency in radians/second. It also has the parameter ‘σ’ appended to the end, however this is only useful in circuits where we’re interested in analysing transients (i.e. a sudden change), rather than a steady sine wave. So, we can essentially set it to zero to end up with:

Once this is substituted back into our first equation, it looks like this:

This might look a bit cryptic, but it actually communicates a lot of information about our low pass filter. Let’s see what happens if we give it a 0Hz signal (i.e. a DC voltage).

We get just 1! This is essentially a multiplier of the input signal, which we know would just equal whatever we put in. If we had 5V feeding into our signal at 0Hz, we would know the output would equal 5V too. This is correct, since we’re dealing with a low-pass filter - all low frequency or DC signals should pass through unimpeded.

What happens if we put in the cut-off frequency? The cutoff frequency of a low-pass filter is equal to 1/(R*C) in radians per second, so we can substitute that directly in:

This number might not make a lot of sense to some reading. This is a complex number, which consists of a real number (0.5) and an imaginary number (-0.5j) added together. It will make some more sense if we plot it on two axes, like you would with cartesian coordinates.

On the X-axis, we have our real number and on our Y-axis, we have our imaginary number. If we plot the number we just got onto the graph, it ends up in the bottom right corner. Okay, but what does this tell us? First, if we measure the length of the line we get the magnitude response! The length of this line is about 0.71, which means whatever voltage we fed in will be 71% as big on the output.

This may seem like a weird number, but it’s really just equal to -3dB which we know is located at our cutoff frequency:

But that’s not all that the graph tells us. The angle of the line from the X-axis can also tell us the phase of the output signal! Ours has an angle of -45, which means that our output voltage ‘leads’ our input voltage by 45 degrees.

You can summarise all of this information in ‘phasor’ form, which contains magnitude and phase:

If you’ve never worked with equations and numbers like these before, it can be slightly daunting but hopefully we’ve given you a quick introduction as to why they are so helpful.

Experimenting with filters

Okay, enough talk! We can do calculations and look at Bode plots in simulations fairly easily, but seeing filters work in real life is a lot more intuitive and informative.

While we were playing with Jaycar's new QC1938 Oscilloscope for this month’s review, we noticed it had a SCPI interface which is suitable for interfacing with a computer. It’s possible to fully control and read data from the scope with software! So, we spent some time writing some software in MATLAB to connect and read data from the oscilloscope. We won’t be showing much code as it’s well out of the scope of this Classroom, but those who are curious can download it from the resources.

The main aim of the code was to automatically create Bode plots both from the physical and theoretical filter designs. Since Bode plots represent data across a very wide spectrum of frequencies, we had to take a bunch of data points and observe how the circuit behaves.

Because QC1938 includes a built-in function generator, we were able to do all of this work just by sending commands over the oscilloscopes SCPI interface.

First up, we built a basic RC low-pass filter.

To actually hook the circuit up to the Oscilloscope, we need to connect three BNC cables. If you’re not using an oscilloscope with an inbuilt function generator, you’ll need to use a dedicated function generator and write your own code for interfacing with it (or just change the frequencies manually).

We connected the function generator output to the input of the circuit, and also to Channel 2 on the oscilloscope so we can do phase measurements - i.e. monitoring how much the input and output signals have shifted in time.

The output of the filter circuit is connected to Channel 1, which is where we’re measuring the amplitude. Any circuit can be connected to the oscilloscope, and data points will automatically be gathered for plotting and further analysis.

After that, we used some Dupont cables to connect the Oscilloscope probes to a circuit built on a breadboard. The filter circuit itself is quite simple, and doesn’t require a huge amount of electronics knowledge to build. We used a 10nF MKT capacitor and a 1kΩ resistor, which just need to be connected across the breadboard in series. This selection was carefully considered, we used the first components we saw lying on the workshop bench. MATLAB can handle and model any selection of component parameters - more specifically, it’s a case of what response you want your filter to have.

In our circuit photos, the orange breadboard connection represents ground, the green line represents the input, and the purple line represents the output.

After we built it, we began testing our MATLAB Bode plotter. We’ve included a flowchart below to roughly show how our plotter works.

At its core, our plotter program is simply feeding different frequencies into the test circuit and observing the output amplitude and phase. After we’ve collected all the data points, we can plot frequency versus amplitude and phase on a Bode plot to visually compare it to the theoretical values.

But, what frequencies should we choose to test the circuit with? If we choose too many, the circuit could take hours to test. If we choose too few, we won’t get enough points to plot the Bode plot accurately. And how do we space out the points in between our lowest and highest test frequencies?

One approach is just equally spacing out points between our lowest and highest test frequency. If we wanted to test a few equally-spaced frequencies between 0Hz and 1MHz, we could get a list of frequencies like this in MATLAB:

linspace(0,1000000,11) 
= [ 0  100000  200000  300000  400000  500000  600000  700000  800000  900000  1000000 ]

However, if you recall from our introduction on Bode plots, logarithmic scales are much more effective when it comes to analysing filters. If we test frequencies on a logarithmic scale instead, we’ll get an equally spaced Bode plot which is more useful.

logspace(0, 6, 11)
= [ 1  4  16  63  251  1000  3981  15848  63096  251188  1000000 ]

You can see we’re testing a much better selection of frequencies, as filter behaviour is easier to characterise if we’re testing equally across magnitudes rather than linearly. In terms of the number of points, we can see at the end of the logspace() function, we’re requesting 11 points. We found a range of 30-40 points works well for speed while still maintaining a good number of data points.

When getting data from the oscilloscope, we need to ensure that both our horizontal and vertical scales are set correctly. What we mean by scale is the physical size of the displayed waveform on the display - imagine it as a magnifying glass for signals. If it’s too small or large, the scope won’t make accurate measurements, if any are read at all. If you can’t visually make the reading yourself, it’s likely the scope wouldn’t be able to either.

Horizontal scale is easy. If we have a frequency that we’re outputting from the function generator, say 1KHz, and we want around 1-2 wavelengths to fit on the oscilloscope display, we scale the display appropriately to fit about 2 milliseconds of time on the screen. It’s a very simple association that we can derive from the frequency.

Vertical scale is a bit more involved. Since we don’t know the amplitude of our signal until we read it, the best we can do is guess what scale it needs, and change it if the wave is too small or big. This is why there is a small loop in our flowchart for changing the vertical scale multiple times, which may be needed if our program makes a poor guess.

After we’ve scaled the wave correctly, we can go ahead and take our final amplitude and phase measurement for this frequency.

Note: Phase measurement was a little tricky for this project, as the oscilloscope we are using did not have an inbuilt phase measurement. We had to take the FRR reading, which calculates the time difference between identical parts of two offset waves. We then converted it to a phase reading by multiplying it by the wave frequency and then 360 degrees. Unfortunately, because the oscilloscope doesn’t take multiple readings for this measurement, the result tends to be quite noisy and produce erroneous results. As such, we haven’t included phase measurements for this practical part of the Classroom.

We then repeat this process for the remainder of the frequencies, and plot the data on a bode plot, together with the transfer function plotted as an overlay.

Our low-pass filter graph looks remarkably spot-on, but there are a few things worth addressing. The first is the deviation on the right-side of the graph. Why doesn’t it continue dropping off at 20dB a decade? The signal is apparently going back up at around 25MHz! The answer to this can be seen visually when the program is running at these high frequencies. The signal amplitude is so low - on the level of millivolts - that the oscilloscope is reading more noise than actual signal. So we’re really just seeing the noise floor of the oscilloscope and the surrounding radio interference here. Remember, -30dB is only 3% the strength of the original signal!

However, we also suspect the slight rise in signal strength at the end is due to the metal in the breadboard acting as an inductor and resonating with the capacitor in the circuit, as we saw with our RLC circuits. To test this, we rebuilt the circuit on a soldered veroboard and replotted the results with very minimal change. We also re-calibrated the scope’s probes to no avail.

Because there is much less inductance on a veroboard than breadboard, our best guess is that it’s a limitation or susceptibility of the scopes internal circuitry to frequencies past 20MHz or so. We’re probably looking into this quite deeply, so it’s not something that would greatly affect the average maker using an oscilloscope like this.

In any case, this is why we love doing practical experiments alongside theoretical investigations - it leads to much deeper insight about the topic than just doing the calculations on paper.

Okay, let’s test our RC high-pass filter now. This was just a matter of swapping the probes over between the circuits, which wasn’t a huge deal.

Again, the results look pretty good! The measured response is quite close to what we predicted initially. We’re again seeing around 3dB of amplification at 25MHz, perhaps due to the oscilloscope itself.

Something else worth addressing is the slight amplitude mismatch between the theoretical and predicted responses. Our measured response has a slightly higher magnitude, which is actually above zero gain in the passband. This obviously can’t happen with a passive filter, and we’re pretty sure this is to do with how we’re measuring the amplitude.

Since gain is calculated as a ratio of the output to input, we need to measure both in order to get an accurate figure. However, we’re only setting the frequency generator to our target amplitude and assuming it’s actually outputting that, which could be throwing off our calculations if it’s inaccurate.

Finally, we also wanted to test an RLC filter. This was the same process as the other filters we’ve tried so far, but being an RLC filter we also wanted to see what happens at its resonant frequency.

We hooked up a 100μH inductor in series with a 10nF capacitor. We also connected a 1kΩ resistor to simulate the load across the filter, because otherwise the resonance would be unpredictable and not easily modelable. We ended up having to implement the input waveform measurements we mentioned too, since the resonance was causing the input voltage to drop, which was completely throwing off the gain readings.

Regardless, the plot looks spot-on. The main discrepancy is the sharpness of the resonance curve, however this could have been due to a few culprits. Additional resistance in the breadboard, capacitor or inductor will cause less current to flow at the resonant frequency.

Since the waveform generator has a 50Ω output impedance, it’s also very likely that its impedance is causing a large voltage drop under load. And of course, the MATLAB simulation is a purely theoretical model of the circuit, so we think the results are more than adequate.

Where To From Here?

This is probably one of the more mathematically-oriented Classrooms we’ve had in DIYODE in recent months, but we thought it was important since filters underpin so much electronics knowledge. Even for circuits that don’t explicitly employ the use of a filter or its variants, parasitic inductance, capacitance and resistance will still affect your circuits just in the way any other filter does.

Breadboards that we build our prototypes on have a lot of capacitance between the lines, which makes circuits with resistors act like filters! So, if you get stuck when dealing with strange or sluggish data signals on breadboards, we hope this investigation of filters might give you a clue of how to find the problem.

Regardless, even for those of us who see equations and presume they are ancient magic spells from the dark ages, we hope we’ve put enough interesting practical information in here for those who are more hands-on. There is a huge variety of practical applications for filters which require a surprising amount of both hands-on and technical knowledge, so don’t worry if it feels like a large learning curve.

This is one of the most challenging concepts in
electronics to master, but hopefully this Classroom was a relatively informative crash course into the wonderful world of filters!

Talking Physics

You may notice that throughout this article, we refer to current flowing ‘through’ a capacitor. This isn’t physically possible in an ideal capacitor, as there is an insulative dielectric between its plates. In other words, there is no physical way for electrons on one plate to jump to the other.

However, we do apparently see current flowing through the capacitor as we apply higher frequencies. As more electrons accumulate on the negative side of the capacitor plate, electrons on the now positive side become repelled as they are like charges. Even though no electrons are really flowing between the leads of the capacitor, we can visualise it as such.

Long story short, we’re simplifying for the sake of keeping everything understandable. We’re not physicists!