HELP with function generator using OpAmps!

Thread Starter

Narrin

Joined Oct 2, 2011
47
Good day,

PLEASE HELP
I have a project to simulate and build a low cost function generator. This can be either using Op amps, IC timers or Function Generator IC's.
I must first simulate this or many examples/types of function generators using the Multisim sotware. It must include a switch for the type of wave (sine,triangular,square) and also a switch to vary frequency.

I have successfully simulated 2 circuits so far using Multisim. The question I am about to post is based on 1 of them. It is a function generator based on a LM158 Op amp and 3 other 741 opamps.
The problem i have at the moment is trying to get all the waves to the same amplitude. I want them to be at +5/-5V peak to peak. I have achieved that with the square and triangle waves but i cant get the sine wave to get to that amplitude...right now it is at around +2.5/-2.5V pk to pk. I am changing the external resistors and capacitors of the sine wave shaper and i cant get it to budge without totally altering the shape of the sine wave....PLEASE HELP.

View attachment FG741.pdf

FG741.jpg
 

Thread Starter

Narrin

Joined Oct 2, 2011
47
Good day Bill,
I have read through that thread and i am looking at simulating that design sometime tonight, i will let you know how that goes.
I am also going to try to simulate your design using the IC555 timer for the function generator. I will let you know how that goes also. Thank you
 

praondevou

Joined Jul 9, 2011
2,942
problem of the simulation looks like an offset problem, I don't know why yet, just had it put into the simulator. from the very first signal , the square wave, the signal has an DC offset, and it gets worse every stage...
 

Wendy

Joined Mar 24, 2008
23,421
Cool. Point of order, I will only participate on this thread. I'll try to keep up on it though. Good luck.
 

praondevou

Joined Jul 9, 2011
2,942
Ok, the initial offset seems to steem from the fact that you don't have a 50% duty cycle on the square wave output. Try to correct this first.

Edit: it works with a zero DC offset square wave. since your oscilator is not exactly 50% duty cycle you can achieve this by adjusting the first opamp's output voltage more negative (offset circuit at the +input).

The sine wave shaper I tried with 8.2nF and R6=47k, the gain of the last opamp has to be increased in this case. Then you get your 5Vpp at the output.
Multisim does also some strange things sometimes, I wouldn't be so sure that it's showing correct values/circuit behaviour.
 
Last edited:

Audioguru

Joined Dec 20, 2007
11,248
The offset voltage of the square-wave is caused by the assymetrical clipping from the lousy old LM158 opamp. Its output goes low to almost -9V but it goes positive to only +7.7V.

The Multisim schematic had + and - wires all over the place so I changed them to symbols. The - supply was shown backwards. The output 'scope was connected wrong.
 

Attachments

Thread Starter

Narrin

Joined Oct 2, 2011
47
I was wondering about that oscilloscope connection, thanks.
As for the LM 158 OpAmp, i can see from the oscilloscope that it clips the output and it is that which affects the duty cycle, so should i change the OpAmp to another such as the LM342 or TL071,TL072?
 

Thread Starter

Narrin

Joined Oct 2, 2011
47
Okay so i changed the Op amp to a FET input Opamp. I used the TL034CD. It removed the DC offset completely and also gives me a purer sine wave.

Now i have to try to tweak the circuit so that the Square, Triangle and Sine waves are at the same amplitude, preferably 5V pk to pk.
Once that is done i have to look at a switch to change the frequency of the waves.

TL034.png

View attachment WOrking TL034.zip
 

SgtWookie

Joined Jul 17, 2007
22,230
Don't bother tweaking the levels without the switch. The resistors in the path to the output amp, along with R11, is what controls the gain of the output amp.
 

Thread Starter

Narrin

Joined Oct 2, 2011
47
Okay but for the output of the opamps what i am concerned about is that i am getting a small difference in the positive and negative peaks such as:

Square: +7.96V, -7.86 V
Triangular: +1.54V, -1.83V
Sine: +5V, -6.7V

The triangluar and sine wave is a problem as the difference is of 300mV and 1.7 V respectively. Is that because of the Opamp itself clipping the waveform?
 

SgtWookie

Joined Jul 17, 2007
22,230
So, why do you suppose that's occurring?

Do you know what the input offset is for these opamps?

Do you know what your gain per stage is?

Do you realize that the input offset, multiplied by the gain of the stage, is cumulative?
 

Thread Starter

Narrin

Joined Oct 2, 2011
47
I can see from the oscilloscopes that the offset is amplified in each stage.

I am not totally sure what is the input offset of the op amps. I have an idea what input offset voltage is but, pertaining to this circuit i will have to do research on what it is exactly.

I know the gain per stage, that can be calculated.
I know that to rectify the offset problem, something has to be done with the input offset of the first op amp. I will do research on the matter and reply soon.
 

SgtWookie

Joined Jul 17, 2007
22,230
Do you know how to see what your actual input offset voltage is?

Wire the inverting input to the output directly.

Connect the non-inverting input to a voltage roughly halfway between the supply voltage.

Then measure the voltage difference between the noninverting input and the output. That's your input offset.

Then, multiply the input offset by the gain of the stage; that's the error at the output of the 1st stage.

Then find the input offset error of the 2nd stage, and calculate the gain of that stage. Then, multiply the error from the first stage by the gain of the 2nd stage, multiply the offset of the 2nd stage by the gain of the 2nd stage, and add the two results together; that is the cumulative error.

By the time you get through to the last stage, the input offset error from the 1st stage has been multiplied by the gain of ALL of the stages. So, it's better to keep the gains fairly low to keep from amplifying the input offsets.
 

Audioguru

Joined Dec 20, 2007
11,248
You have the opamps DC-coupled so they amplify the DC input offset voltage. If a coupling capacitor or two and biasing are added then the DC gain is 1 but the AC gain is high like what you want.
 
Top