# Conversion of Triangular Wave to Sine Wave

Discussion in 'Homework Help' started by eLg, Nov 10, 2015.

1. ### eLg Thread Starter New Member

Nov 10, 2015
1
0
Hi,

I just want to confirm if the following concept is right. If I have an input signal that has some value X or X Vp-p, and it is triangular waveform at frequency f Hz, and I want to convert to a sinusoidal signal or the input signal as a sinusoidal, will the equation be (X/2)sin(2pif)?

2. ### WBahn Moderator

Mar 31, 2012
18,079
4,917
How will that convert one signal into another signal?

What you need to do is filter out everything except the fundamental.

3. ### MrAl Distinguished Member

Jun 17, 2014
2,546
512
Hi,

Just to add a little here...

As Wbaln says, you could filter out the harmonics and that will leave you with just the fundamental which is really just a sine wave at the base frequency. This technique can create an almost pure sine wave.

A second technique would be to use a non linear "breakpoint" type approach. This kind of solution is based on either diodes or transistors (along with resistors) that cause a non linear change in gain over the amplitude range. Each "breakpoint" causes more or less attenuation of the ramping triangle and so the output looks like a pseudo sine wave. The output isnt as pure as with a linear filter, but the advantage is that it is it does not have to be adjusted over a wide frequency range of inputs (the input must always be a triangle though). This is a little bit of a difficult circuit to design though and it's success depends in part on how much experience you have had in the past with circuits like this. Each diode or transistor has to kick in at the right point in the amplitude. A minimum of maybe three to four diodes or transistors would be needed for each half cycle in order to get a reasonably shaped sine wave output.

4. ### WBahn Moderator

Mar 31, 2012
18,079
4,917
I think I follow what you are recommending. If so, wouldn't this approach also depend on the triangle wave always being of the same amplitude and DC level?

5. ### AnalogKid Distinguished Member

Aug 1, 2013
4,678
1,295
Yes, that's why it frequently is used inside waveform generator chips like the 8038, where the amplitude is controlled by design. Externally, it can work well with the classic integrator-comparator square/triangle wave generator with a couple of trimming adjustments, although it takes a lot of parts.

Another option is to use the logarithmic V/I relationship of a transistor to bend the triangle slope into a parabolic curve. This takes fewer parts but needs tighter adjustment

ak

6. ### MrAl Distinguished Member

Jun 17, 2014
2,546
512

Hi there WBahn,

Yes, and so the triangle has to be more or less the same amplitude as the frequency changes. I dont think that part of it is a big challenge though.

As member ak stated, there are a few ready made chips that *used* to be available that use/used this technique, but i am not sure if they are available anymore as they may have been discontinued by the manufacturer. They may still be available in some overstock though.
The internal transistor arrangement for i think the 8038 is available on the web somewhere that shows the part values too. One thing i didnt like about this chip was although the basic concept of doing it with transistors is not frequency dependent, there was still a frequency limitation on that chip of only 1MHz. That means it would work for 0.1Hz, 1Hz, 10Hz, etc., but the max was 1MHz. I could not see this as that great, although it was better than nothing. Then another manufacturer came out with one that went up to 25MHz. Nice. But now that chip is "discontinued" and maybe because that is about the time when DSP generators were coming into the arena. Now the DSP generators (which maybe we should have mentioned also) can go pretty high. I have one that goes from 0.039Hz (much less than 1Hz) all the way up to 40MHz, and i think some will go up to 70Mhz. The chips are sold for about 25 dollars but they sell complete boards with a high order LC filter on the output (to filter out the clock frequency of 125MHz) for about 10 bucks (USD) in places like Amazon and sites in China. These chips/boards are programmable using a microcontroller using a 32 bit program word to set the frequency, from below 1Hz to 40MHz in steps of 0.039Hz !!
You probably already had seen these but im just mentioning them for the good of the thread. Most amazing sine wave generators i've ever seen.

I always meant to build up a transistor version of the 8038 and i even did the simulation and everything, but since there are so many parts it's not something i might do in one afternoon. I think there were 8 transistors and many resistors for the output shaping section. I wanted to see if i could get higher frequency using good discrete transistors, like maybe up to 5MHz. I could see that happening, but never actually got around to trying it.
The 8038 waveshape isnt as pure as with the other techniques too, so it's only good for certain things. Certainly cant use it to look for distortion in audio circuits
I think the other chip was made by Exar, XR2206, which is discontinued. That has a 1Mhz limit too i think. I cant remember the part number of the 25MHz device or who made it. I think the 8038 was made by Intersil, might be discontinued also.

7. ### crutschow Expert

Mar 14, 2008
13,469
3,356
If you run a triangular wave through an op amp integrator circuit you will get sine-wave with a few percent harmonic distortion, which may be good enough for non-critical requirements.

8. ### MrAl Distinguished Member

Jun 17, 2014
2,546
512

Hi Carl,

Are you sure? I think you have to also use a subtractor. For example, compare these two half cycle waves:
1. 12-t^2/2
2. 12*cos(t/pi)

for t from -5 seconds to +5 seconds. They look very much identical, except for a small difference.
The second is obviously a sinusoidal wave (with half cycle from about t=-5 to t=+5 seconds), and the first is the result of a time domain convolution of a ramp with an integrator, subtracted from a constant which is12 in this case (which can be normalized later), and looks very similar to the second expression evaluated over a half wave period.
Without the subtraction we'd get an upside down half wave which would have sharp points at both ends. We might do this with an offset for example.

Last edited: Nov 13, 2015
9. ### crutschow Expert

Mar 14, 2008
13,469
3,356
Don't know about the math but below is an LTspice simulation of an integrated triangle wave.
There is no significant 2nd harmonic and the 3rd harmonic is about -29dB below the fundamental according to the FFT function.
Reasonably sure that it's a reasonably good sinewave.

Last edited: Nov 13, 2015
10. ### DickCappels Moderator

Aug 21, 2008
2,746
665
Of course with an integrator the amplitude will change with frequency.

My favorite method is a slightly over-driven differential pair. It has low sensitivity to frequency and makes beautiful-looking sinewaves. Of course the base drive signal should be temperature compensated or AGC used.

The technique is outlined as a lab experiment at the URL below.
https://wiki.analog.com/university/courses/electronics/electronics-lab-12sg

11. ### MrAl Distinguished Member

Jun 17, 2014
2,546
512
Hi Carl,

Yes that looks pretty good and even without knowing the real harmonics it looks good. That circuit has an automatic subtraction built in i guess, because we are driving it in the inverting mode.
When someone says "Integrator" strictly speaking that means a non inverting integrator, but i realize the more casual definition would also include an inverting integrator, which is just fine.

Yes some amplitude variation but that might be met with some change in the triangle wave to correct.

I also today in fact ran into another old chip i used to use for analog multiplication, the CA3080 chip. This chip is also capable of generating a sine wave from a triangle due to it's variable gain capability. I've never done that but i have read that it can be done, so add yet another method to the pot

Apr 5, 2008
15,796
2,384
MrAl likes this.
13. ### crutschow Expert

Mar 14, 2008
13,469
3,356
The inversion has nothing to do with the integrator generating a sine-wave from a triangle-wave and there is no subtraction involved.
A non-inverting integrator would give the same output (shifted by 180 degrees of course).
Here's a simulation using a non-inverting integrator:

14. ### WBahn Moderator

Mar 31, 2012
18,079
4,917
Wouldn't that imply that if you since a sine-wave through a differentiator that you should get a triangle wave?

DickCappels likes this.
15. ### MrAl Distinguished Member

Jun 17, 2014
2,546
512
Hi again,

WBahn:
Wow that's a very good point. I hadnt thought about that aspect of it which might disprove that there is no subtraction.

Carl:
Well the math works out to something that requires a subtraction to get the sine, because when you integrate a ramp you get a second degree equation with only a constant and an x^2 term, which as i am sure you know if x is time 't' and we start at t=0, the wave will be exponentially increasing:
y=x^2

But if we simply subtract a constant from this, we get something that looks like a quarter of a sine wave, and if we shift it in time we get something that looks very much like a half of a sine wave:
y=K1-(x-K2)^2

I will take a more in depth look at this though and see if there is something that happens in the integrator that makes it work out the same even without a subtraction.

In the mean time, what is that second cap for on the non inverting terminal? That means we are getting a double integration which is not just an integration.
I think to get a pure non inverting integration we have to do something different. If we use a resistor and capacitor in series that's not a pure integration, that's more of a regular low pass filter filter.

Last edited: Nov 13, 2015
16. ### WBahn Moderator

Mar 31, 2012
18,079
4,917
The sim results are pretty convincing, so it's not a matter of disproving that it works, but rather of understanding why it does work.

My guess, purely off the top of my head, is that the circuit is acting not only as an integrator but as a low pass filter (which is inevitable since a true integrator IS a low pass filter) and that this is resulting in the filtering out of the higher order harmonics from the result.

17. ### DickCappels Moderator

Aug 21, 2008
2,746
665
Yes. Figure the harmonics are reduced much more than the fundamental the 3rd harmonic would be down by 9.5 db, the 5th harmonic wouuld down by 14 db, etc.

18. ### crutschow Expert

Mar 14, 2008
13,469
3,356
That circuit is a standard non-inverting op amp integrator circuit. It generates the first-order integrate function.
You can sort of look at it as the standard differential amp configuration expect that two of the resistors are replaced by capacitors.

19. ### MrAl Distinguished Member

Jun 17, 2014
2,546
512
Hello again,

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.
You can try this though to make sure i have it right, but the real reason appears to be because of the subtraction as previously thought. The subtraction comes in a very subtle form here however. In this case it is caused by the non sync of the triangle with the sine wave output. For a plus and mijnus 1v peak triangle, the triangle starts at -1v when the sine is at 0v, which indicates a huge phase shift looking at it in the frequency domain, and in the time domain it looks like a minus unit step. So the circuit, to analyze it correctly, requires the use of a ramp with a minus unit step, so it is not just a ramp it is minus unit step plus ramp. So in other words, the circuit is not integrating a triangle mathematically, it is integrating a triangle with a subtracted unit step at t=0. So that's where the subtraction comes from, and it shows up at the output as:
Vout=t-t^2/2
for the simplest values of R and C, and that clearly has an included subtraction although not with a constant this time. The wave above evaluated from t=0 to t=2 seconds looks very close to the positive half cycle of a sine wave.

Another way to look at it is that there is a built in offset that is always present. If we started the triangle at zero volts, i bet we'd have to wait for the offset to build up before we got a good clean sine wave (try it maybe). How long we have to wait would be dependent on the RC time constant.

As Wbahn pointed out, we should get a triangle wave if we differentiate the output, and guess what, the derivative of the above comes out to a ramp. That's because it's not a pure sine wave but really a second degree curve that is not allowed to progress any farther than the period of the input triangle will allow.

To digress slightly, an increasing ramp (or just one part of a triangle) can be represented very simply in the time domain as:
y=t

and if we simply integrate both sides we get:
integral(y,t)=integral(t, t)
and as most people know, the right hand side above comes out to t^2/2+K, where K is a constant that can be plus or minus, but apparently the constant is not always needed if we drive it with a triangle wave. With a triangle wave however the subtraction is still present, just in a different form.

I still have to accept Carl's suggestion that running a triangle through an integrator produces a near sine is a valid statement because we often look at an integrator as a physical device, even though the analysis is a little more complicated and strictly speaking, a *mathematical* integration of part of a triangle (or the whole triangle taking into account initial conditions) will result in an exponentially increasing (decreasing) second degree curve that is very pointy at the peaks.
Pure integrations appear all the time in control theory, and there it is not a physical equivalent. Here it should be taken as a complete physical circuit part of which integrates. If we had to reword it, i think it would be something like:
"We get a near sine wave if we run a triangle through an integrator circuit".

Last edited: Nov 13, 2015
20. ### crutschow Expert

Mar 14, 2008
13,469
3,356
Certainly the triangle wave has to have an average value of zero to properly generate the pseudo-sinewave from the integrator (which can be insured by capacitive coupling of the triangle wave to the integrator input).
If that's part of what you call a subtraction process, okay.

And, as might be expected, a simulation of running the integrator output though a differentiator recovers the triangle wave (see below), so obviously the output of the integrator is not a pure sinewave, since that would result in a phase-shifted sinewave.