# Making a Triangle wave on LTSpice using LM741 opamp

I'm trying to get a 1kHz, 15V triangle wave on LTSpice. For that, I'm using the following design:

So far, my Square Wave has the desired frequency and amplitude, but my triangle wave has a lower amplitude. How can I correct this so both waves match at +15v and -15v?

I'm using the following specs, sorted out by some formulas but also trying. There are some values that I don't see how affect what I get.

• Vcc=15v
• R1=150k
• C1=3.03361n F
• R2=R3=100k
• R4=R5=1k
• C2=1000n F
• R6=3k

Thanks a lot for your help.

EDIT: [UPDATED] here's a caption of the actual simulation i'm running on LTSpice:

• Please use the built-in schematic editor (Use control-M to start it) to enter your schematic. The LM741 can't get its output closer than 2.5 volts or so to the supply rails. Nov 30, 2016 at 22:55
• You are right, and that explains that my square wave was peaking at 13.4 V, but the triangle wave is moving just between -3 and 3v. Dec 1, 2016 at 1:36

There a few problems with your circuit:

1) The second stage will generate an exponential rather than a triangle. 2) The resistor values for feedback on the second stage are much too low - the amplitude may be limited by the output current capability of the 741. You can use something in the range 10k-100k. 3) The actual amplitude of the output will be limited by the opamp. The 741 os a very ancient opamp and is not as good as more modern ones - as Peter mentioned the output cannot get closer than ~2.5v to the rail.

This configuration should give better results:

It still uses two opamps and only needs one capacitor to set the timing.

The first stage is arranged as a schmitt trigger to detect when the output of the second stage reaches voltages determined by resistors R1 and R2. The second stage is configured as an integrator and will produce a triangular wave with linear slopes.

The square wave output is still determined by the saturation of the opamp as before, an opamp with rail to rail output will get very close to the supply rails.

• This was very helpful. With this circuit i'm able to create a square signal and a triangle signal of the same amplitude. I'm just trying to figure out how to set the parameters to get the desired frequency. About the LM741, I've seen they're not the best available option but I'm required to work with them. Dec 1, 2016 at 15:34

Dan,

There is two components to your the generator ±15 V Triangle Wave Generator you are trying to generate, the first stage is the Schmitt Trigger Oscillator then the Integrator so I think it would be appropriate to discuss them separately first.

Regarding Schmitt Trigger Oscillator:

First, let's discuss how it operates to aid the understanding let's refer to the figure below. Image source here.

Step 1: The Excitation

An excitation -- namely the intrinsic noise in your system will go into the Op Amp, and will be amplified by the "Closed Loop Gain" which approaches the "Open Loop Gain" much like it does in an basic Op Amp integrator circuit.

Step 2: The Saturation

Ideally it would be amplified forever, however the Op Amp has Output Limitations which causes the output to saturate at VCC or a voltage close to it, depending on the Op Amp. Your output will look similar to this at the beginning:

Image source here.

This is important because you might not be able to achieve an output of ±15 V due to the Op Amp Output "Voltage Swing" Limitations. Note that as other commenters have noted this depends on your load, which in your current set up is around 1 kOhm.

The Texas Instruments LM741 Datasheet specs between ±10 V and ±13 V for a 2 kOhm load, so as the other commenters have suggested you might want to increase the Integrator's resistor values.

For more details on Output Limitations check this.

Step 2: The Switching

You can use the following definition to determine the Output Voltage of your comparator, given the current state:

$$V_{OUT} ≈ \ \left\{ \begin{array}{ll} -V_{CC} \quad \to \quad V_{OUT(new)} ≈ +V_{CC} \quad when \quad V_{IN-} > V_{IN+}\\ +V_{CC} \quad \to \quad V_{OUT(new)} ≈ -V_{CC} \quad when \quad V_{IN+} > V_{IN-}\\ \end{array} \right. \$$

For example, if your output voltage is around +15 V, it will go to around -15 V when the voltage in the negative input of the Op Amp (i.e. the voltage accross C1) is greater than the voltage in the position input of the Op Amp (i.e. the voltage accross R3).

This is important because understanding this helps you determine your RC time constant, with some algebra and assuming R2 = R3 you can find the following relationship between frequency and your RC Constant:

$$f_0 = {1 \over T} = {1 \over {2 \cdot RC \cdot \ln{(3)}}}$$

Note that the rise and fall times of the output will be limited by the "Slew Rate" which will get worst the bigger your load is (the smaller your resistive load is).

Finally, a word of caution about using an Op Amp as Comparator

Some Op Amps implement Input Overvoltage Protection by using "Clamping Diodes", which limits the Op Amp's differential input voltage (the voltage measured between the two Op Amp inputs) to diodes' voltage (usually ~0.7 V).

The LM741 is OK to use, other options would be TL084 and OPA192, ranked as follows:

LM741 - OK, TL084 - Better, OPA192 - Best

For more details on Op Amps as Comparators, check this.

Regarding the Integrator:

Let's first look at the simple OpAmp Integrator:

The dotted line represents the "Open Loop Gain" of the Op Amp (the internal gain of the Op Amp) and the Solid Line represents the "Closed Loop Gain" of the Op Amp (the gain set by R5 and R6).

The issue with this implementation is that unlike an Ideal Op Amp and current going into and out of the Op Amp inputs is not zero, another non-ideality is "Offset Voltage" which is modeled as as small voltage source at the input of the Op Amp.

The point is that both of these are DC imperfections, and because the "Closed Loop Gain" is so high at DC (i.e. Frequency = 0 Hz), they will be amplified causing a DC offset in your output voltage.

Adding R6 limits the "Close Loop Gain" at lower frequencies and it goes from beging like the figure below (in the left) to the figure below (in the right), effectively creating a Low-Pass Filter.

where:

$$f_C = f_{Cut-Off} = f_{-3 dB} = {1 \over {2 \cdot \pi \cdot R5 \cdot C2}}$$

and,

$$f_L = f_{Unity-Gain} = f_{0 dB} = {1 \over {2 \cdot \pi \cdot R4 \cdot C2}}$$

Note: having R5 being 100 times bigger than R4 allows for enough separation between 'fC' and 'fL' to allow for the circuit to behave as a "good" integrator.

This is important because the frequency of the signal that you want to integrate should be above 'fC' but before reaching 'fL'. In other words should be in the yellow shaded area in the figure above.

First C2:

Your first problem is that C2 is too big... think of a Capacitor as a Variable Resistor (or Frequency Controlled Resistor) that decreases under two conditions:

• Increasing Frequency.
• Increasing the Capacitance value.

Remember that a Capacitor is a "Frequency Controlled Resistor" and having C2 = 1 uF, at 1 kHz looks like a ~160 Ohm Resistor, that means that if R5 = 1 kOhm then 'fL' < 1 kHz, so your signal will get attenuated significantly.

Decreasing C2 to somewhere between 100 nF and 220 nF should be a good starting point to increase 'fL' enough.

Then R5:

R5 is too small, that means that you will have an very small area where your circuit will behave as a good integrator (i.e. 'fC' and 'fL' are too close to each other).

Increasing R5 to 100 kOhm (that is 100⋅R4), puts 'fC' at a lower frequency, increasing the range of frequencies for which your circuit will behave as a good integrator.

As I mentioned before, one of the disadventages of the non-ideal Op Amp for an Integrator is that the "Bias Current" (i.e. current coming and going out of the Op Amp input pins).

R6 is meant to aid with this issue and it should be R6 = R4||R5, however, this method it is not always effective because it depends on the Op Amp.

For more details on Input Bias Cancelation Resistors, check this.

Yes, you should have an off-set due the DC Op Amp non-idealities being amplified by the DC 'Closed Loop Gain', adding a "coupling" capacitor (between the Schmit Trigger Oscillator and R4) has two results:

1. The DC error introduced by the Schmit Trigger Oscillator no longer affects the Integrator. This is because the Capacitor is like a "Frequency Controlled Resistor" and at DC / low frequencies it looks like an open circuit, given you choose the appropiate capacitor size.

2. The second result is a change in the "Closed Loop Gain", remember how introducing R5 made the Gain "flat" (i.e. 0 dB slope) at lower frequencies?, well adding the coupling capacitor would make lower frequencies have a slope of +20 dB (coming from minus infinity), the result would be the following:

What is going on in that triangle thing, anyways?

The reason the DC error is improved is that you can think of the area under the + 20 dB slope as a differentiator, and the derivative of a Constant (i.e. DC) is zero!

In the figure above, the circuit would be a Differentiator at frequencies below 1 kHz and Integrator above that.

You need to be keep in mind that:

• A lower C will give you the better DC perfomance (less offset), but your AC peformance (Integration) is affected.

• A higher C will not necesarily give you better performance, because your impedance is limited by C2.

Some simulations on TINA-TI show that 0.47uF and 1.0uF are your best option, because you will get the DC benefits and still have a good enough slope for integration.

Just a note:

1st order Low-Pass has a slope of -20 dB, and acts as an Integrator

1st order High-Pass has a slope of +20 dB, and acts as an Differentiator

1st order Band-Pass is an integrator at lower frequencies and differentiator higher frequencies (like the figure above).