Square + triangle = sine (almost)

To generate a square wave and triangle wave together, just hook a Schmitt trigger to an op amp configured as integrator (resistor from input to (-) node, feedback capacitor from op amp output to (-) node. The output of the op amp then is fed to the Schmitt trigger (a '555 does this without the op amp, but its triangle waves are curvey because of that).

The result is a square wave and a triangle wave, both of constant amplitude, which changes frequency with a single variable resistor (the integrator input resistor).

SO, now you want to mix a square and triangle? If you generate them by the method above, fundamentals ARE OUT OF PHASE by ninety degrees, and so are all of the harmonics. You get neither cancellation nor reinforcement by any simple summing.

Reply to
whit3rd
Loading thread data ...

Sure enough, as does the ICL8038. Part of the question is how it is = done.

Reply to
JosephKK

The datasheet at

formatting link
has a pretty good schematic and explanation which shows how it's done.

--
Muzaffer Kal

DSPIA INC.
ASIC/FPGA Design Services

http://www.dspia.com
Reply to
Muzaffer Kal

You can use diode gates to divert a current source and sink into the cap, driving the gate with the output pin (since pin 7 doesn't source current). Then you also get freely adjustable frequency and duty cycle, like a proper function generator. Add a buffer and you've got a hearty triangle output!

Tim

--
Deep Friar: a very philosophical monk.
Website: http://webpages.charter.net/dawill/tmoranwms
Reply to
Tim Williams

Phil Allison schrieb:

In Gemany, the angle is 56.789 degrees, because the mains voltage is higher...

Frank

Reply to
=?ISO-8859-15?Q?Frank-Stefan_M

"Frank-Stefan Müller"

** Das Fuhrer has spoken....

..... Phil

Reply to
Phil Allison

If you use a quad comparator, you can do some interesting stuff. With just 2 more comparators, you can make this:

------ ------

--- --- --- --- ------

It will be in phase with the triangle wave. It can be made to have no

3rd harmonic fairly easily. By trading off the 3rd you can have a reduced 5th.

It is too early in the morning for me to be sure, but I think that if you fiddle it just right and add in some of the triangle wave, you can get low values for both the 3rd and 5th.

It also seems to me that there should be a way to make a very nonlinear PWMing action that when low pass filtered leaves a moderately good estimate of a sine wave. This could allow you to hold the sine wave shape over perhaps a couple of decades.

Reply to
MooseFET

Yep. "Piecewise-Linear", aka break-point analysis... taught in better engineering schools ;-) ...Jim Thompson

--
| James E.Thompson, CTO                            |    mens     |
| Analog Innovations, Inc.                         |     et      |
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    |
| Phoenix, Arizona  85048    Skype: Contacts Only  |             |
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  |
| E-mail Icon at http://www.analog-innovations.com |    1962     |
             
      The only thing bipartisan in this country is hypocrisy
Reply to
Jim Thompson

I recollect something from Don Lancaster about Magic Sinewaves and how you can get arbitrarily low harmonics from certain optimal patterns of on and off, given sufficiently accurate timing, and I suppose some sort of filtering. I never did figure out if it's supposed to be a tristate waveform (as above) or PWM (on/off for varying rates) or multivalued (minimal bit DAC?) or what.

formatting link

Ugh. Why does Don. Always have to write. Fragmented sentences.

Looks like it's a PWM tristate thing (requiring an always-on H bridge), but not really PWM as the edge timings are arbitrary through the cycle. Rather than microcomputer friendly as claimed in the introduction, I expect such a generator would be easier to synthesize in an FPGA, since microcontrollers don't offer timers with lots and lots of counter compare units, and general microcomputers have awful timing (at best, you'll get single cycle accuracy in a single-cycle-instruction microcontroller with no possible interrupt service).

Tim

--
Deep Friar: a very philosophical monk.
Website: http://webpages.charter.net/dawill/tmoranwms
Reply to
Tim Williams

I have played around with the XR2206 before. It appears to me that the square and triangle have a derivative/integral relationship to each other. I seem to think that the triangle is generated current source switching polarity periodically, such that the current waveform is a squarewave, alternately charging and discharging a capacitor.

And it appears to me that the sine wave is derived by feeding the triangle wave through a resistor in series with an inverse-paralleled pair of diodes or something having similar effect. The sinewave is found across the antiparallel pair of diodes (or similar circuitry). This results in the tips of the triangle wave being "squashed" to obtain an approximation of a sinewave. The peaks of the resulting sinewave are not perfectly rounded, but show a trace of the pointy tips of the triangle wave.

The XR2206 has provisions to adjust the symmetry and the degree of squashing of the sine-to-triangle conversion. When my hearing is in a good mood, I can adjust the symmetry to minimize even harmonics, and the degree of squashing to get the 3rd and 5th harmonic low. (The 3rd and 5th cannot be both reduced to zero simultaneously in my experience). Traces of odd harmonics higher than the 5th will remain since the peaks of the sinewave cannot be perfectly smoothed by the triangle-to-sine conversion circuitry in the XR2206.

- Don Klipstein ( snipped-for-privacy@misty.com)

Reply to
Don Klipstein

ut

The 'magic sinewaves' approach is a variant on the digital filter theme, using calculated ON/OFF pulses to cancel two or three of the harmonics... but that only buys you a small reprieve from the problem, a low-pass filter to take out the higher harmonics is assumed. Alas, that kills the adjustable- frequency range, unless you make a (expensive) tracking filter.

The linear solution of making an accurate triangle wave, then distorting, might get from 5% distortion (which is what a triangle wave is, compared to a sine) down to 1% or less, is terribly limited, too. There's a theorem (the Wiener-Hopf theorem) that says your fit functions work best if they have the same autocorrelation as the thing they fit to... which means a smooth diode response curve is not going to reduce a step-like square wave to sinusoid in a small number of stages, EVER.

But, all these 'one percent' solutions don't kill the high harmonics down to the level of a true sinewave oscillator. My old HP 204C was worst-case 0.1% ( - 60 dB) on its distortion right out of the box; compared to the triangle-wave and breakpoint-diodes of an XR2206 at 2.5% before hand-tweaking.

Reply to
whit3rd

I also think it is more a tanh shaping. I used the transistor shaping network for a VCO some years ago and it worked nice, if you do not expect an extremely low distortion rating. A problem is that the output amplitude (before the opamp) is rather small and so there can be noise problems.

Reply to
Darwin

In , whit3rd wrote in part:

A triangle wave has 12.1% distortion. The 3rd harmonic alone has voltage of 11.1% of that of the fundamental.

- Don Klipstein ( snipped-for-privacy@misty.com)

Reply to
Don Klipstein

You can do a pretty good job with an LM13700 producing the tanh shape, and then subtracting off a small amount of the original triangle wave to get rid of the cusps at the peaks.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal
ElectroOptical Innovations
55 Orchard Rd
Briarcliff Manor NY 10510
845-480-2058
hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs

The transfer characteristics of a BIPOLAR diff pair IS a TANH function.

The tricky part is containing the signal within the temperature-dependent operating range. ...Jim Thompson

--
| James E.Thompson, CTO                            |    mens     |
| Analog Innovations, Inc.                         |     et      |
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    |
| Phoenix, Arizona  85048    Skype: Contacts Only  |             |
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  |
| E-mail Icon at http://www.analog-innovations.com |    1962     |
             
      The only thing bipartisan in this country is hypocrisy
Reply to
Jim Thompson

Yup, but since you don't go all the way out to infinity, it never quite flattens out--hence the cusp that has to be subtracted out. Almost all the high harmonics are concentrated in that cusp, so getting rid of it makes a big difference.

Or else generate the triangle wave using another diff pair as the Schmitt trigger--also easy to do with the LM13700. That way the total amplitude is temperature dependent but the distortion tracks, so the THD should be pretty nearly temperature-independent.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal
ElectroOptical Innovations
55 Orchard Rd
Briarcliff Manor NY 10510
845-480-2058
hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs

Sure, but you could do it adaptively, using higher order magic sines for lower frequencies. I don't know how much computation or memory that would require. Sufficiently low frequencies could be driven by PWM instead (basically DDS with PWM or d-s output). So instead of an expensive tracking filter, you write a (potentially expensive) sinewave generator.

Practical considerations can change things of course... driving a motor, it's not really going to matter much, as winding inductance will filter harmonics, at some expense to efficiency; at low frequencies, the drive will be rather coggy and the harmonics will be lossy, but the power output is small, too (think VFD), so efficiency doesn't matter as much. On the other hand, driving something like a voice coil shaker table, you *must* have harmonics above a fixed frequency, or else they'll screw up your test results.

Tim

--
Deep Friar: a very philosophical monk.
Website: http://webpages.charter.net/dawill/tmoranwms
Reply to
Tim Williams

Oh, I just use brute force instead of adapting; my iPod has a complement of sinewaves, both pure and swept, ready for any occasion.

Reply to
whit3rd

h
u

The waveform I drew can be made by simply adding two pulse trains with different duty cycles. The fact that 3 time 60 degrees is 180 degrees is how you can get the 3rd harmonic to go away.

If you use more steps, you can get the first N harmonics to drop to zero. The same is true for line segments instead of steps.

(time for dinner)

ut

ther

a
s

al

cy

Reply to
MooseFET

Err... did I miss something? I've squinted at the referenced paper, but what you want to convert a triangle wave to a sine is sine, not hyperbolic tangent... the tricky part is that it's not the right function and ALSO that it's temperature-dependent.

The only 'pure' way to convert to a sine is to filter somehow. Motor/flywheel/generator is a pretty good filter... and it keeps any frequency of sine pure after it comes up to speed. Alas, there's no non-moving-part flywheel equivalent (high Q at a large range of frequencies).

Reply to
whit3rd

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.