Conversion of Triangular Wave to Sine Wave

When integrating, one often needs to include a constant of integration. In the case of crutschow's circuit, that is the voltage on the integration capacitor. If that voltage is set to the proper value when the input triangle is applied, the process will take off as desired.

But, there's an easier way. Just use a leaky integrator. The resistor across the integration capacitor provides the leak and after the circuit runs for a while the initial transient dies out and the output of the integrator no longer tries to head to infinity.

Here are 3 approximations to a sine wave, in order of increasing goodness. They show the sine wave in blue, and the approximation in red. First a truncated triangle wave. The minimum harmonic distortion is 4.47%

SineApprox1.png

Next, a parabola which is what crutschow's integrator produces when fed with a triangle wave. The minimum distortion is 3.8%

SineApprox2.png

Finally, the slightly overdriven differential amplifier, which gives a hyperbolic tangent (tanh) approximation. The minimum distortion is 1.36%, but with an irritating cusp on the top of the wave:

SineApprox3.png
 

crutschow

Joined Mar 14, 2008
34,442
Well, i found that it's not that the physical integrator is acting like a low pass filter it is something else. We can see it's not acting like a filter i think by noting that decreasing the time constant still gives us a pseudo sine of the same shape.
..........................
Yes, decreasing the time constant has no affect on the integrator output wave-shape but that's because an integrator acts as a low-pass filter with a constant 6dB/octave roll-off and no corner frequency.
Thus it attenuates the fundamental and the signal harmonics by the same amount no matter what the integrator time constant is, consequently the output only changes amplitude, not shape, as the time-constant is changed.

I think perhaps you are overthinking this. :rolleyes:
An integrator is just an integrator, whether in theory or in practice.
 
Last edited:

MrAl

Joined Jun 17, 2014
11,480
When integrating, one often needs to include a constant of integration. In the case of crutschow's circuit, that is the voltage on the integration capacitor. If that voltage is set to the proper value when the input triangle is applied, the process will take off as desired.

But, there's an easier way. Just use a leaky integrator. The resistor across the integration capacitor provides the leak and after the circuit runs for a while the initial transient dies out and the output of the integrator no longer tries to head to infinity.

Here are 3 approximations to a sine wave, in order of increasing goodness. They show the sine wave in blue, and the approximation in red. First a truncated triangle wave. The minimum harmonic distortion is 4.47%

View attachment 94605

Next, a parabola which is what crutschow's integrator produces when fed with a triangle wave. The minimum distortion is 3.8%

View attachment 94607

Finally, the slightly overdriven differential amplifier, which gives a hyperbolic tangent (tanh) approximation. The minimum distortion is 1.36%, but with an irritating cusp on the top of the wave:

View attachment 94608
Hi,

Some very GOOD illustrations.
The truncated triangle is interesting because it's so close already.
The pointed one at the bottom is what actually irritated me for years when all i had was that type of sine wave generator back then.
There is one missing however, and that is the actual analysis output of the circuit which i think was:
y=t-t^2/2

That's the actual output of the circuit we have been talking about. If you could plot that with the other ones i think that will be informative. It will also have to be plotted in a limited range so we dont have to account for the change in polarity of the input signal.

I dont think you need a leaky integrator because the signal being used goes both plus and minus. When it goes just positive it will create a very high output after a time, which will never come back down. When it goes both pos and neg then it will maintain some average value, but will always have the extra term (subtractive or additive) because of the way the triangle appears to the input.
 
Last edited:

MrAl

Joined Jun 17, 2014
11,480
Yes, decreasing the time constant has no affect on the integrator output wave-shape but that's because an integrator acts as a low-pass filter with a constant 6dB/octave roll-off and no corner frequency.
Thus it attenuates the fundamental and the signal harmonics by the same amount no matter what the integrator time constant is, consequently the output only changes amplitude, not shape, as the time-constant is changed.

I think perhaps you are overthinking this. :rolleyes:
An integrator is just an integrator, whether in theory or in practice.
Hello again,

Well we could test the idea of the harmonic reduction by injecting all the harmonics of the triangle wave into an integrator and then looking at the output. Perhaps the amplitude grows as the time constant comes down and that keeps the relative attenuation the same. At first it looks as though if we push a 1vpeak triangle through the integrator with an RC time constant of 1 second and get a smooth output, if we reduce the time constant to RC/1000000 then we would not see as much attenuation of the harmonics. But yes they may still be the same relative to each other.

See i come from the world of control theory as well as regular analog theory. In control theory, when you say "integrator" it means a block integrator that integrates the input signal, and if we integrate a triangle we dont get a sine wave or anything close to that, we get a sine wave with inverted half cycles. The way to right this is to either use a constant (not as good perhaps) or a lower order time term, and the only way that can come about is with the addition of a step change to the input as well as the triangle.
In a simulation this will enter as JUST a triangle wave, but in theory the step is present as well. That's the only way to get a near sine output. If we integrate JUST the triangle, we dont get a sine wave, but if we integrate a triangle with a (subtracted) step, then we get a near sine. I dont see any way around this because if you do a full analysis of the integrator circuit, you get a subtracted (or added) term which results as the near sine, but only if you use the added step input. If you dont include the added step input then you dont get a near sine wave. With just the triangle we get a single term like K*t^2, which is clearly not right.
I think this might happen if we run the harmonics of the triangle through the integrator, real or not, but i havent tried this yet. The input would have the harmonics of the triangle alone:
x=sin(wt)+sin(3*wt)/9+sin(5*wt)/25+...+etc.

[LATER]
Just tried it theoretically by generating a long series, then integrating over time. The result was that the integration does produce a sine like wave of low amplitude, but it is all above zero. We could probably loose that with the 'leaky' integrator as Electrician proposed.
I think this could be just because we dont need the step when we represent the triangle like this because the sin() function has an implied step already. So this test really didnt show us anything new.

So i guess the conclusion is that the subtraction (or addition) is always present or else we dont get a near sine wave output.

It is also informative to look at the integration of just a ramp, not a triangle, over a limited time range. This tells us right away that something else must be included too.

Here is a plot comparing a real sine to the harmonic injection theoretical experiment. Red is the real sine wave and blue is the result of the integration of the addition of several of the harmonics of a pure triangle.

Sine-NearSine-1b.gif
 
Last edited:

crutschow

Joined Mar 14, 2008
34,442
If you notice, my simulations were with a leaky integrator (R1 across the integration capacitor).
That is needed in the real world to take care of any asymmetry in the triangle wave or offsets in the op amp.
Otherwise the output will drift to one of the rails and saturate.
 

MrAl

Joined Jun 17, 2014
11,480
If you notice, my simulations were with a leaky integrator (R1 across the integration capacitor).
That is needed in the real world to take care of any asymmetry in the triangle wave or offsets in the op amp.
Otherwise the output will drift to one of the rails and saturate.
Hi again,

It's interesting how that changes the mathematical form of the output, from an algebraic polynomial in time to a time exponential and a time term and constant term:
From: A*t-B*t^2
To:A*e^(-at)+D*t-C (or something like that)

so the math comes out a little different with that added resistor, but still produces a pseudo sine wave.
I guess that extra resistor changes the frequency response a little too.
 

crutschow

Joined Mar 14, 2008
34,442
Hi again,

It's interesting how that changes the mathematical form of the output, from an algebraic polynomial in time to a time exponential and a time term and constant term:
From: A*t-B*t^2
To:A*e^(-at)+D*t-C (or something like that)

so the math comes out a little different with that added resistor, but still produces a pseudo sine wave.
I guess that extra resistor changes the frequency response a little too.
The resistor value is high enough that it has little effect on the integration at the frequencies being simulated.
It only affects the very low frequencies where drift and offset come into play.
If you substitute the actual values into your equations, you should see that.
 

MrAl

Joined Jun 17, 2014
11,480
The resistor value is high enough that it has little effect on the integration at the frequencies being simulated.
It only affects the very low frequencies where drift and offset come into play.
If you substitute the actual values into your equations, you should see that.

Hi again,

Didnt i say that it had a little effect? :)

Anyway, here is the plot of all three equations. The two in question are blue and green, and for the second method the second resistor R2 is made to be 100 times the input resistor R1, and still not much difference.

Where i come from if there is a difference, even a little difference, you want to know about it. That way you always have the choice of whether to ignore it or not. Here i think we can choose to ignore it.
 

Attachments

Top