square to sine wave blending?

Started by corbs, May 27, 2005, 04:43:53 AM

Previous topic - Next topic

corbs

i'm currently (slowly) getting through all the info peeps thanks

i've also found this (pdf) quite useful.

edit: hmm 2-5 hz seems to be the slowest occilating speed - is there any way of making it slower?

Paul Perry (Frostwave)

[quote="gezThat's not quite what I meant Paul, I was overdriving the OTA with the chip run off a fixed supply voltage, but for some reason it just goes straight into hard clipping when the chip is run at voltages lower than those specified in schematics, i.e. 9V or less.  For this reason I then started starving the amp to reduce gain in an attempt to get softer clipping...didn't work. :?[/quote]

You might need to change the bias resistor feeding the OTA.

ExpAnonColin

Quote from: gez
Quote from: ExpAnonColinThere is simply no good, small, and reliable way to turn sine to square.

I'd say Paul's way is pretty simple, just doesn't seem to work at voltages lower than those shown in schematics.
I meant square to sine.... my mistake.  EDIT!

-Colin

gez

Quote from: Paul Perry (Frostwave)You might need to change the bias resistor feeding the OTA.

That's what I meant by 'starving' the amp Paul, I ended up using resistors in the meg range to the Iabc pin but still got harsh clipping!
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

Paul Perry (Frostwave)

Well if you got harsh clipping, then you must have WAAAAAAAAAAAAAAAY too much signal going in, remember it expects to see only a few millivolts at the input! must be some problem somewhere.

gez

Quote from: Paul Perry (Frostwave)Well if you got harsh clipping, then you must have WAAAAAAAAAAAAAAAY too much signal going in, remember it expects to see only a few millivolts at the input! must be some problem somewhere.

I used a divider at the input of the OTA to keep the signal small, plus a trimpot so that I could gradually increase gain to push the amp into overdrive.  The output approaches the rails and when you nudge the trimpot to push it into clipping there's no gradual curving (like you get with inverters), the tops of the triangle get spliced clean off.

I tried this about a year or so ago Paul (you might remember as I asked for your help then) and I also tried it again recently, just can't get it to work at lower voltages than those specified on schematics, i.e from a 9V supply.

Don't worry about it though, there's more than one way to skin a cat!  :)
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

David

Quote from: ExpAnonColinSo how do you take a square wave and turn it back into a sine wave?  Well, take out the harmonics of course!  Since all of the harmonics are higher in frequency than the fundamental frequency, all we need is a lowpass filter, right?  Well yeah, a lowpass filter that will filter out every single frequency higher than the fundamental, without loweing the fundamental in amplitude at all.  Gee, that's an easy one! ;)
-Colin

Colin, I've seen examples of using a resistor ladder to smooth a square wave into an approximation of a sine wave.  Why might that not work?  Also, wouldn't it work to put a gain recovery stage after your filter if you're concerned about amplitude loss?

Not trying to be a smart*** here, I'm wrestling with this question myself for something I'm considering doing with a PIC.

Also, N.B. - R.G. has indicated that a CD4046 can be used in the wave-shape conversion, but I'll be jiggered if I can figure out how (yet)!  I may have to wait and PIC this up later (pun DEFINITELY intended!).  I've only got 2 to 6 weeks of wifely rehab to get my electronic projects for the year done!  AAAHHHH!  When she comes back she'll be able to see my shop!  Oh, no!  I'll be dog meat! Especially when she sees all the test equipment and components I bought while she wasn't around to stop me!  :twisted:  :twisted:  :twisted:  :twisted:  :twisted:

puretube

she`ll be glad, not having to have heard your shop...  :lol:

David

Quote from: puretubeshe`ll be glad, not having to have heard your shop...  :lol:

You know, Puretube, you're right.  I SHOULD build  that Ruby...  now...  while there's time!  :mrgreen:

Paul Perry (Frostwave)

Quote from: DavidColin, I've seen examples of using a resistor ladder to smooth a square wave into an approximation of a sine wave.  Why might that not work?  

You might be thinking of something along these lines?
http://www.tinaja.com/magsn01.asp
OK I worship the ground Don Lancaster walks on, but it is hard to forgive that filter pun "from the cheby to the leby".

David

Quote from: Paul Perry (Frostwave)
Quote from: DavidColin, I've seen examples of using a resistor ladder to smooth a square wave into an approximation of a sine wave.  Why might that not work?  

You might be thinking of something along these lines?
http://www.tinaja.com/magsn01.asp
OK I worship the ground Don Lancaster walks on, but it is hard to forgive that filter pun "from the cheby to the leby".

No, it was definitely done with discrete components.  I'll dig it up and post the link if you'd like.  I don't think I'm ready to mess with the stuff in your link, though.  Any idea how a 4046 might fit into this picture?

Paul Perry (Frostwave)

A very overkill way would be to use the 4046 to control an oscillator running at 100 times the frequency of the input square wave (phase lock loop) and then use a switched capacitor filter like the National MF series as a 4th order lowpass to filter the input square wave, & then keep the fundamental, which will be "sine enough for rock & roll".
Ratehr a sledghammer to crack a wallnut tho..
And, you have the usual problems of delay in locking in & following the input.. phoey :roll:

corbs

If i wanted something simpler (can't get my head round the theory :( ) to just produce a flashing (not square - but a sine wave) led that you could change the depth of the sweep and it's speed - what sort of IC's would i be looking at?

David

corbs, I might owe you an apology.  First, I didn't set out to hijack your thread.  I thought this thread concerned transforming a square wave into a sine wave.  This is something I'm interested in because I'm researching a way to emulate the old top-octave generator chip using a PIC.  Some of the research I've done seems to indicate that the PIC will produce the audio in square waves.  I'd also like to have the option of getting something that resembles a sine wave so I can get a tone that's more like organ pedals.  I've been running down everything I could find about transforming square to sine waves.

It looks to me (and please forgive me if I'm wrong) like this thread is actually about square or sine wave LFOs.

gez

The traditional dual op-amp LFO is an example of square shaping as the integrator converts it into a triangle.  This would be (is) the basis of any further (sine) shaping I would do.

You can use diode/resistor networks to shape a sine from a triangle, but the supply needs to be regulated to avoid the whole thing going pear-shaped if your battery flattens (assuming you're using one).  I've used this approach and it's ok.  

Other approaches include secondary integration (active, passive is crap).  If you make the cap in an integrator big enough it will shape a triangle into a sine.  You get a linear decrease in amplitude with increase of frequency, but if you're canny this problem can be overcome.  :wink:

PS  Check out the current consumption of function generator chips, then decide if you want to use them in a stompbox!
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

puretube

gez, now that you said it:
isn`t a state variable filter (turned into self-oscillation) exactly an
oscillator, that has square, tri-, and sinewave at its
hipass, bandpass, and lopass outputs   :?:  :idea:  :shock:

(now slow it down for LFO purposes...)

gez

Quote from: puretubegez, now that you said it:
isn`t a state variable filter (turned into self-oscillation) exactly an
oscillator, that has square, tri-, and sinewave at its
hipass, bandpass, and lopass outputs   :?:  :idea:  :shock:

(now slow it down for LFO purposes...)

I usually do this without 'closing the loop', so to speak. If you use half a LM13700 with half a dual op-amp for your triangle you can then use the other half of the op-amp as your integrator. If you replace this integrator's input resistor with the other half of the LM13700 acting as a variable resistance you end up with a reasonably simple sine generator. Although there's a linear decrease in amplitude with frequency, there's a linear decrease in 'resistance' from the second (matched) OTA in the LM13700 so amplitude is kept stable (both OTAs are controlled by the same pot & stop resistor).

For some reason 'stand-alone' OTA integrators don't do the sine shaping so well. If you keep increasing the cap size the sine shaping eventually starts to kick in, but amplitude is too small to make it usable. As is, you need to amplify the resultant sine wave from the circuit outlined above (The circuit I use kicks out a 1V peak-to-peak signal from a 9V supply), but that's no big deal as you need a mixer for the other waveforms anyway.

Not a 'tweak friendly' circuit, but, once set up, it does a really good sine wave and is reasonably simple.
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

gez

Quote from: corbsIf i wanted something simpler (can't get my head round the theory :( ) to just produce a flashing (not square - but a sine wave) led that you could change the depth of the sweep and it's speed - what sort of IC's would i be looking at?

If you want simple then something similar to the circuit I posted will do the trick.  Either that or look at the EA trem oscillator.  Both circuits suffer from a non-linear 'feel' to the rate pot (speed bunches up at one end).
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

corbs

Quote from: gezIf you want simple then something similar to the circuit I posted will do the trick.  Either that or look at the EA trem oscillator.  Both circuits suffer from a non-linear 'feel' to the rate pot (speed bunches up at one end).

coolies - gonna give it a go. btw do you think a LM339N would be an ok substitute? - i'm gonna have two together :). btw if the speed bunches up at one end - would a log pot be better?

David: don't worry about it  - i'm glad it got people discussing :)

puretube