HELP with function generator using OpAmps!

Discussion in 'The Projects Forum' started by Narrin, Oct 2, 2011.

  1. Narrin

    Thread Starter Member

    Oct 2, 2011
    47
    0
    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
     
  2. praondevou

    AAC Fanatic!

    Jul 9, 2011
    2,936
    488
    post the ms file please.
     
  3. Narrin

    Thread Starter Member

    Oct 2, 2011
    47
    0
    Here is the multisim file for that function generator.
    View attachment Working 741.zip

    I have changed C1,R3 and C2 in order to get the amplitude of the Square and Triangular waves to 5V pk to pk.
     
  4. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,535
  5. Narrin

    Thread Starter Member

    Oct 2, 2011
    47
    0
    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
     
  6. praondevou

    AAC Fanatic!

    Jul 9, 2011
    2,936
    488
    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...
     
  7. Narrin

    Thread Starter Member

    Oct 2, 2011
    47
    0
    Yes i have also noticed that Dc offset occuring but i am not sure why.
     
  8. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,535
    Cool. Point of order, I will only participate on this thread. I'll try to keep up on it though. Good luck.
     
  9. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    So, what are you going to do about the offset?

    Hint: the 741 has adjustments for input offset, the 158 does not.
     
  10. praondevou

    AAC Fanatic!

    Jul 9, 2011
    2,936
    488
    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: Oct 2, 2011
  11. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    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.
     
  12. Narrin

    Thread Starter Member

    Oct 2, 2011
    47
    0
    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?
     
  13. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    Most old opamps have assymmetrical clipping. Use a modern "rail-to-rail" opamp or a Cmos logic oscillator.
     
  14. Narrin

    Thread Starter Member

    Oct 2, 2011
    47
    0
    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
     
  15. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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.
     
  16. Narrin

    Thread Starter Member

    Oct 2, 2011
    47
    0
    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?
     
  17. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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?
     
  18. Narrin

    Thread Starter Member

    Oct 2, 2011
    47
    0
    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.
     
  19. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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.
     
  20. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    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.
     
Loading...