Hello everybody! It's great to be back doing another circuits tutorial. It's been so long since I've done one of these, I almost forgot I was an electrical engineer.
What? This? Oh, don't worry about that.
That's just my, uh, nicotine patch. Yeah. Anyway, today we are going to be building a frequency generator.
The schematic looks like this, the final product looks like this, so let's just jump into it. It's fairly fundamental in electronics to be able to generate a frequency. There are different kinds of waves that you can make.
This would be an example of a square wave, this being an example of a triangle wave, and this being an example of a sinusoidal wave. The circuit I will be building for you today will be able to generate all three. Lovely for us, this circuit can be broken up into two sections.
The first thing that we need to build is a circuit called a relaxation oscillator. And I know what some of you are thinking and you can keep your comments to yourself, alright? So we're going to start our circuit off with two LM741 operational amplifiers. Their pinout looks like what you see on your screen right now. So let's start populating the area around these.
So now we have all of our passive components on this part of the circuit board. Our resistors, our potentiometer, and our capacitor. This potentiometer controls the rate at which the capacitor is charged.
The amount of time that it takes the capacitor to charge will eventually be half of our output frequency. Next, we connect a wire to that output and run a wire back to the input of our first op-amp. We're making a feedback loop so that the circuit will oscillate by itself.
Oh, and before I forget, I should probably add in some power lines. Red is for positive, blue is for negative, and green is for the reference voltage, or ground. Since an AC wave swings between positive and negative voltage, we need to make a thing called a split power supply.
Here, I'm using two 9-volt batteries. And I also added two opposite polarity Zener diodes, because I think they look nice. Also, they quench the voltage to a 5-volt peak.
So I want to stop real quick for a sanity check. This circuit should be generating both a square wave and a triangle wave. So I injected positive and negative 9 volts into it using two 9 volt batteries, and now if I probe the output of the first op amp, I should see a square wave.
And there it is. Second, if I probe the output of this second operational amplifier, I should see a triangle wave. And there that is.
Perfect! So I know that this circuit is working properly. Now if I want to change the frequency, I need to change the value on this potentiometer here.
So if all you wanted to do was make a square wave or a triangle wave, then hey, pretty good, you're done. But we can take this circuit a step further and turn the output triangle wave into a sine wave. Let me show you how. So to turn a triangle wave into a sine wave, we take our output and we feed it into this thing called a wave shaper. Now, these are kind of touchy and hard to get right.
Basically how it works is it takes advantage of the known voltage drop across these silicon diodes, which is 0.7 volts. So we kind of use this as scissors to cut down the triangle wave into a sine wave. So that looks pretty good, but unfortunately we can't really draw a whole lot of power off of here. And by shaping the wave, we've dramatically reduced the voltage.
So we're going to need to build an amplifier to bring that voltage back up to workable levels. There we go. So what we've just added is an amplifier here. We've taken our waveform, which was only a couple of volts off of the wave shaper, and now we've boosted that back up.
And how much we've boosted it by depends entirely on this resistor right here. And this will tell the amplifier either to give it more or less power until it's reached the voltage it wants. Now technically this is an inverting amplifier, which means it takes our wave and flips it upside down. But since our wave is AC, I don't care. Alright so the circuit is pretty much done as is, but there's still a little bit of room for improvement.
You see these ICs really can't sink a whole lot of current. But we can add one more amplifier after this so that we can get as much current as we want out of this. Okay, so here's the final step. I took the output of this circuit and I fed it into a push-pull amplifier, which uses a PNP and an NPN transistor to further amplify the wave, and now we're only limited by how much current these transistors can push through them. And then, at the junction between the push-pull amplifier, we have our output frequency.
Let's put it under an oscilloscope and see how it looks. And finally, if we probe the voltage off of our push-pull amplifier, we get this. It looks the exact same as coming off the op-amp, but this will be able to handle a whole lot more current.
With the transistors I chose, maybe an amp. Now, this wave is fairly clean, but if you have a problem that you get wobble or some distortion on this, All you need to do is add a small capacitor between the output and ground, and that should make that wobble disappear. So with that, I'd say this circuit is done. Here's a close-up of it in case there was something you didn't get a good look at before.
Now if following these arbitrary paths comes difficult to you, I've also designed this PCB that has all of the wiring already integrated, and all you need to do is put components in the right spot. My gift to you! If you go into the description of this video, You'll find Gerber files that you can send to any manufacturer. So let's get this stuff off the breadboard and onto the PCB.
And there we go, the board is now all soldered. Took me about 15 minutes to put this all together, and I just moved all of the components from the breadboard onto this. This board is the final evolution of the circuit, granting the user complete control over the variable frequency and the amplitude of the output voltage.
By default, this will output a sine wave. If you want the triangle wave, just don't build the wave shaper. And if you want the square wave, just run a jumper wire from there to the output push-pull amplifier.
You should probably also know that there are a few absolute limits on this design. The ceiling voltage for these operational amplifiers is plus and minus 15 volts, and you can reasonably expect them to reach up to a 100,000 hertz frequency before they begin to crap out on you. So there we go everybody, I hope you got some value out of this video and that you now feel confident to build this circuit either on a breadboard or on the PCB, link in the description.
I will be available to answer any of your questions in the community comments and feel free to subscribe to this page for more circuit tutorials coming soon. Okay, thank you!