Filtering Square Waves to Sine Waves - Simply Put

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
RC networks as high-pass and low-pass filters high-pass filters give you a pulse generator low-pass filters bring you back down to a sine wave that's what we want today so I'm going to use my oscilloscopes function generator to create a basic square wave just because there's only so much room on my breadboard and I keep switching around the circuits once I move everything to a PCB it'll be much more compact and I can fit everything together so we'll have the oscillator feeding into the H bridge feeding into the RC networks feeding into the amplifier but for now I'm only trying to demonstrate the filtering step so let me show you the test circuit I have I will have the function generator first of all because my oscilloscope is quite expensive just to be careful I'll put a safety resistor in I won't need this in the final circuit where the worst I do is blow a regular transistor of course we'll have our ground on the other end our reference voltage since this is a signal the ground the negative the zero is the reference voltage for the whole thing and then I will be using potentiometers as variable resistors because recall an RC networks timing how long it takes to charge and discharge for the capacitor is based on the resistance times the capacitance and it's very easy to have a variable resistor not as easy to have a variable capacitor so I'll be choosing a capacitor and adjusting the resistor to get the effect I want so I will have three filters and I'll explain as I go why that number three capacitors that is our network all of the capacitors of course connect down through the ground and these are junctions naturally one there one there and one there so the power will connect all the way through here and it will continue to get filtered by the capacitors so just for the moment only look at this resistor in this capacitor as one RC network so we have our input signal and recall that an RC network is a resistor and a capacitor in series for a low-pass filter we have the resistor first if there's only one filter it doesn't matter but we have more than one so it does so we have the resistor first and then the capacitor and the output is taken across the capacitor from one end to the other the other will always be the reference voltage the high-pass filter would be the capacitor here and the resistor here and we would take the voltage across the resistor but we have resisted capacitor now why do I have different resistors isn't this all just one series resistance well no this capacitor the loop is like this it doesn't involve these two resistors so it's this Plus this is the R and that's the C for this capacitor is this Plus this Plus this series resistance R times C and it's all four together times this C for the third aishi network so you know the earlier ones are included in the later ones but there's always one resistor that is only affecting the capacitor at particular point so from here we have this one we can adjust and then this one both of these are dependent upon this one but only this one will adjust this one and then when we move to the third one both of these are doing both of these but then we have a third one we can adjust for this so we adjust it in stages will connect only this one we won't even have these connected we'll adjust this then we'll connect this one so this stays the same we don't mess with it and then we adjust only this one to set the second filter then connect the third filter adjust the third one so it's a bit more of a pain to configure initially but we need that configurability again I'll show you why when I'm using actual values now the output of course will be here if we had one filter the output would be here and then ground the second the output would be here but you can see instead of it being an output it's into the next RC network so the true output will be here plus ground so at this point and this point will be our result signal and that's as simple as it is no other trickery I'm going to be physically swapping these capacitors and then just using my screwdriver to adjust these essentially trimpots since they don't have knobs on them it's just a little trim pot so let's get that oscilloscope on and get going right now I'm going to make a statement I will go into more detail in my upcoming amplifier video as part of this project but right now the statement is simply that a capacitor it's filtering as in what frequencies it filters more and less is dependent upon its capacity a 100 nano farad 10 nano farad 1 nano farad capacitor will all have different curves of how much they affect different frequencies of signal so this is why I'm going to be trying different capacitors so the first thing I'll do is turn on my wave generator this is a square wave at 60 Hertz five volts peak-to-peak which as I have said I was getting wrong before but now I'm getting right it's five volts from the bottom to the top so the center would be zero and then this would be 2.5 volts and this would be 2.5 volts so five total from peak to peak which I should have figured out but I didn't anyway so I have it connected to the safety resistor and right now the yellow waveform is measuring if I can see where I put my probe let me move it over here to the actual input so of course had nothing plugged in so this is the same thing but it's a square wave you should be able to see the score of going up and down and the reason I chose 60 Hertz is I'm trying to mimic wall power not the voltage of wall power but the general shape of it close enough anyway so the potentiometers I am using our 500,000 ohms I have three of them and I will begin with 100 nano farad ceramic capacitors which are the largest ceramic capacitors I have now I did try electrolytic s-- even though in this circuit you shouldn't be using electrolytic s-- because you've got the power going back and forth it's fast enough it should be safe but you know you really shouldn't be relying on luck and reoxidation you should really not operate electrolytic capacitors like that but as it turns out the higher value capacitor actually didn't work as well the large ceramic capacitor worked great so luckily I don't have to think about that so I'm going to use three 100 nano farad ceramic capacitors in a row but first I will put in just one of them so I will switch my signal view here to be the output of the RC network which is the not ground side of the capacitor and you see basically nothing maybe a little wiggle because I have a very large resistor across it so I'm going to turn down the 500,000 ohms slowly and you will see a signal begin to emerge more clearly once you get down low enough see it's getting a little tall there we are that right there is a nice triangle wave but it's very low voltage so I had a two point five to minus two point five waveform I guess I'll say five peak to peak just to be simple and now so this is 0.5 this is minus 0.5 so now it's a 1 volt peak to peak that's terrible we don't want to start filtering and losing the entire signal so I'll keep turning this down so if I turn it all the way down we just get our signal because the capacitor is having very little effect so if I very slowly very gently turned up this capacitor and let's zoom in a little so we can see the waves if I slowly gently turn up this capacitor we see the first thing that happens is it begins to smooth out the corners since it is a low-pass filter if I get it just right this is a large resistor a belt like this maybe it's I need bit more there it is that right there if you recall my RC network video I showed you a waveform roughly like this where it's about approximately 1 tau going up in one tell going down not exactly I'm just eyeballing it here but very roughly I'm letting the capacitor charge and then discharge about its time constant and as you can see as I filter the signal down and change the shape it loses its voltage so since I want three filters I'm going to say let's do about half a volt right I don't want to go overboard we're gonna have multiple stage filters here because if you want your triangle wave you can just turn the resistor way up and the timing will get you a triangle wave but I can get one while retaining more voltage by using an extra stage so this is at about 2.5 so I'm going to go down to about 2 on the peak I'll turn up this resistor to about there and so now we have definitely something spiky it's more like a ocean wave kind of thing you know stylized one but you can see it has smoothed out the edges so now that's the first stage so what if I put in another 100 nano farad capacitor now watch you might notice a very small change when I plug that in it has a slight effect on the signal but not too much but I will actually measure the second signal now and now of course there's no signal because we have 500,000 ohms if I turn the second potentiometer down to zero we get our original waveform pretty much so this is why I'm adjusting one at a time I get the first one where I want it and the second one roughly but if we notice we've actually lost a little voltage partly because I bumped this so I'm actually going to turn the first one back up a little bit because the second potentiometer is at zero so essentially it's not there and I'm just adjusting this again so let me get some my voltage back that'll about do now I will turn the second potentiometer up from zero and we see we get a triangle wave with much less resistance that I did before if I turn it up to here we've lost about as much voltage as we did before but now it's more rounded it may be hard to tell do take my word for it I've looked at these waveforms back and forth these Peaks are more rounded smoother but I again don't want to lose that much voltage so I'm going to say let's lose only another half a volt on the top and bottom so you can see it's still curvy but it's much more triangular thee let's try a third one a third one hundred nano farad capacitor plugging it in effects the circuit very little switching the signal to the third and final RC Network no signal naturally turn down the resistor potentiometer and you can see once again we have lost a little voltage so I'm actually going to turn this second potentiometer back up in fact I'm going to turn all of them to zero so we get back original signal but do you see it's a little curved I have all three potentiometers at zero now and we have a very slight rounding of the score wave that's because of my safety resistor recall I have a 1000 ohm I didn't say the value but I have a 1000 ohm resistor right there that the signal is going through before it reaches any of the potentiometers or capacitors and that is effectively an RC network very slight one but that's an RC network because right now if I had all these potentiometers to zero this would be a roughly short circuit and I don't want that so with these two zero I will now turn up the first one to lose my half volt about there about let's say there once again I'm using a very large potentiometer let's do that now the second one I will turn up to losing about another half a volt gently gently super gently all right now the third one so we're back to where we were now I will engage the third filter and once again if I turn it to here we've lost the voltage that we did in the very first place to get the triangle wave but now it is much much much smoother can you see that it's much smoother but let me turn this down and lose only half a volt so now instead of having a point five two point five so one volt peak-to-peak I have a 2 volt peak-to-peak - one - one but this is with three capacitors of the same size recall how I said the frequency response is a little different depending on the capacitance so remember this rough looking waveform let me turn all the potentiometers back down to zero let me switch the signal back to the first one and I'm going to do a little swap so those are rough for a signal so I will take out capacitors two and three so capacitor one is a 100 nano farad capacitor capacitor to the second in line will now be a 10 nano farad capacitor and the third capacitor in line the final filter will be a 1 nano farad capacitor so a 100 a 10 and a 1 now let's do the same thing we just did but actually I am going to switch my signal to the third one because I can adjust them separately by having the potentiometers at 0 so we have our nice square wave here 5 volt peak-to-peak so if I turn up the first potentiometer the same thing as last time will happen if I lose about half a volt will get same way if we did now I will turn up the second potentiometer with the 10 nano farad capacitor and it will look very similar but if you're able to see my screwdriver I was able to turn the screwdriver much further before the signal started visibly going down recall it's resistance times capacitance is you tell constant 100 nano farad is 10 times bigger than a 10 nano farad so because the capacitance is smaller you need a bigger resistance to get the same time constant so I've gone down about half a volt again and already at this moment this is smooth then the second filter last time it's hard to see like I said I've been staring at these waveforms multiple times but with only the second filter in the last one it was still pretty sharp and pretty angular definitely smoothing but still pretty angular this one is already very close to the sine wave you want so now I will turn off the third filter the one nano farad capacitor and I'm turning the screwdriver a lot and when we get down to our one volt peak-to-peak roughly look at that it's not perfect but it is very close much smoother than last time let me not hit my screwdriver on my screen please it's not a huge dramatic thing they're very close to each other but this is in fact smoother but the fun thing is this 500,000 ohm potentiometer is at max it's at five hundred thousand ohms zero to five hundred thousand because the one nano farad is a hundred times smaller than the hundred so you could of course power down your circuit and use a multimeter to measure these potentiometers to see which actual resistors to put in if you had an exact signal and you might say you have over five hundred thousand ohms going on here isn't that going to destroy your ability to do anything with the signal that's why I'm putting in an amplifier this stage is to smooth the square into the sine the oscillator produces the square the oscillator feeds the H bridge which changes a zero to positive square to a negative to positive square and then I take the negative to positive square which is effectively what my function generator is outputting right now and I'm going to filter the square into this sine wave and then the final stage is to feed the amplifier which is just a transistor and a couple resistors nothing grandiose here just a regular Class A to use the shape of this signal to actually generate a full voltage of sine wave and if I'm doing that then this being high resistance very little current able to flow through all of these resistors is fine because number one the transistor amplifiers the transistor base needs a small signal and then it amplifies that's why it's called an amplifier but second it's more energy efficient now the whole thing is energy inefficient we're doing this for fun but the point is think about what's going on when you user resistance is high resistance actually problems sometimes no sometimes just sometimes no it depends entirely upon the situation in this case because we're feeding into an amplifier we don't care so I can use more resistance to get a better shape with the same number of components and there you go now one question you might be asking and before that question like I said the difference this makes is noticeable but it's not major I'm going to do it because I want that little bit more smooth than this but we got a plenty smooth wave we got a sine wave we got a kind of rough cut sine wave but we got a sine wave with just the three bigger ones and less resistance but I'm gonna do the better one what if these are in the reverse order what if I have the one nano farad then the ten then the hundred the hundred nano farad being the final filter let's do a quick demonstration so I will now turn up all of the potentiometers at zero I will turn up the first potentiometer which is connected to the one nano farad capacitor as we can see roughly does its job now I will turn up the second one now that we have about 0.5 volt drop from the peak turn up the second filter on the ten nano farad and then the third filter on the 100 nano farad and there is the same roughly two volt peak-to-peak minus one to one that we had a minute ago but hopefully you can clearly see this is not smooth the doll this is straight up a triangle wave and I'm using less resistance to the first potentiometer connected to the one nano farad capacitor I barely turned up at all in fact I turned it up about as much roughly speaking as I did when these were reversed but when I had the 1 nano farad capacitor in the third position I turned it all the way up to 500,000 ohms but if I had turned it up any more I would have lost too much voltage so by the time I turn these up so that I get the voltage I want we've barely smoothed it all so if you're trying to low pass filter you always want to go from biggest to smallest and looking at a spec sheet for these capacitors or any similar capacitors would probably give you a response curve of frequency versus resistance effective series resistance for a capacitor so you could see from that which frequencies you're likely going to filter out I just realized my hand is fuzzy when I do that but in short it doesn't work so let me put them back the original way so it is less resistance so let's just let's just count one two three four five five notches on my screwdriver is the full rotation of this potentiometer so to get the curve where I want it I do one that's one two the signal is already degenerate so I have to do less than one notch for the first filter let's do one once again the signal is already almost gone so it's less than one and this third one once again less than one so much less resistance much much much less resistance in fact similar for all three just to get down to the crappy triangle wave but if I switch them back to where I had them first the one hundred nano farad then the ten and then the one so now let's count one and it brings it way down so the first one the 100 nano farad I need very little lose half a volt on the peak the second one one and that's close to right maybe three-quarters of one 5/6 of one and then the third filter we already know all the way up it's almost exponential so barely any for the first one maybe three-quarters or nearly one for the second one and all five notches on the screwdriver for the third and we get our nice two volt peak-to-peak smooth wave so if you want a nice sine wave you start with a bigger filter then go to a smaller and a smaller and just for fun before I turn everything off I'm going to plug in my other probe so we can simultaneously see the actual input square wave compared to this and get an idea of what we're losing now I don't technically need this ground plug as much because the function generator is grounding it but let's do things right so I'll just plug this straight into the input with no filtering at all turn on the green and then just fix the signal so it's nice and centered and there we go make it a little taller so we can see it now here's an interesting thing remember the charging and discharging cycle the yellow is after all the filters the green is before the filters the pure No so here is where the signal was low and goes to high the capacitors were outputting low and when the square wave switches high and feeds the capacitors they're charging and then when it switches low here they start discharging so through all three capacitors unsurprisingly the frequency is preserved of the core wave but we're filtering out all of the sharpness but as I said we're losing voltage the yellow one is on a 500 milli volt scale the green one the input signal is on a one volt scale if I put them on the same scale this is the voltage we've lost unnecessary evil but we can put it into an amplifier in fact the amplifier doesn't really need very much voltage at all certainly not a two volt peak-to-peak so we could even turn these up just a smidgen more if we want not too terribly much now but I could actually turn these up just a smidgen more not that one I'd need more than 500,000 but if I do a little more filtering we get an even smoother wave and that's perfectly fine this is only a 60 Hertz signal so as you might remember higher resistance means a slower response when the voltage changes but at 60 Hertz you would probably need tarah ohms to really have a detrimental effect on the delay electricity may not go at the speed of light but it goes pretty darn close if we were working with gigahertz signals or even megahertz signals this resistance might start to affect it but at 60 not a bit so I can get myself a smoother wave as I want right into that amplifier and we're done so that's how you change your low-pass filters to get a nice sine wave out of any other wave remember the Fourier series the more filters you have the more high frequencies are filtered out so with an unlimited number of capacitors and resistors you could eventually take any signal whatsoever other than DC and get a sine wave out of it of some kind get yourself down to nothing but that core base wave but fortunately here we need only three and you could do it with two but for me three is a lot easier to adjust it's a lot less fiddly so two or three capacitors two or three resistors and square becomes on so next task is going to be to make it bigger because we don't want to have a 9-volt input and get a one-and-a-half volt output that would be just lame until then be seeing you
Info
Channel: Simply Put
Views: 34,113
Rating: 4.8866215 out of 5
Keywords: simply put, simply, put, circuit, circuits, electric, electrical, electronic, electronics, electricity, filter, filters, filtering, low-pass, low, pass, low pass, square, sine, sinus, sinusoidal, wave, waves, waveform, waveforms, fourier, series, transformation
Id: kbcmLx5qDPk
Channel Id: undefined
Length: 22min 24sec (1344 seconds)
Published: Tue Nov 06 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.