[sdiy] square to sine
rburnett at richieburnett.co.uk
rburnett at richieburnett.co.uk
Tue Oct 9 14:06:10 CEST 2012
> I'm looking for a good way to convert square to sine. I need
> low-cost,
> stable, low-distortion sine wave generators with excellent 1V/octave
> tracking over the entire audio range.
It's a shame you can't do it the other way around and generate the
square wave from the sine. It's much easier ;-)
> I've read the app note for the UAF42 which suggests using a tuned
> state
> variable bandpass filter of moderate Q, but the distortion of this is
> a
> little high for what I want to do (about 1.5% THD). I'm hoping to
> get the
> THD to less than 0.5%.
That's one way to do it. In order to convert square to sine you only
need to filter out the harmonics so you can use an agressive low-pass
filter. Provided the square wave has exactly 0.5 duty ratio there'll be
no 2nd harmonic, so you have all of the space between the fundamental
and the 3rd harmonic for the transition band of your lowpass filter.
That will determine the order of filter required to hit your THD
specification. You can cheat a little bit by peaking the lowpass filter
response around the cutoff frequency in order to boost the wanted
fundamental frequency of the square wave. This will improve the THD
figure for the same overall filter order. However, the more resonance
you add the more critical the tracking will become between the
square-wave oscillator and the resonant low-pass filter. With lots of
resonance any mis-tracking of the filter will cause significant
amplitude and phase variations in the sinewave output. Such variations
may or may not be a problem in your application.
> I'm not totally averse to digital solutions either, but I'd prefer
> analog.
Direct Digital Synthesis using one of analogue devices' cheap DDS chips
is a simple elegant solution to generating frequency-agile sinewaves in
a digital system. If you're not familiar with these, they basically
contain a numerically controlled oscillator (NCO) and play out a
sinewave stored inside the chip (in a lookup-table) at a rate you
specify digitally. You can program the frequency and phase to fractions
of Hz and fractions of degrees accuracy and make them change to a new
frequency instantaneously on command. AD9834 is a device i've used
recently if you want to browse a datasheet.
> One method I'm thinking of is a voltage-controlled clock with divider
> and
> switched capacitor filter. Has anybody tried this?
If you've got access to a clock that is at a multiple of the final
desired output frequency then this gives you more options. For example
you could synthesise a very approximate stepped-sinewave shape
containing maybe 3 or 4 levels and then filter this to get your pure
sinewave. Even a really ragged stepped sinewave or triangle
approximation will have less harmonics than a square wave! Anything you
can do to make the job of the filter easier will result in better
sinewave purity. This is particularly so if you can arrive at a
waveform that at least forces some of the low-order harmonics down in
amplitude. Eg. The 3rd and 5th harmonics of a squarewave are large in
amplitude and not that far away in frequency from the fundamental so
demand a high oreder filter to suppress them sufficiently. A stepped
sinewave approximation can be made that has little or no energy at these
frequencies making filtering in this region much easier.
You can also use the high-frequency clock to clock your
switched-capacitor filter which would improve the tracking accuracy
between the waveform generator and the filter.
You could also look at using a Cauer (elliptic) filter. It's sharp
transition-band and zeros in the stop-band could be just what's required
to squash those low-order harmonics.
I hope these ideas help,
-Richie,
More information about the Synth-diy
mailing list