I created an Op Amp integrator with LM358 to convert square wave to triangle wave as shown below.


simulate this circuit – Schematic created using CircuitLab

Though the circuit sometimes works as I expected, but sometimes when I restart my signal generator square wave output, the output will be exceed voltage rail.

enter image description here

(The yellow one is the output of signal generator and the blue one is the output pin of the Op Amp, both 1V/div )

I am 90 percent sure that this problem raised because my generator not outputting perfect waveform on the beginning and the waveform take some time to become stable. And this will make the integral result go to voltage rail and cannot be integrated back. However, I am not sure how to solve this and make the circuit more stable and always start working. I hope this can be bettered because latter I want to connect it to a 555 timer and the timer, just like my function generator, not start working perfectly as I observed on the scope days ago.

Thanks for any suggestion.

Thanks to vangelo's suggestion, I changed the cap to a 224 one. And then the circuit works a lot of better that I turned on and off the signal generator ten times and all of them works well. However, I found I can still repeat my problem by screw the R3 to a low resistance. (Originally the connected side measures about 5kOhm and now I turned it to about 2kOhm) And here I finally captured how the circuit go out of control. (Same scope configuration as the above and before this experiment I checked probe again and it's OK)

enter image description here

The screenshot was taken by one shot but what happening, if in Auto mode of scope, I can notice triangle wave after turning signal output on in several seconds or frames maybe. And in that way it is after my generator works stable state that the circuits go wrong... Also, I found another problem is when the signal was turned off, the output of Op Amp is about 3.6V but not 2.5V, I believe this is caused by offset voltage and offset current. Should I compensate it in this application and how?

  • 1
    \$\begingroup\$ "... the output will be exceed voltage rail." This is impossible unless you inject power from somewhere else. What is the signal generator output? Add a caption below your 'scope screengrab to explain what points in the circuit yellow and cyan refer to. \$\endgroup\$
    – Transistor
    Jul 7, 2019 at 9:34
  • \$\begingroup\$ @Transistor image caption fixed. But I really observed that the output go below 0V on my scope by about 0.7V (showed in the attached image), though I do not expect this will happen too, but it does... \$\endgroup\$
    – Page David
    Jul 7, 2019 at 10:18
  • \$\begingroup\$ I don't see any integration happening at all. Instead, I see an AC-coupled copy of the input signal. Are you sure your opamp is powered up every time? \$\endgroup\$
    – Dave Tweed
    Jul 7, 2019 at 11:19
  • \$\begingroup\$ @DaveTweed I am sure, I powered the Op Amp by bench power supply. The only thing I did is turn on and off the signal generator several times. \$\endgroup\$
    – Page David
    Jul 7, 2019 at 11:28
  • \$\begingroup\$ Then how do you explain the lack of any triangle wave? Do you have a loose connection somewhere in your setup? \$\endgroup\$
    – Dave Tweed
    Jul 7, 2019 at 11:29

2 Answers 2


The condition for integration using differential equations are;

Ic =C dV/dt where dV = output Vpp in dt ramp time for 1/2 triangle time

  • Thus if you wanted to integrate a 1Vp 1kHz square wave into a 5Vpp Triangle ( using a RRIO OA )
  • dV/dt = 10V/ms from 5V for each half cycle of 0.5ms
  • Ic= 100 uA = Vin/R = 1Vp /10k (Pot max)
  • thus C = Ic* dt /dV = 10 nF [uA*ms/V]

Whereas you show 10uF which is far too big as pots only have a 300:1 range and 10 Ohms is too high a current to drive with 10uF @ 1kHz.

Always use specs and 1st principles when in doubt. Ic=CdV/dt

For a better design with included sig Gen.

Use a Schmitt Trigger Astable that buffers the Triangle wave to constant amplitude.

  • \$\begingroup\$ That's make a lot sense. Could you please take some time to read my new edition (experiment after lower the cap) and explain the what caused the problem? Thanks. \$\endgroup\$
    – Page David
    Jul 7, 2019 at 12:46
  • \$\begingroup\$ can you use my values and no pot with no inductive wire lengths ? Rin=10k Reduce Vin to 1Vpp to prevent saturation \$\endgroup\$ Jul 7, 2019 at 12:50
  • \$\begingroup\$ See this improved design tinyurl.com/y4hnbvgj \$\endgroup\$ Jul 7, 2019 at 13:28
  • \$\begingroup\$ Here is what I get after soldering the circuit to a perfboard with the value you suggested. It's working well except the distortion which, I believe, can be solve by a Rail-to-Rail one. But I still have some questions, first, should pot be used to adjust current to compensate 10% error of the cap? Second, can I get RtR triangle wave without a RtR Op Amp (to lower cost)? \$\endgroup\$
    – Page David
    Jul 8, 2019 at 2:47
  • \$\begingroup\$ You didn't reduce the input nor did you attempt to understand what I write nor comment on the better design I offered you. You can easily reduce gain...dV/dt=Vin/RC \$\endgroup\$ Jul 8, 2019 at 6:19

Here is a guess. Your R and C values are so large for the 1kHz frequency you use that your pot. may be adjusted to a very low value:

enter image description here enter image description here

If you just see this when turning off the voltage source an than back on again very quickly, you may consider the capacitor initial voltage different than zero.

You could capture this with a one-shot trigger. BTW, please check your probe compensation.

  • \$\begingroup\$ You cannot drive R=10 with full swing \$\endgroup\$ Jul 7, 2019 at 12:48
  • \$\begingroup\$ @SunnyskyguyEE75 of course not. What in my post led you to understand that I as suggesting it as a fix, instead of trying o find an explanation for the problem in the original question. \$\endgroup\$
    – devnull
    Jul 7, 2019 at 13:18
  • \$\begingroup\$ Then explicitly suggest a fix with current limit criteria. Or better a CMOS Triangle generator of constant amplitude, variable freq. using a trimpot for f \$\endgroup\$ Jul 7, 2019 at 13:19
  • \$\begingroup\$ I did, in the comments, and the question was updated. \$\endgroup\$
    – devnull
    Jul 7, 2019 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.