square wave to sinewave converter (link)

Started by Paul Perry (Frostwave), May 07, 2005, 02:46:36 AM

Previous topic - Next topic

Paul Perry (Frostwave)


gez

I hate it when schematics aren't shown!  :)

On the face of it it looks like a passive integrator followed by a diode clipper, the diodes rounding off the tips?  Would need to be regulated if that's the case.

Don't have the data sheet handy so might be wrong.
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

puretube

yep: preamp - gain= R1/P3;
lopass R2/C3;
diode-clipper - gain= 10-1000 (R7/R5+P2) rolloff set by C1;
not sure about C5 in parallell to R6...

note the mentioning: "sinewave with character"...

edit: just drew up the schem... R4&3+C2 create bias;
C1 looks strange, coz it goes to plus, but the effect is the same as
going to ground...

puretube

is there a stripboard layout available?  :lol:
(anybody got a pcb layout?)

gez

Quote from: puretubenote the mentioning: "sinewave with character"...

Translation: slightly sinusoidal over some of the range!  :)

Due to the integrator, there'll be a reduction in amplitude of the output signal over a large frequency range and it would probably 'triangulate' at the upper end of things. My best results at Square-to-sine conversion have been with double integration using OTAs (LM13700). First integrator shapes to a true triangle and the second does the sine shaping (need a largish cap to avoid 'triangulation'). The output of a frequency-to-voltage converter feeds the Iabc pins and keeps amplitude stable. I like to leave the second integrator's gain static so that you get a tapering in amplitude from low to hi frequencies, sounds more natural with a guitar.

Only down side to these things is it can be a nightmare stopping bleed-through from the square wave reaching the output. Even if you get a nice pure sinusoidal signal there can be annoying buzz in the background!  :cry:
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

puretube

as long as the (output) square noise isn`t a modulation-product,
you could try to add a little amount of inverted original square to the (sine-)output,
to "outphase" (cancel out) the background noise  :?:

gez

Quote from: puretubeas long as the (output) square noise isn`t a modulation-product,
you could try to add a little amount of inverted original square to the (sine-)output,
to "outphase" (cancel out) the background noise  :?:

The circuit has been on my breadboard for months and is (literally) gathering dust!  I'll have to resurrect it and see what I can do (probably just the layout, I'll have to investigate with the scope).
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

Paul Perry (Frostwave)

http://home.att.net/~theremin1/Circuit_Library/converter.htm
OK! maybe this is more like it!!
OK you still need to convert the triangle to a sine, but that is trivial,
compared to getting the square to a triangle!

R.G.

There's a pretty simple square wave to sine wave converter.

(a) Make the square wave into a logic wave - that is, 0V to a fixed high level. A comparator with a floating reference should do this nicely.
(b) Feed that to a CD4046 phase locked loop.
(c) Feed the 4046 output to a CD4024 binary divider and take the divided-down output to the frequency feedback input of the 4046. This makes the 4046 lock at the divider-times higher frequency than the input frequecy.
(d) Use the multiplied frequency out of the 4046 to drive a shift-register sine wave generator (See http://geofex.com/Article_Folders/LFOs/psuedorandom.htm under walking-ring counter LFO generators for how). An eight stage (i.e. single chip) counter should do nicely. The first error/distortion harmonic in the output of one of these is the seventh, and it's at 14%, the next is the ninth at 11%. These are fairly simple to filter out because they're so much higher than the base frequency.
(e) If you're using the output signal for audio, re-apply the envelope by using something like a compander ship to make the output signal follow the size of the input signal.

You can also get triangle and other waveforms out of the divider/walking ring setup by just tapping off various outputs in the divider. One interesting one is getting one, two, or more octaves up or down as a sine wave output by using different outputs of the 4024 divider (they are all locked, just at different binary multiples) as the feedback to the PLL or the output of the PLL to the walking ring counter. Do your homework carefully and you can get multiple-octave sine octaves *simultaneously*...

The Achilles heel of all square-to-sine converters based on integration is that you then have a linear output-to-frequency drop (i.e. the output goes down linearly with frequency) and it's much harder to recover just the right amount of signal level especially if you are not fixing the square wave signal level up front.

I've ... um... thought about this topic a fair amount in the past...
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.

Hal

OK so what would happen...

if you use square wave fuzz into that thing...

I think i need a scope.  Or I can just make the buzziest, most clipping fuzz I can and try it..

Greybeard

That what I was just wondering Hal................

Greybeard

gez

Quote from: R.G.(d) Use the multiplied frequency out of the 4046 to drive a shift-register sine wave generator (See http://geofex.com/Article_Folders/LFOs/psuedorandom.htm under walking-ring counter LFO generators for how). An eight stage (i.e. single chip) counter should do nicely. The first error/distortion harmonic in the output of one of these is the seventh, and it's at 14%, the next is the ninth at 11%. These are fairly simple to filter out because they're so much higher than the base frequency.

I thought you might crop up with this one RG!  :) I tinkered around with this idea a little after the last time you mentioned it and I have questions!!  

I used a 4017 chip to get a stepped sine, as described in Owen Bishop's 'Practical Electronic Design Data'.  You end up with a 10 step wave.  He uses the outputs of the 4017 to trigger switches (4046?) which select voltages (set by trimpots across the rails) to be presented to the output.  To save board space I just draped a resistor in series with a diode off each output, joined all the cathodes then ran them to a common resistor to ground.  Works perfectly and you get a nice stepped wave form but I had problems getting it to look anything like a nice smooth sine wave.

A simple cap across the output, as he suggested, didn't do the trick and the waveform still had that 'Frankensine' look to it.  Increasing the value of the cap did smooth things out but resulted in distortion of the waveform and reduction in amplitude with increasing freqency.  I toyed with the idea of going for an active filter, but what looked nice and simple on paper was ending up having quite a high component count, so I switched to the method outlined in my previous post.

So, assuming an active filter is needed, does the waveform still have a stilted look to it, but sounds good enough for practical purposes, or do you end up with a reasonably good sine? Also, is there some reduction in amplitude as freqency increases?
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

gez

Quote from: HalOK so what would happen...

if you use square wave fuzz into that thing...


A comparitor type fuzz is what's needed.  You end up with a very dull (boring?) sounding sine wave.  Turn down the tone control on your guitar till it's all the way off and you'll get a rough idea of just how non-descript it'll sound!  :P Sometimes a little distortion isn't a bad thing...

A totally pure sine isn't so bad when blended in octave circuits though (at least it's clean).
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

puretube

one could make a nice graphic waveform synthesizer with such counters and a set of (trim-) pots...  :wink:

gez

Quote from: puretubeone could make a nice graphic waveform synthesizer with such counters and a set of (trim-) pots...  :wink:

The thought had occured to me!  :lol:
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

puretube

I think it was a 7442 or 74141 that did the "SeekWave" ( :wink: ) for me some 20 years ago... (it was a V*RO-layout btw....) maybe I can still find that thingy in the basement...

(of course "Elektor" had s.th. like that too, at the time  :shock: )

R.G.

QuoteWorks perfectly and you get a nice stepped wave form but I had problems getting it to look anything like a nice smooth sine wave.
Two thoughts - (1) did you *listen* to it?  (2) sine waves, as noted above, are kinda boring to listen to.

QuoteSo, assuming an active filter is needed, does the waveform still have a stilted look to it, but sounds good enough for practical purposes, or do you end up with a reasonably good sine? Also, is there some reduction in amplitude as freqency increases?

Here's the trick. Audio is so wide range in frequency that a simple filter that will remove harmonics at low frequencies will also lower amplitude as the frequency goes up. You need some kind of frequency agile filter. This can be either an analog tracking filter or some kind of stepped filter.

Stepped filters are easiest. Generate a voltage proportional to the input frequency; this is simplest with a one-shot fired by the edge of the wave. An LM2917 is just about perfect for this. From that, run an LM3914 dot/bar display chip to give you one-of-ten outputs. Use the output to select filter frequencies.

Analog tracking is best done with switched capacitors along the lines of the MXR envelope filter. In fact, the MXR filter is an OK thing to use here, conceptually.

Finally - again, did you listen to it? It may not need all that much filtering. Besides, you can freely add in some second and fourth harmonics for more character, or generate a triangle wave to start with.
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.

Hal

Quote from: gez
Quote from: HalOK so what would happen...

if you use square wave fuzz into that thing...


A comparitor type fuzz is what's needed.  You end up with a very dull (boring?) sounding sine wave.  Turn down the tone control on your guitar till it's all the way off and you'll get a rough idea of just how non-descript it'll sound!  :P Sometimes a little distortion isn't a bad thing...

A totally pure sine isn't so bad when blended in octave circuits though (at least it's clean).

its the first electric guitar flute sim pedal :-D

gez

Quote from: R.G.Stepped filters are easiest. Generate a voltage proportional to the input frequency; this is simplest with a one-shot fired by the edge of the wave. An LM2917 is just about perfect for this. From that, run an LM3914 dot/bar display chip to give you one-of-ten outputs. Use the output to select filter frequencies.

Interesting, thanks for that RG.  I might have to revisit this in the near future.

QuoteFinally - again, did you listen to it?

Probably not, and if you saw the looks I get from my partner after she's had to endure a whole afternoon of blips squeaks buzzing and ripe language from yours truly when things don't go according to plan, you'd probably just stick to the scope too!  :P  

Point taken though,  and lesson learnt!  :oops:
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

Paul Perry (Frostwave)

RG is of course right, use a phase locked loop, but once you commit to a PLL, you might as well replace the VCO in the PLL with one that actually gives a sine anyway. (this isn't an original concept.)
As for the ragginess of that digitally generated sine, you can't hear the steps by ear. Where you DO have problems with steppy sines, is using them as LFOs!