Designing a functional function generator using op-amps

Thread Starter

MateoEV

Joined May 26, 2023
17
Hello everyone,

I'm currently having some trouble over a lab practice in which I was required to build an op-amp based function generator. The primary requirement is to generate square and triangle waves (varying their frequencies through potentiometers) using LM-741 IC's. Initially, our professor provided schematics for a function generator with stable frequency output, but once we tried implementing the circuit, the output voltage was not promising. I then decided to try and design my own circuit, I'm sharing it in the schematics below.

1685153118896.png

The first sub-circuit works as an astable multivibrator designed using a hysteresis comparator and the charge voltage of a capacitor (C1). The next chunk is supposed to generate the triangle wave by integrating the oscillator output, although as the square wave frequency raises, the integrator gain lowers. To compensate for this gain loss, I had to add a third op-amp acting as a small-signal inverter amplifier. Please note that the input resistor for this third circuit (R7) is half of a double potentiometer, whereas the other end of this component (R3) must be used to change the frequency of the square wave generator (changing the C1 capacitor's charge and discharge time).

Anyways, the circuit works just fine, but the problem is the frequency variance does not add up to my initial design's math, and I can't figure out why. According to my calculations, as R3 varies I should be able to generate square and triangle waves with frequencies from 226Hz up to 41KHz, but in reality the output frequency varies only between 300Hz and 900Hz. This remains true even in Multisim simulations. I've read that LM-741's have an internal 30pF capacitor that lowers this op-amp gain as frequency goes higher so could that be the issue? Also, when implementing the real circuit I noticed an undesired DC offset in the triangle wave. Can someone help me figure out how to fix those issues?
 

WBahn

Joined Mar 31, 2012
30,071
Did your calculations take into account that the output of the 741 isn't going to get particularly close to the supply rails? That is going to have an effect on your hysteresis levels, which is going to have quite an impact on your switching times (though, without giving it much though, I would expect this to result in the frequency being higher than anticipated compared to assuming that you have rail-to-rail outputs. Perhaps that explains why your low end is 300 Hz instead of 226 Hz?

Do your calculations take into account the typical slew rate of the 741, which is only 0.5 V/µs? So if your output is having to transition from -13 V to +13 V, it's going to take it 52 µs. Then another 52 µs when it goes the other way. That right there means that it will be spending about 100 µs making the transitions. But at 40 kHz, the total period is only 25 µs, so the output of your opamp is going to be a pretty small triangle wave, instead of a pretty large square wave.

To add insult to injury, the 741 can typically only put out about 25 mA. When you have R3 down near zero ohms, you are trying to get the 741 to deliver that or more just through R2, on top of what it has to deliver to R5.
 

LowQCab

Joined Nov 6, 2012
4,075
One problem that I noticed right away is that
a 550-Ohm-Load is probably going to be too heavy for linear operation.

With a 30-Volt Supply, You can expect the 741 to overheat,
and eventually fail, when maximum Frequencies are being used, ( 550-Ohm-Load ).

The 550-Ohm Resistor,
and possibly the Frequency-Adjustment-Pot,
may also overheat, and fail.
What are their Wattage-Ratings ?

In Your Simulator, measure the Output-Current of the Oscillator,
then compare that with the Spec-Sheet of the 741.
.
.
.
 

Thread Starter

MateoEV

Joined May 26, 2023
17
Did your calculations take into account that the output of the 741 isn't going to get particularly close to the supply rails? That is going to have an effect on your hysteresis levels, which is going to have quite an impact on your switching times (though, without giving it much though, I would expect this to result in the frequency being higher than anticipated compared to assuming that you have rail-to-rail outputs. Perhaps that explains why your low end is 300 Hz instead of 226 Hz?

Do your calculations take into account the typical slew rate of the 741, which is only 0.5 V/µs? So if your output is having to transition from -13 V to +13 V, it's going to take it 52 µs. Then another 52 µs when it goes the other way. That right there means that it will be spending about 100 µs making the transitions. But at 40 kHz, the total period is only 25 µs, so the output of your opamp is going to be a pretty small triangle wave, instead of a pretty large square wave.

To add insult to injury, the 741 can typically only put out about 25 mA. When you have R3 down near zero ohms, you are trying to get the 741 to deliver that or more just through R2, on top of what it has to deliver to R5.
Hello and thank you for your reply! I wasn't expecting to get one that fast.

First of all, yes I did take into account that the hysteresis levels would never get to 15 V. I actually got my frequency values from the capacitor charge depending on R3's maximum and minimum values and also the logarithmic relation for it's charge and discharge time (considering a 13.5 upper and lower threshold). One thing I did not consider is the typicall slew rate for 741 IC's... that surely has to have an impact on how the circuit works. But even so, if that is the case, I should be getting a triangle wave once my desired output is over 18.5KHz right? The problem is the circuit seemed to work only between 300 and 800 Hz frequencies which is out of my understanding.

Lastly, on the current issues you mentioned, I did not really understand your explanation. Are you saying the maximum output current of 741 IC is around 25 mA? If that's the case, are you saying I'm demanding more current than it actually can provide or less? Sorry for the trouble, English is not my mother-tongue and I haven't used it in conversation for a long time.

Also, thanks for your help.
 

Thread Starter

MateoEV

Joined May 26, 2023
17
One problem that I noticed right away is that
a 550-Ohm-Load is probably going to be too heavy for linear operation.

With a 30-Volt Supply, You can expect the 741 to overheat,
and eventually fail, when maximum Frequencies are being used, ( 550-Ohm-Load ).

The 550-Ohm Resistor,
and possibly the Frequency-Adjustment-Pot,
may also overheat, and fail.
What are their Wattage-Ratings ?

In Your Simulator, measure the Output-Current of the Oscillator,
then compare that with the Spec-Sheet of the 741.
.
.
.
Hello, thanks for replying.

The maximum wattage ratings for all resistors is 0.25W, which surelly could be a problem and I actually did not notice (I'm not sure about the potentiometers). Even so, when I connected the circuit at the lab It did not seem like any of the IC's were heating, although I'll have to check again next week so thank you for the heads-up!
 

Thread Starter

MateoEV

Joined May 26, 2023
17
But even so, if that is the case, I should be getting a triangle wave once my desired output is over 18.5KHz right?
Sorry, I just noticed that doesn't make sense... To get a nice square wave, the frequency probably has to be much much lower than that.
 

WBahn

Joined Mar 31, 2012
30,071
The slew rate is going to significantly affect your output frequency well before you get to a frequency that prevents it from getting to it's max value. While it is slewing, the charge on the capacitor will be changing more slowly than expected. I don't know that I would expect it to slow it down so much that you see less than 1 kHz, since at that point the transition time should only be about 10% of the total period.

But the heavy load on the opamp output might be coming into play, as well. And, yes, the 25 mA is the typical spec on what it can either source or sink. Also, the max voltage swing is greatly effected by how heavily it is loaded. +/-13 V is typical when run from +/-15 V supply when it is driving a 2 kΩ load (to common). But, even with that load, the minimum could be only +/-10 V. You are asking it to drive 550 Ω (to a point on the other side of common, which makes it an even heavier load).

Since you are saddled with a 741 as a given, I would recommend that you reduce the loading on it by at least an order of magnitude.
 

Thread Starter

MateoEV

Joined May 26, 2023
17
1685160896684.png

These are the currents I'm getting at max frequency through simulation: 6.5mA (p-p) and 1.56mA (p-p). Should this be fine? I'm really not getting what you mean by "heavy load"? Does that mean I should increase this 550 ohm resistor or decrease it's value? Or do you mean the potentiometer value?

Thanks for the replies, I'll keep working on this circuit through next week so I'll keep you posted on any updates.
 

WBahn

Joined Mar 31, 2012
30,071
What does the voltage waveform look like at the opamp output?

The current through R5 is saying that the peak to peak variation is 1.56 mA. That would suggest that the Vpp at the output is about

Vpp = (1.56 mA)(11 kΩ) = 17.16 V

Which would imply that the output is only getting to about ±8.6 V.

I also note that it is saying that the frequency is 9.2 kHz. That is much more in line with the kind of impact I would expect to see due to slewrate and loading limits. Notice that, at this frequency, the output should be pretty close to a triangle wave at the slew rate limit, assuming the simulation model imposes that behavior (which the voltage waveform should tell us pretty quickly).

If the slew rate is modeled at 0.5 V/µs, then this should be a trapezoidal wave with the ramps consuming about 60% of the period. If it is a triangle wave, then the slew rate would be about 0.33 V/µs, which would be too unreasonable.

The slow transition is going to drastically reduce the peak currents through R2, because the peak current would occur just after the output changes when the capacitor voltage is still at the old threshold and the output has swung quickly to the other rail (or as close as it can get). But with the slow slew rate, the capacitor voltage is changing almost as quickly as the output voltage is, which holds the voltage across R2 to a much lower value.
 

Thread Starter

MateoEV

Joined May 26, 2023
17
What does the voltage waveform look like at the opamp output?

The current through R5 is saying that the peak to peak variation is 1.56 mA. That would suggest that the Vpp at the output is about

Vpp = (1.56 mA)(11 kΩ) = 17.16 V

Which would imply that the output is only getting to about ±8.6 V.

I also note that it is saying that the frequency is 9.2 kHz. That is much more in line with the kind of impact I would expect to see due to slewrate and loading limits. Notice that, at this frequency, the output should be pretty close to a triangle wave at the slew rate limit, assuming the simulation model imposes that behavior (which the voltage waveform should tell us pretty quickly).

If the slew rate is modeled at 0.5 V/µs, then this should be a trapezoidal wave with the ramps consuming about 60% of the period. If it is a triangle wave, then the slew rate would be about 0.33 V/µs, which would be too unreasonable.

The slow transition is going to drastically reduce the peak currents through R2, because the peak current would occur just after the output changes when the capacitor voltage is still at the old threshold and the output has swung quickly to the other rail (or as close as it can get). But with the slow slew rate, the capacitor voltage is changing almost as quickly as the output voltage is, which holds the voltage across R2 to a much lower value.
Ah yes, you are absolutely right I do have to increase R2's value for this to work. I think the IC model in my simulator considers a lower slew rate (probably around 0.33V/µs as you mentioned) because the output wave is not trapezoidal but triangular (see image below). I guess I will have to check the specific slew rate for my LM-741 components and re-do the calculations taking this into account. I surelly will give you an update next week as I try this out. Thanks a lot for the help, I sure was getting frustrated.

1685163589280.png
 

WBahn

Joined Mar 31, 2012
30,071
You really want to design your circuit so that you can ignore the slew rate (meaning that the fact that it isn't instantaneous has limited impact on the circuit behavior).

The reason is simple -- pick ten different opamps out of the tube, and you will have ten different slew rates. Warm up the opamp, either because of internal heat generation or just the room changing temperature, and the slew rate will change.

As a result, you will never get stable, predictable performance if your design relies on a nominal slew-rate value that is assumed to be constant.

What are the requirements for the function generator for this lab? What is the frequency range that it needs to be adjustable over?
 

Thread Starter

MateoEV

Joined May 26, 2023
17
You really want to design your circuit so that you can ignore the slew rate (meaning that the fact that it isn't instantaneous has limited impact on the circuit behavior).

The reason is simple -- pick ten different opamps out of the tube, and you will have ten different slew rates. Warm up the opamp, either because of internal heat generation or just the room changing temperature, and the slew rate will change.

As a result, you will never get stable, predictable performance if your design relies on a nominal slew-rate value that is assumed to be constant.

What are the requirements for the function generator for this lab? What is the frequency range that it needs to be adjustable over?
Oh I see... I didn't know slew rate could be affected by room temperature nor the IC heat generation. Thanks for ponting it out. The problem is we don't have specific requirements set by the professor, he first told us we just had to be able to adjust the wave amplitude and frequency to a specific value and confirm the circuits functioning through oscilloscope measurements.

As I presented how my circuit worked, he stated that a frequency change of 600 Hz was not acceptable if my calculations expected a nearly 40KHz change when varying R3. He then said we should aim for at least a 5KHz frequency change, but I'm really not sure we can manage that given the variable operating slew rate you mentioned. I guess if I can explain and justify the 741's limitations through math he will give the circuit a pass, but I still would like to know how to improve it's functioning. I'll surely have to check the design again, and try to make it so the slew rate doesn't have a big impact on the generators functionality.
 

LowQCab

Joined Nov 6, 2012
4,075
Have any minimum, or maximum, Frequency-limitations been established ?

Is there any problem with having a Frequency-Range of maybe ~1Hz to ~5KHz ?
( The 741 is going to have serious Slew-Rate-problems when operating above ~5KHz )
.
.
.
 

WBahn

Joined Mar 31, 2012
30,071
Instead of trying to get all of your frequency adjustment from a single potentiometer, use a switch to select different capacitors that set a range and use the pot to adjust the frequency over that cap's range.

Right now, you are trying to adjust a resistance between 0.55 kΩ and 100.55 kΩ, a span of a factor of 200. That's going to make it much more sensitive at one end than the other. Instead, try something like a factor of 10 or 20. With 20 you could span 5 kHz down to about 250 Hz with one cap and then 250 Hz down to about 12.5 Hz with a second. A third could get you down into the sub-hertz range.

You can mitigate both the variability and uncertainty of the output voltage limits by clipping the output to narrower limits. This also reduces the impact of slew rate because the transition time between the narrower limits will be less.
 

Thread Starter

MateoEV

Joined May 26, 2023
17
Have any minimum, or maximum, Frequency-limitations been established ?

Is there any problem with having a Frequency-Range of maybe ~1Hz to ~5KHz ?
( The 741 is going to have serious Slew-Rate-problems when operating above ~5KHz )
.
.
.
Well in my initial design I hoped to get it to work between around 230Hz and 41KHz, but after everything I've learnt from this thread I now know that will not work using the 741. My professor will probably accept my design if I get it to work between 1Hz and 5Khz as you suggest, I'll have to try it out.
 

Thread Starter

MateoEV

Joined May 26, 2023
17
Is that the only op amp you can use?
There has not been any restriction set on which op-amps we should use, but we sure can not use any op-amp based IC's such as AD630. But even if there is a better option out there, it probably won't be easy to find in my country. If you have any suggestions I would be glad to hear them out.
 

Thread Starter

MateoEV

Joined May 26, 2023
17
Instead of trying to get all of your frequency adjustment from a single potentiometer, use a switch to select different capacitors that set a range and use the pot to adjust the frequency over that cap's range.

Right now, you are trying to adjust a resistance between 0.55 kΩ and 100.55 kΩ, a span of a factor of 200. That's going to make it much more sensitive at one end than the other. Instead, try something like a factor of 10 or 20. With 20 you could span 5 kHz down to about 250 Hz with one cap and then 250 Hz down to about 12.5 Hz with a second. A third could get you down into the sub-hertz range.

You can mitigate both the variability and uncertainty of the output voltage limits by clipping the output to narrower limits. This also reduces the impact of slew rate because the transition time between the narrower limits will be less.
Right, we did notice sensibility was a bit off due to the potentiometer's value span, thanks for the suggestions.
 

crutschow

Joined Mar 14, 2008
34,459
it probably won't be easy to find in my country. If you have any suggestions I would be glad to hear them out.
Find an op amp in your country (wherever that is) that has better frequency response and slew-rate characteristics.
Otherwise you won't be able to meet the specified required circuit operating characteristics.
 
Top