While this is not my design, this is my analysis and derivations.

I used this in my sound reactive lighting project. I had only one op-amp to spare for a triangle wave generator, so I couldn’t use the popular two op-amp design.

For those who are not interested in the details, you can find the final formulas in an example here.

## Overview

*view this circuit simulation here*

**This single op-amp circuit uses positive feedback with hysteresis to create a square wave, which charges and discharges an RC circuit, which roughly produces a triangle wave.**

Before we begin, assume the op-amp is acting like an ideal comparator. The highest voltage the comparator can output is V_{CC} and the lowest is 0V. These high and low output voltages are determined by the power supply connected to the op amp (which isn’t shown in the schematic).

Start at V_{1 .} For now, let’s ignore R_{3 }. Currently, V_{1} is equal to V_{CC} – this voltage comes from the comparator output. The output is V_{CC} because the noninverting input is greater than the inverting input.

Connected to the comparator output is R_{4} and C_{1} . Together, they act as an integrator. As the voltage on the capacitor ramps up, it produces the up ramp of a triangle wave. This triangle wave appears at V_{2}.

As V_{2} is increasing, it eventually becomes greater than V_{3}. When this occurs, the comparator sees the inverting input is now greater than the non-inverting input. Accordingly, the comparator switches its output from a high voltage (V_{CC}) to a low voltage (0V). With a comparator output of 0V, C_{1} drains through R_{4} . This produces the down ramp of a triangle wave.

Eventually, V_{2} becomes less than V_{3} – the comparator output goes back up to V_{CC} and the cycle repeats.

So far, we’ve ignored R_{3} . However, it is a very important resistor. It allows for the cyclic action by adding hysteresis. It affects the voltage V_{3}. We’ll look at R_{3 }in more detail below.

## Hysteresis and R_{3}

*Left: simplified diagram when comparator output is high (V _{1} = V_{CC} ). Right: simplified diagram when comparator output is low (*

*V*

_{1}= 0V). View circuit hereThis simplified diagram shows all inputs for V_{3}. In this diagram, we’re simplified the comparator output (V_{1}) as a voltage source. V_{CC} , R_{1} , and R_{2} form a voltage divider where the divided voltage is V_{3 }. So does V_{CC} , R_{3} , and R_{2}.

When the comparator output V_{1} is high, the voltage at V_{3 }increases. This sets the upper threshold for the triangle wave – the voltage the comparator’s inverting input must reach in order to cause the comparator output to switch low (0V) and begin the down ramp of the triangle wave.

When the output V_{1} is low, the voltage at V_{3 }decreases. This sets the lower threshold for the triangle wave – the voltage the comparator’s inverting input must reach to cause the comparator output to switch high (V_{CC}) and begin the up ramp of the triangle wave.

In short, R_{3} is adding hysteresis, making the triangle wave possible. The amplitude of the wave depends on V_{CC}, R_{1}, R_{2}, R_{3}, and the maximum voltage output swing of the op-amp. We’ll look at calculating this amplitude next.

## Determining Amplitude

Notice the way I set up the figure from the previous section. It’s ready for Millman’s Theorem. It allows us to quickly write the minimum and maximum voltages of the triangle waves:

We won’t be solving directly for V_{tri,max} or V_{tri,min} with these equations. Let’s introduce some more variables first:

- V
_{O,max}is the maximum output of the comparator (you can find this on the data sheet under Maximum Voltage Output Swing). It is typically within 1 volt of V_{CC} - V
_{O,min}is the minimum output of the comparator (you can find this on the data sheet under Minimum Voltage Output Swing). It is typically within 1 volt of V_{EE}. - V
_{tri,amp}is the desired amplitude (peak-to-peak voltage) of the triangle wave. This is a value you choose. It is equal to:

- V
_{tri,max}is the maximum peak voltage of the triangle wave. While this value won’t be calculated for determining amplitude, we’ll need it to determine frequency in the next section. - V
_{tri,min}is the minimum voltage of the triangle wave. Like V_{tri,max}we will need this value to determine frequency.

Again, our goal is to solve for R_{3} . We can set the two equations from above equal to each other and get the following:

To further reduce this equation, we can set R_{1 }equal to R_{2}. This is a fine assumption for 99% of applications. We’ll also replace V_{tri,max} – V_{tri,min} with V_{tri,amp }.

After reducing, we’re left with the following formula:

where all resistances are in ohms and voltages are in volts.

You choose the value of R_{1} in order to calculate R_{3} . As it is a simple voltage divider, anything between 10 kΩ and 1 MΩ is fine. In the example at the bottom of this page, I chose 100 kΩ.

## Determining Frequency

As mentioned early, the frequency is determined by the R_{4} and C_{1} integrator. Our goal here will be to choose a value for C_{1} then calculate R_{4} .

*simplified diagram of the RC section*

To determine the triangle wave frequency, we’ll start with the RC time constant equation:

This is the formula for the rising section of the triangle wave.

Graphing the formula above as a function of time produces something like this:

The graph above shows that V_{tri,min} occurs at time t_{a} and V_{tri,max} occurs at time t_{b} . The time from t_{a} to t_{b} is the upramp of the triangle wave.

V_{tri,min} and V_{tri,max} will be needed to determine frequency. Assuming R_{1 }is equal to R_{2}, we can calculate them with the following formulas:

t_{a} and t_{b} don’t need to be calculated. However, what we need is Δt – the time between t_{a} and t_{b} . This Δt is one half of the period, so we can express it in terms of frequency:

Notice the 2 in the denominator. It’s because we are calculating the up ramp of the triangle wave, which is only half of a period.

We can create two equations. One at time t_{a} and another at time t_{b} :

Rearranging in terms of t gives:

Subtracting these two equations from each other gives:

We now substitute t_{b} – t_{a} for frequency:

where f is the desired triangle-wave frequency. Frequency is in Hz, capacitance is in farads, voltage in volts, and resistance in ohms.

Note – you have to choose C_{1} first. I recommend starting with 100nF. See more details on this in the Example Design section.

C_{2}, R_{5} , R_{6} , and the output load will change the frequency. As long as the output load is high impedance(100k+), the frequency *shouldn’t* change more than 1%.

## Output Stage

If you want to remove DC bias from the output, then you’ll need to add a coupling capacitor on the output.

## Example Design

This is an example from my Sound Reactor project.

### Step 1 – Define Criteria

For this example, we’ll use the following criteria:

- f = 1.1 kHz
- V
_{tri,amp }= 1 V - V
_{CC }= 12 V - V
_{O,max }= 11.715 V (this value came from the comparator datasheet when the comparator is powered by 12V. I used the MC4558) - V
_{O,min }= 0.285 V (this value was from the comparator datasheet)

### Step 2 – Choose R_{1 }= R_{2}

R_{1} and R_{2} form a voltage divider. I recommend anything in between 10 kΩ and 1 MΩ. Too low of a value will waste power. Too high of a value will cause inaccurate results. I chose R_{1 }= R_{2 }= 100 kΩ.

### Step 3 – Calculate R_{3}

I calculated R_{3} = 521.5 kΩ, which is close to the standard 520 kΩ.

### Step 4 – Calculate V_{tri,min} and V_{tri,max}

This is an intermediate step to get values for R_{4} and C_{1} .

I calculated V_{tri,min} = 5.5 V and V_{tri,max} = 6.5 V.

### Step 5 – Calculate R_{4} and C_{1}

Note – you have to choose C_{1} first. The quick way is guess-and-check. Guess a value for C_{1} and check if R_{4} is a reasonable value.

I recommend starting with C_{1} = 100 nF. If the resulting value of R_{4} is too high (>1 MΩ), choose a lower value for C_{1} and recalculate. If the resulting value of R_{4} is too low (<10 kΩ) choose a higher value for C_{1} and recalculate.

I started with C_{1} = 100 nF. The calculation gave R_{4} = 25.9 kΩ. I settled for an actual value of 24.9 kΩ.

### Results

*view this circuit here*

- f = 1.1 kHz
- V
_{tri,amp}= 1 V - R
_{1 }= R_{2 }= 100 kΩ - R
_{3}= 520 kΩ - R
_{4}= 24.9 kΩ - C
_{1}= 100 nF

## Comparison to the Two Op-Amp Design

The most common design for an op-amp triangle wave generator uses two op-amps. It looks something like this:

The two op-amp design generators a square wave then integrates it to produce a triangle wave. It uses an active integrator, instead of a passive RC integrator.

The two op-amp design uses 8 discrete components and 2 op-amps whereas the single op-amp design uses 5 discrete components and 1 op-amp.

I believe the two op-amp design is overall less dependent on component tolerances and op-amp specs and therefore more consistent from circuit to circuit.

Neither should be used for any circuit that needs accurate, precise, or stable frequencies or amplitudes. Nor for circuits that need a true triangle wave instead of the RC integrated approximation.

Overall, the single op-amp triangle wave generator is certainly simple to implement and practical for real world circuits!

Hi!

I keep calculating your R4 and something doesn’t quite fit y result. Could you explain me the formula a little more? For example what transformations did you make to the numbers as far as kHz , kΩ etc.??

Thanks a lot.

Hm, you’re right – I’m not getting the same results this time either. I’ll recheck my formulas and specify the units. I’ll get back to you on this

Hi Thanos,

I significantly revised this page and fixed some formula errors. Thanks for bringing this to my attention!