square to sine converter

Started by Paul Perry (Frostwave), March 17, 2007, 09:15:10 AM

Previous topic - Next topic

Paul Perry (Frostwave)

http://oldtemecula.com/theremin/sixthvoice/index.htm
Yeah, square to sine, that's what he says.. a pretty big claim, even if it is only approximate.
If you try it, and it works, let us know!

albatross

Hi,

How would one go about adjusting this for stompbox purposes, as the input is at 6 volts

Would be interesting if placed after a Buzzy square wave distortion if it could be adapted.

slacker

#2
Should function the same if you just run it off 9volts. If you untangle the schematic it looks like the first half of the opamp provides a variable inverting boost, which is then fed into the second half which is a basic variable gain TS style diode clipper. If you feed in a square wave I think R2 and C3 integrate it into a triangle then the second opamp stage clips the triangle into a more sinewave like shape. Not sure what R6 and C5 are doing though.
Might make an interesting fuzz pedal if nothing else  ;D

R.G.

Could be, I guess.

But a cursory examination of that circuit seems to show that it's a two-stage affair. The first stage is a variable gain inverting opamp which feeds a 100K/0.22uF single pole lowpass filter. That filter has a 7.2Hz turnover point. The entire audio range then gets a -6db/octave lowpass filtering.

A real square wave has no second harmonic, but an imperfect square does. Whatever second harmonic that's there is attenuated by 6db. Third harmonic should be down about 9db, and so on. So the waveform goes get rounder.

Unless I'm missing something - which is always possible - the fundamental of the input signal is also attunated by the same slope. So signals an octave up are half the power with each octave.

I suspect this makes the buzzy output of a theremin sound much more like a sine. But theremins are monophonic.

The second stage looks very much like a MXR Distortion Plus - back to back diode clippers, 1M feedback resistor and 1K limiting resistor on the - input. Maybe this adds the character mentioned in the writeup, as well as restoring signals back to some semblance of a constant level. The only problem with that is that the lows are still clipped (and symmetrically) by the diodes.

It probably sounds much more sine-y than theremin, but I suspect that it's not a general square-to-sine converter in the sense we'd like it to be.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

DDD

There's a lot of square-to-sine converters in the world. There are some attempts to use such a devices for the guitar gadgets also. But there is no any success.
The reason is that all of the converters require strongly admissible voltage of the triangle wave on the input of their last stage. Otherwise their output wave won't be a sine wave.
Of course one can simply integrate the square wave twice (or more times) to have quite pure sine on the output, but the higher the frequency the lower voltage of the sine-wave will be.
In both cases it's necessary to use the AGC circuit with all of its problems.   
Too old to rock'n'roll, too young to die

gez

#5
A frequency-to-voltage converter hooked up to OTA integrators can (if done right) produce a reasonable sine wave with stable amplitude over a reasonable frequency range.  The sine isn't mathematically perfect/pure, but it's as good as and when you look at the result thru a scope it appears sinusoidal:  I've compared the waveform with that of the sine from my function generator (precision jobbie integrated into my scope) and you're splitting hairs with the differences.
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

R.G.

I do have a workable way to make a VERY close approximation to a pure sine from any rectangular wave of a single frequency.

First, you run whatever you have through a filter if needed, then a comparator to make sure you have a volts-big rectangular wave.

Then you run it into a PLL and phase lock multiply the frequency up, perhaps about 16x. From the 16X output, you run a shift-register with output resistances which convert the 16X rectangular into a sine approximation. With a 16X clock, all harmonics other than the sine are the 15th and the 17th, and they are 1/15 and 1/17th the amplitude of the fundamental. With the rirst harmonics at 15x the output frequency, you can filter them out pretty easily. More importantly, you have a 16X clock there to use - you might just be able to do a tracking filter which would adaptively produce a really big reduction in harmonics.

All that blather amounts to - it's a really good sine wave. And the output amplitude is completely constant.

The tough part in this approach is all tied up in that "rectangular wave of a single frequency"  because guitars don't do that all that well.

That issue can be cleaned up with some digital assist. A filter banking scheme where you have an array of half-octave bandpass filters. The fundamentals on a guitar are less than four octaves, so you only need 8. Detect output envelope on the eight filters, and use a CMOS priority encoder to gate off the outputs of all but the lowest frequency filter with output. That nails down the fundamental and removes a lot of the hash. This then could be cleaned up pretty well into a rectangle.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

DDD

gez,
a reasonable frequency range of a guitar is 80-1300 Hz approx., i.e. approx.16 times. So we expect of about 16 times difference of amplitude on the integrator output (if I'm right).  Also, it doesn't matter what do we use for the circuitry - simple RC chain or OTA or OA or other components. Integrator is just an integrator.
Maybe you're speaking of the SPECIAL integrators?
IMO there is no way to convert square wave to sine without detector. But detectors usually cause time delays that can affect the sound in the unwilling manner.
Too old to rock'n'roll, too young to die

gez

#8
Quote from: DDD on March 18, 2007, 10:10:08 AM
gez,
a reasonable frequency range of a guitar is 80-1300 Hz approx., i.e. approx.16 times. So we expect of about 16 times difference of amplitude on the integrator output (if I'm right).  Also, it doesn't matter what do we use for the circuitry - simple RC chain or OTA or OA or other components. Integrator is just an integrator.
Maybe you're speaking of the SPECIAL integrators?
IMO there is no way to convert square wave to sine without detector. But detectors usually cause time delays that can affect the sound in the unwilling manner.

OK, feed an integrator with a square and you get a triangle that diminishes in amplitude with increasing frequency.  But, if you use an OTA for the integrator and hook up its Iabc pin to the output of a frequency to voltage converter then amplitude is stable: higher frequency = higher control voltage = more current at OTA's output = triangle of larger amplitude.  Feed the triangle to a further OTA integrator, also wired up to the f-to-v converter, and it will shape the triangle into a waveform which is sinusoidal (think of the second integrator as being a filter).

All this assumes that the f-to-v converter is linear and that it has sufficient range: in practice, I've found you need to have a supply much larger than 9V to do this.  Also, the signal coming out of the second integrator, though stable, is  somewhat reduced in amplitude so a gain recovery stage is usually necessary.  It does work though.

By 'detector' you mean fundamental extractor?  Agreed, it helps, but there are methods (working on a circuit now) that don't necessarily cause (significant) delay.

(Edited umpteen times because the ****ing spell check changed 'f-to-v converter' to "foot's" and Iabc to ABC.  Aghhhh!
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

albatross

Hi,

Did anyone have the chance to test this yet?

Might try this on a breadboard sometime, sounds interesting.


PS: Thank you Slacker for the vero easyvibe layout! It works great!

slacker

Quote from: albatross on March 18, 2007, 02:30:59 PM
Hi,

Did anyone have the chance to test this yet?

Might try this on a breadboard sometime, sounds interesting.

It's on my long list of things to try, just to see what it sounds like as a Distortion pedal.

Quote
PS: Thank you Slacker for the vero easyvibe layout! It works great!

Thanks, glad it worked. That's a couple of people who've built it now so I'll add a remark to say it's verified.


brett

Hi
Although I've never used it at low frequencies, this might work.  I use the inverters in a CD4049UBE and a film 0.022uF cap.  The 0.022uF cap gives f about 1kHz.


Brett Robinson
Let a hundred flowers bloom, let a hundred schools of thought contend. (Mao Zedong)

markusw

QuoteFirst, you run whatever you have through a filter if needed, then a comparator to make sure you have a volts-big rectangular wave.

Then you run it into a PLL and phase lock multiply the frequency up, perhaps about 16x. From the 16X output, you run a shift-register with output resistances which convert the 16X rectangular into a sine approximation. With a 16X clock, all harmonics other than the sine are the 15th and the 17th, and they are 1/15 and 1/17th the amplitude of the fundamental. With the rirst harmonics at 15x the output frequency, you can filter them out pretty easily. More importantly, you have a 16X clock there to use - you might just be able to do a tracking filter which would adaptively produce a really big reduction in harmonics.

All that blather amounts to - it's a really good sine wave. And the output amplitude is completely constant.

The tough part in this approach is all tied up in that "rectangular wave of a single frequency"  because guitars don't do that all that well.

Maybe I'm wrong but IIRC the phase comparator 2 of a 4046 doesn't need a square wave to work. Any duty cycle should do. So one just had to lp filter a bit to ensure that the 2nd harmonics don't trigger the squarer. 

Markus