Low Pass Filters - Page 1
Forum section: electronics / beginners

author: blewisjr
author_rank: Frequent Contributor
timestamp: April 15, 2013, 10:35:36 pm
content: Hello Everyone,I have been doing some experimenting with my Oscilloscope and various wave forms I am bread boarding. I built a very simple C routine to generate a 500HZ square wave off of a digital IO pin. My plans are to eventually move it over to the ADC/PWM and tighten up the loop by using assembler but this was just a quick off test. Worked great!!!! Then being the curious individual I am I thought well how can I turn this digital square wave into a analog wave. Through some research I found you can use a low pass filter to convert the square wave into a analog triangle wave and a second stage low pass filter will bring it into a sine wave. Since I did not have any op amps on hand I decided to improvise skipping the op amp and filtering with 2 100k ohm resistors and 2 0.1 uF capacitors. I Picked these values because other resistors and caps did not seem too work properly. Now here is my issue.The square wave and triangle waves work like a charm but reading the output after the second low pass filter the signal gets very distorted and flickers all over the place and has crap tons of noise. In order to see the wave form properly I need to turn on averaging and set the averaging sample rate to 256. I am using a Rigol DS1102E 100MHz scope. Any clue on what is causing all these issues?The one thought I had as that due to the op amps being left out the signal is degrading dramatically over the resistors leaving everything unstable. Any thoughts on how to clean it up or explanations to why this is happening. Keep in mind this experiment is teaching me a lot so I finally think I just figured how I learn best by being curious and screwing around.

author: 4to20Milliamps
author_rank: Regular Contributor
timestamp: April 15, 2013, 11:19:06 pm
content: My guess would be it's overloading the input somehow, but without building the circuit or seeing it that would be pure speculation.I don't remember where I got this from> somewhere on the net a few years back? it makes a pretty good sinewave from a squarewave :

author: jmole
author_rank: Regular Contributor
timestamp: April 15, 2013, 11:40:55 pm
content: There's pretty much no way a 2nd order passive low-pass circuit will be unstable with a 500Hz input.So, lets look at your time constant here: 1/RC = 1/(100k * 0.1u) * 2 pi = 600Hz.With two passive filters back to back, your corner frequency (600 Hz) will be at -6dB, or 1/2 the input voltage.Try using 10k resistors instead, with 1u caps, and see if that helps. Also, if you can, post a pic of your scope outputs so we can see what you're seeing.Also, keep in mind that the input impedance of your scope will attenuate the signal even further. Remember to use 10X mode on your probe.

author: amspire
author_rank: Super Contributor
timestamp: April 16, 2013, 12:00:13 am
content: If you are using simple RC filters, then to get something that looks liken a sinewave you may have a lot of attenuation. It is not just that the amplitude is so low that you are seeing a lot of noise, including some digital noise coming from poor ground connections to the micro?The idea of generated a sinewave from a squarewave is a good one, but to get a pure sinewave, you will need something like a bandpass filter. If you are interested, you can do a search for "twin-T bandpass circuit". There are more complex outputs you can generate which use harmonic cancellation to allow youy to turn a binary output stream into a very stable low distortion sinewave with a simple low pass filter.

author: blewisjr
author_rank: Frequent Contributor
timestamp: April 16, 2013, 12:18:00 am
content: Awesome thanks for all the input. I am realizing my probe is set to 1x so I will first try 10x and check out the difference. I will indeed get some snapshots for you to take a look at from each stage square to sine when I get a chance later on. As far as different resistors and caps is there any other size caps I can use as I don't have any 1uF ceramic caps only Electrolytic.

author: MikeK
author_rank: Super Contributor
timestamp: April 16, 2013, 01:07:49 am
content: Your cutoff frequency is too low.Fc = 1/(2*pi*R*C) = 1/(2*3.1415*100*10^3*100*10^-9) = 15.91 HzTry 1K resistors and see what you get. The Fc will be 1591 Hz.Or better yet, use 3K. You'll get an Fc somewhere just above 500Hz.

author: dentaku
author_rank: Frequent Contributor
timestamp: April 16, 2013, 01:55:03 am
content: Quote from: 4to20Milliamps on April 15, 2013, 11:19:06 pmWhat software was use to create that simulation?It looks useful.

author: blewisjr
author_rank: Frequent Contributor
timestamp: April 16, 2013, 02:23:13 am
content: Okay I got a chance to get some screen caps of the oscilloscope for each wave form by probing each point in the circuit. Sadly the one thing you don't see is all the jerking like action going on in the sine wave. All three readings were made at 10x with the 100k resistors and 0.1uF capacitors.

author: 4to20Milliamps
author_rank: Regular Contributor
timestamp: April 16, 2013, 12:07:38 pm
content: Quote from: dentaku on April 16, 2013, 01:55:03 amMultisim:http://www.ni.com/multisim/

author: 4to20Milliamps
author_rank: Regular Contributor
timestamp: April 16, 2013, 12:08:50 pm
content: What are you using to power your circuit? That looks like some pretty bad power supply noise to me.

author: blewisjr
author_rank: Frequent Contributor
timestamp: April 16, 2013, 12:22:18 pm
content: It is being powered by a Korad KA3005D. Maybe I should hook up the scope to the Power supply to see if that is where all the jitter and noise is coming from but I am not 100% positive. I ended up swapping the 100k resistors for 10k resistors and I got a very crisp sine like wave not perfect more like a rounded triangle wave but the noise and the jitter was gone. The triangle wave was more saw tooth in nature. When I get a chance I will get some shots of the circuit using the 10k resistors with the 0.1uF caps.

author: airiclenz
author_rank: Contributor
timestamp: April 16, 2013, 12:27:20 pm
content: Do you have any kind of load behind the filter or is it just the scope? I am asking because this would allow you to calculate the voltage drop over your 100k / 10k resitors. On your last picture you only have some 40mV peak to peak left and I guess the noise you see is just picked up noise.Airic

author: blewisjr
author_rank: Frequent Contributor
timestamp: April 16, 2013, 01:17:17 pm
content: Quote from: airiclenz on April 16, 2013, 12:27:20 pmNo Load. I am running directly from the digital IO pin right into the first stage low pass filter then right into the second filter. The filters are in series with the sine wave being read right from the second cap.Like I stated with the resistors at 10k (down from 100k) the noise goes away probably due to the sine wave not dropping to uV level but the waves are not the waves I am looking for. With the 10K resistors I am getting more of a saw tooth wave from the first stage and a rounded top triangle wave after the second stage. This is why I am thinking inserting the op amps will let me use the 100k resistors to get the proper waves and the op amps will keep the voltage up instead of dropping to minute uV. This should then stabilize and clear up the noise. I just have to go to radioshack and grab a few op amps to test it out.

author: jpb
author_rank: Super Contributor
timestamp: April 16, 2013, 01:28:59 pm
content: I think your problem is trying to combine the circuits.To go from square to triangle you essentially want to apply a square current wave (if that makes sense) to the capacitor so the voltage rises linearly, this means that the voltage needs to be mainly across the resistor even when the capacitor is charged (so the current remains constant and equal to V/R). This could be viewed as a low pass filter but to my mind it is a rather confusing way of looking at it.To get the sine wave you want to low pass filter the square wave to remove the 3rd and higher harmonics. For this you just want to set 1/RC to be above the frequency of your square wave but below three times the frequency. This is a proper low pass filter application.In analogue function generators I think they start with a generated triangular (sawtooth) wave and then integrate it to get a square wave and then low pass filter it to get a sine wave.

author: blewisjr
author_rank: Frequent Contributor
timestamp: April 16, 2013, 01:57:54 pm
content: Quote from: jpb on April 16, 2013, 01:28:59 pmOk thanks for this. I think this information will be very useful I will tinker around with that concept and see what I can get.EDIT:Made some modifications as according to my calculations with the 100k resistor and the 0.1uF cap through 1 phase of the low pass it was only sitting around 0.62 HZ. So I re built the low pass filter with a 4.7k resistor and a 47nF capacitor. According to the calculation this sits around 750HZ. This is less than 3 times the 500HZ input but I am not getting a sine wave. Instead through this 1 pass I am getting a very nice sawtooth. So I figured I would add another pass and the sawtooth was refined. A third pass still did not get a sine wave just an identical sawtooth to the second pass. So again a road block but I am heading in the right direction I think as the only noise I get is in the square wave which I think is common mode coming from the poor grounding the breadboard provides.