Triangle Wave Generator

Thread Starter


Joined May 1, 2020

Currently, I am working on designing a class D amp and started with the triangle wave generator.
I have built the following circuit:


Right now it seems to work and generates a decent triangle wave, but the problem is if I lower or increase the voltage the wave falls apart. Is that normal behaviour or could the circuit be improved? If so how, and why it is better that way.

Also, are these op-amps suited? I know these are high frequencies but these were the best I had around.

Thanks for your time.


Joined Jul 11, 2016
? try R3 C1 : 120 1n -> 1k2 100p
? set 1k:1k as op amp follower (Fig.3 Fig.4 offset trim) offset is dependent on the supply voltage ← if you change it you need to invent circuitry that adjusts for such (Fig.35 fig.36 same as prev.)
PS! -- you only need to trim the offset of the one op amp to match the other
your first op amp won't produce square-wave because of it's "moderate" slew rate
you need comparator or digital inverter .... there unfortunately is thousands of ways to set up such circuit . . . so you need to make one that meets all your requirements
↓ this one has the "warm-up" time of 1ms ↓
Op-Amp - 3-wave - TEST - 10.gif
Last edited:


Joined Aug 1, 2013
Without some feedback, the DC operating point of the output of the circuit in post #2 will drift over time until the output saturates.

In the circuit in post #1, R5 is too small with respect to R4. The ratio of these two sets the output amplitude. As is, the output amplitude is so large that there is zero operating headroom. To start, increase R5 to 10K and see if things are better for you.



Joined Mar 2, 2015
Also, are these op-amps suited?
They'll function, but are not ideally suited for this job (specifically, for U1 in your diagram). As @Audioguru again noted, the OPA27 has input protection diodes that will affect the operation of your circuit in "funny" ways.

This op amp, and others of its kind such as the OP177, OP277, LT1007/LT1037 and many others, have diode clamps connected across their (+) and (-) inputs to protect the differential input stage transistors from excessive reverse base-emitter voltage, as shown in the op amp internal schematic in the data sheet:

OPA27 Schematic.png
One effect of these diodes is that they restrict the maximum differential voltage that can be applied between the inputs without causing damage to the op amp, as reflected in the Absolute Maximum Ratings section of the data sheet:

OPA27 Ratings.png
So long as the surrounding circuitry limits the input current to ± 25 mA or less no damage will result, but another effect comes into play: if either of the diodes becomes forward biased, any current flowing into either input will also flow out of the other input. In circuits using positive feedback to create a comparator with hysteresis, such as your U1, this can mess up the operation of the circuit if you're not careful.

In your case the feedback current flowing through R4 into the op amp's (+) input will flow back out the (-) input into your R1-R2 voltage divider that's providing bias voltage for the circuit. That current is in the form of a square wave of roughly 1 mA peak-to-peak amplitude and will cause your bias voltage to bounce up and down by about 500 mVp-p due to the non-zero impedance of the voltage divider. That square wave voltage will then get superimposed on U2's triangle wave output, which might (or might not) be undesirable.

If that's a problem and you want to get rid of it, pick a different op amp for U1, one that does not have that particular input structure and which can withstand large differential input voltages.

'Tis oft said that in electronics, "the Devil is in the details." And this input protection diode issue is one of those details that can trip you up.

Always consult the data sheet. Always observe the Absolute Maximum Ratings and the performance parameters of the part to look for "gotchas."


Joined Mar 2, 2015
In the circuit in post #1, R5 is too small with respect to R4. The ratio of these two sets the output amplitude. As is, the output amplitude is so large that there is zero operating headroom.
The effect of the R4/R5 ratio is actually the opposite of that: having a small value for R5 reduces the amplitude of the triangle wave output, since it takes less output voltage to overcome the hysteresis feedback through R4 than it would if the two resistors were equal.