I am trying to generate a sinusoidal wave whose frequency I can control based on the input being a triangular wave. I am getting the sinusoidal waveform by integrating the triangular wave through an op-amp integrator.

The issue is that as the frequency of the input triangle wave increases, the amplitude of the sine wave decreases. I basically want automatic gain control, so I do not want to manually compensate for it by adding a gain stage with just a potentiometer.

I know that I might be missing something obvious, if so, please point it out.

Here is the circuit I am talking about for reference. Vin is the triangle wave and Vout is the sinusoidal waveform. enter image description here

As I understand, the integration takes place on the -20dB/decade of the low pass filter which explains the gain loss as frequency increases. My initial thought was to have a second stage with a frequency dependent resistor(capacitor) which would adjust the gain based on the frequency as below:

The problem is that this created a differentiator which undoes the sinewave and converts it back to a triangle wave.

Is this the incorrect approach? What other approaches can I take? Thanks. enter image description here

  • \$\begingroup\$ What frequency range are you talking about? \$\endgroup\$
    – Andy aka
    Dec 12, 2022 at 18:57
  • 1
    \$\begingroup\$ Is there a reason you're starting with a triangle and converting it to a sine rather than generating the sine directly? \$\endgroup\$
    – brhans
    Dec 12, 2022 at 19:23
  • \$\begingroup\$ Andy aka, for the moment I am attempting 100Hz to 10kHz, but I would like to later on go up to 20kHz. \$\endgroup\$ Dec 12, 2022 at 19:50
  • \$\begingroup\$ Brhans, part of the reason is because I am using a triangle wave generator circuit. Basically a square wave generator circuit fed into an integrator to make a triangle wave. I can control the frequency of the square wave which controls the resulting waveforms frequencies. I do not know of any alternate methods of generating dynamically adjustable sine wave. For example, a Wein bridge oscillator would require me to change all resistors at the same ratio to change frequencies which is not preferred. \$\endgroup\$ Dec 12, 2022 at 19:53
  • \$\begingroup\$ Use a "function generator" made with diodes ... (triangle -> sine). \$\endgroup\$
    – Antonio51
    Dec 12, 2022 at 19:55

4 Answers 4


A better way to use a fixed gain op-amp and attenuate the non-inverting input with a common 1 ohm FET drain. However with tolerances of Vgs(th) = Vt = 2 to 4V to control and Id= (Vgs-Vt)^2. Then use a reference voltage for the desired positive peak with a fast attack to attenuate and slow decay (called ducking).

This way you only need to be concerned about the GBW you need for the desired BW at any net gain with attenuation.

E.g. GBW >= 20 MHz with 60 dB gain using CMOS R2R op-amps.

A triangle wave has all the odd harmonics of a square wave attenuated by integration of -6 dB /octave.

A sine wave has none of the harmonics but was often generated using a nonlinear transfer function for fixed amplitudes with a precise shape to eliminate. That was 50 years ago. Sine waves can be created by integration and AGC but then you have the lag in amplitude control when changing frequency if you expect a fast change.

There are much smarter ways to program a sine wave nowadays but this is a good experiment. I suggest you make a list of testable specs or expectations before the design.


Function generators often use a triangle waveform as the source of a variable-frequency waveform, just as the OP proposes.
Amplitude of the triangle waveform is independent of frequency, by forcing the rising slope and falling slope to be variable. Slope is set by DC current sources - feeding an integrating capacitor. Peak amplitude of the triangle wave is set by hysteresis-switch threshold voltage. Here's one way to do triangle, square, sine waveforms:
Current source "I1" is matched to current source "I2": these current sources are alternately switched on/off based on hysteresis switch output. Switching between I1 and I2 is usually done with diodes. Hysteresis switch output has 50% duty cycle, and also provides square-wave output.
block diagram triangle, square, sine function generator
By varying DC current I1 (and its mate I2), frequency can be varied in a proportional way. Current sources I1 & I2 might be as simple as single NPN & PNP transistors with matched emitter resistors. The diode diverting I1 away from the capacitor every half-cycle, and the diode diverting I2 away from the capacitor during the other half-cycle are not shown.

To generate sine, a diode-array forms a sinusoidal wave from the triangle waveform by piece-wise approximation. Each diode adds in more attenuation as the triangle wave approaches each peak: similar diodes/resistors for the negative peak as for the positive peak. As few as three diode/resistor (plus three for the other peak) can roughly approximate sine shape - six double-sets do a better job, providing 24 line segments every sinusoidal cycle.
This piece-wise sine generator method is independent of frequency, but must be applied to a triangle waveform whose amplitude is the same at all frequencies...the triangle wave generator described above meets this requirement since the hysteresis switch is designed to switch from I2 to I2 at a fixed threshold voltage.


I have made an AGC using a 2N3819 NJFET and Op-Amps. Here is a simulation of such a circuit. The first Op-Amp is a programmable gain block that produces sine waves amplified according to a stepped control signal. That signal is then processed by another dynamically adjusted gain block where the rectified and filtered output is compared to a reference level, so the output is regulated at that point over a range of amplitudes. This circuit could be further optimized.

Sine wave AGC regulator using JFETs


This is a "simple" schematic to try.

Notice the "distortion" at every harmonic, 5th is the highest.
The amplitude of the triangular wave (V4) is 0.9 Vpeak, offset 2.5 V.

enter image description here


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.