Basic Function Generator help - Page 1
Forum section: electronics / beginners

author: dcbrown73
author_rank: Regular Contributor
timestamp: August 04, 2019, 01:23:31 am
content: To preface this, yes. I know this isn't a great function generator. I'm using it just to learn.In the circuit below. (image 1) Right now I'm just trying to learn (re use) the first part that creates the square wave. (image 2)I've set this up on my breadboard, but it does not create a square wave. It sits at a constant voltage. If the pot is turned all the way to the right, it sits at 25mv. If I turn it a maybe 25% of a turn, the op amp comes on and the output sits at 2v.Now, I've never read anything on how this is supposed to work. I was figuring that the pot would determine how quickly the 1uF cap charged and once it was charged, the amp would turn off and the cap would discharge and voltage would drop triggering the amp to come back up and recharge the cap thereby creating a sqaure wave.Well, in my recreation of the circuit. That isn't happening.Question 1. Am I mistaken that just trying to use the first part of the circuit will create a square wave?Question 2: If my assessment is incorrect. A) how is it supposed to work, and B) do I actually need more of the circuit to get a square wave to function?

author: Brumby
author_rank: Unknown
timestamp: August 04, 2019, 01:49:26 am
content: I'm no Op-amp guru - but the answer to Q1 is: No, you are not mistaken.What I will ask, however, is what is your power supply setup...?

author: Jwillis
author_rank: Super Contributor
timestamp: August 04, 2019, 02:20:38 am
content: Do you have a dual rail supply?I think It needs to oscillate between the positive and negative to work properly.I could be wrong to.Not an expert either.

author: Dabbot
author_rank: Regular Contributor
timestamp: August 04, 2019, 02:46:46 am
content: I just built the first stage up. Works for me. ~20Hz square wave.9.6V supply. Using another LM324 to provide the ground.Can you supply pics of what you've built?

author: Brumby
author_rank: Unknown
timestamp: August 04, 2019, 07:50:02 am
content: Quote from: Jwillis on August 04, 2019, 02:20:38 amExactly. Which is why I asked the Op.

author: MrAl
author_rank: Super Contributor
timestamp: August 04, 2019, 12:19:34 pm
content: Hi,The circuit works roughly as follows.Say we have a +12.2v and -12.2v power supply and say the op amp is ideal.When the output goes high, we see +2.2v across the 22k resistor.The cap then starts to charge higher and higher until it reaches just over +2.2v, then the inverting terminal has a higher voltage than the non inverting terminal so the output goes low.When the output goes low, we see -2.2v across the 22k resistor.Now the cap starts to discharge lower and lower until it reaches just under -2.2v, then the inverting terminal becomes lower than the non inverting terminal so the output goes high again.Now just reread this paragraph. The cycle keeps repeating.

author: dcbrown73
author_rank: Regular Contributor
timestamp: August 06, 2019, 12:52:49 pm
content: Sorry for the long delay. Life interjected itself.Well on my first test where I posted here. I was actually using a UA741 rather than the LM324 by accident.I've switched that out. I was also just using a positive rail and ground.I've switched out to the LM324 and I'm now using +9v and -9v rails.I still do not get the oscillation in the circuit. Actually sometimes I'm getting inconsistent results (very low volages) and I have to kill the power turn it back on to start seeing close to 9v on the pins. (the PSU is always supplying the full 9/-9v)Here is an image of the breadboard.

author: kulky64
author_rank: Regular Contributor
timestamp: August 06, 2019, 02:06:09 pm
content: I think you have your pot wired wrong. It looks like you go from pin 1 of the op-amp to the wiper of the pot, then from upper end of the pot back to pin 2 of the op-amp. So far good. But it looks like the lower end of the pot is connected through black wire to ground. You only need two connections to the pot, leave one end unconnected. Also you used electrolytic cap between pin 2 and ground. This cap should be non-polarized type, because it sees both positive and negative voltages across it.

author: dcbrown73
author_rank: Regular Contributor
timestamp: August 06, 2019, 02:22:11 pm
content: Quote from: kulky64 on August 06, 2019, 02:06:09 pmThank you I will take a look when I get home. Although, I don't think I have any caps of 1uF that are not electrolytic caps. I have only purchased an electrolytic cap kit and a ceramic cap kit.What type of cap would be best to use here?

author: kulky64
author_rank: Regular Contributor
timestamp: August 06, 2019, 02:27:57 pm
content: Ceramic or film should work fine.

author: rstofer
author_rank: Super Contributor
timestamp: August 06, 2019, 02:45:26 pm
content: It's probably just the way the photo is cropped but I don't see where pin 11 (Vee) connects to anything other than the blue rail which, apparently, goes nowhere. Are the PS connections out of the photo?I would prefer to connect the two binding posts that create the midpoint together at the PS. I want only 3 wires leaving the supply, not 4.I don't know anything about your breadboards but on many of the longer boards, the power rails aren't continuous from end to end. There is a gap in the middle. That fact has caught up a lot of new users.

author: Audioguru again
author_rank: Regular Contributor
timestamp: August 06, 2019, 04:57:58 pm
content: Photos of solderless breadboard circuits are always a tangled mess of wires all over the place.In your schematic, the slider of your pot is not shown where it connects to.

author: dcbrown73
author_rank: Regular Contributor
timestamp: August 06, 2019, 06:57:31 pm
content: Quote from: rstofer on August 06, 2019, 02:45:26 pmI'm not home, but this a picture of the the breadboard I'm using. I have the red (+9v) / black (-9v) banana plugs jumpered to all the red / blue rails on the board.The + and - pins entering the opamp were tested and are at sitting at -9v (blue) and +9v. (red)Quote from: Audioguru again on August 06, 2019, 04:57:58 pmIn this picture, the pot's wiper is connected to the output pin while other is connected to the -input. I've flipped it before too. I figured since it's a non-polarized variable resister. It probably didn't matter.As suggested above. I will remove the 3rd pin from being connected to the gnd rail (which is sitting at -9v)

author: Gyro
author_rank: Super Contributor
timestamp: August 06, 2019, 07:23:21 pm
content: @dcbrown73:A small request. Can you please change your thread title to something more related to the topic, eg. 'Basic function generator'? It's easy to do by editing the title in your original post and might just help somebody in the future.

author: kulky64
author_rank: Regular Contributor
timestamp: August 06, 2019, 08:00:59 pm
content: Can you post a picture of the whole setup (power supply, all leads and breadboard) all in one frame at the same time when you get home? So we don't have to guess where things not in frame are connected.

author: rstofer
author_rank: Super Contributor
timestamp: August 06, 2019, 09:10:31 pm
content: Quote from: dcbrown73 on August 06, 2019, 06:57:31 pmI missed what you said.There are 3 wires to deal with: +9, -9 and Gnd. If you are talking about using one of the 'blue' rails for Gnd, well, that's pretty much what you have to do. You need 3 rails running down the side; 2 on one side of the board and 1 on the other. It makes sense to have the + and - on the same strip with Gnd on another strip.

author: rstofer
author_rank: Super Contributor
timestamp: August 06, 2019, 09:22:43 pm
content: It may not be obvious on the schematic that the output pin of the first op amp is connected to one end of the pot and one end of the 100k resistor. The 'dot' is a little small. I didn't try to trace the wiring...Also, the wiper on the pot is not shown as connecting to one end of the pot. It is shown just dangling in space. I think this was discussed above.

author: dcbrown73
author_rank: Regular Contributor
timestamp: August 10, 2019, 02:35:50 pm
content: Okay, I rewired the board with short 22 gauge wire, a smaller pot, and I obtained a film cap. Hopefully it's more clear how it's connected now.The cap I've had both connected to -9v and not connected (as you see in the picture)Here is how the power supply is wired.Now, I actually got it to produce a square wave (once) at close to the supplied voltage, but it was operating at 1hz. I was expecting much higher.Most of the time, I'm just seeing a terrible looking sine wave in the mV range sitting right around 60hz which I'm guessing is just AC ripple.What is weird is I had the square wave. I turned the output off on the power supply and when I turned it back on. I started getting the 60hz, mV sine wave. Without changing anything.A majority of the time, I'm just getting the sine wave. (you can see the counter) I generally have to turn the PSU completely off and come back later before I see the square wave again.Clearly something is wrong.

author: bjbb
author_rank: Contributor
timestamp: August 10, 2019, 02:55:59 pm
content: Missing a 'ground' equipotential that would be the return reference.

author: dcbrown73
author_rank: Regular Contributor
timestamp: August 10, 2019, 03:03:56 pm
content: Quote from: bjbb on August 10, 2019, 02:55:59 pmAre you referencing the cap not being connected to ground in the first picture?The second picture shows I did connected, it just wasn't connected in the first image.That begs the next question. Since the rails are +9v / -9v. Do I actually require a GND (0v) potential also?For instance, when I measure the waveform with my scope. Do I connect the gnd connection to the -9v rail?It's a bit maddening. Earlier someone said you need to ensure my rails are +9v / -9v for this to work, but I saw a video of someone powering the entire thing with a 9v battery which didn't produce a -9v rail.

author: MarkF
author_rank: Super Contributor
timestamp: August 10, 2019, 03:08:44 pm
content: It looks like your power is NOT connected properly.The LM324 pin 4 connected to +9V (red wire in picture) and pin 11 connected to -9V (yellow wire in picture).The GND (black wire in picture) connected to the capacitor and 22K resistor. The GND appears to be missing (See 2nd picture).

author: MarkF
author_rank: Super Contributor
timestamp: August 10, 2019, 03:24:54 pm
content: Quote from: dcbrown73 on August 10, 2019, 03:03:56 pmConnect the +/-9V rails to the op-amp only.Connect the GND of power supply to capacitor, 22K resistor and scope GND.You need all three connections from the power supply.

author: dcbrown73
author_rank: Regular Contributor
timestamp: August 10, 2019, 05:11:35 pm
content: I've been an IT engineer for well over 20 years (servers, storage, networks, and software development) and I have never had anything that stumped me the way this little simple circuit is while trying to get it to function. I feel like throwing the entire thing into the fireplace! I don't have this issue with other circuits I've tried to replicate as a learning experience.Given I'm not an electrical engineer I'm going to create a legend that will properly explain my terms since I could be naming one incorrectly and I want to eliminate confusion.If I say positive rail. I'm talking about +9v rail. (DMM tested to show +9v)If I say negative rail. I'm talking about the -9v rail (DMM tested to show -9v)If I compare the positive rail to the negative rail, I show a 18v potential difference. (DMM tested)If I say gnd. I'm talking about 0v rail. By 0v rail, I mean if tested, it shows +9v compared to the positive rail, and -9v compared to the negative rail. (DMM tested)The 1uF film capacitor is connected to the 100k pot and the gnd rail.The normally gnd pin of the 100k pot is left unconnected.The the negative side of the 22k resistor connected to the voltage divider is connected to the gnd rail. (not the negative rail)Those are the only two connections to gnd. I can connect the pot's ground pin to gnd, but someone said not to.Tested pins of the op-amp as measured against gnd.Vcc: +9vVee: -9v+input: 11.5mV-input: -18.6mVoutput: 15.5mVIt seems to me the op amp just isn't turning on and I haven't the slightest idea why. If I test on everycircuit, if I lower the inverting input below the non-inverting input. The opamp comes on. It seems based on the measurement above, the inverting input is at a -29mV potential difference, yet the opamp remains off.Do I need a pull up/down resistor?In the picture below. The PSU jumpers as are follows:Red Banana Plug: +9vBlack Banana Plug: -9vYellow Banana Plug: GND

author: Audioguru again
author_rank: Regular Contributor
timestamp: August 10, 2019, 05:54:21 pm
content: A "volume control" has a ground terminal. The pot in your circuit is a variable resistor, not a volume control.Your circuit is not oscillating maybe because your variable resistor is set to be a resistance that is much too low.

author: dcbrown73
author_rank: Regular Contributor
timestamp: August 10, 2019, 06:14:20 pm
content: I was poking around the circuit and measured the resistances way above expected on the voltage divider, so I moved the voltage divider away from the op amp and reconnected everything. Now I get an (almost) perfect square wave and the pot controls the duty cycle.Something was off about it, but it seems to be functioning perfectly now. At least I know I'm not crazy now...

author: kulky64
author_rank: Regular Contributor
timestamp: August 10, 2019, 06:23:01 pm
content: Try to adhere to regular color coding convention and use black color only for ground connections and nothing else. Now you have mix of black, blue, yellow and red colors in your ground node and your -9V node is all black. Sooner or later you probably blow something up when you will try to measure your signals with scope or frequency counter because you subconsciously connect ground lead to first black wire you spot on your breadboard.

author: MarkF
author_rank: Super Contributor
timestamp: August 10, 2019, 07:06:06 pm
content: Quote from: dcbrown73 on August 10, 2019, 06:14:20 pmThe trim pot should adjust the frequency. Not the duty cycle.https://www.instructables.com/id/THE-SIMPLEST-FUNCTION-GENERATOR-BUILT-ON-A-BREADBO/

author: dcbrown73
author_rank: Regular Contributor
timestamp: August 10, 2019, 07:23:06 pm
content: Quote from: MarkF on August 10, 2019, 07:06:06 pmCorrect, what I was thinking and what I typed were two different things.