1
\$\begingroup\$

I have square waves of different frequencies (1KHz to 20KHz), and I need to convert them to a sine wave of the corresponding fundamental frequency.

A RC ladder Low-pass filter was the first thing which I tried, It gave good results but the output peak-to-peak voltage (Vpp) varied a lot with the frequency. The square wave has a Vpp of 3.6V. But after filtering, the output Vpp of the sine wave varies from 3V to 2V as the frequency increases.

Is there any other better way to get a pure sine wave from square wave of same frequency without this voltage drop?

Thank you

\$\endgroup\$
3
  • 7
    \$\begingroup\$ Before you continue "trying things" maybe you could spend some time "understanding things" first. What does the frequency spectrum of a square wave look like ? How does it differ from a frequency spectrum of a sine wave ? You assume that it is possible to get a good sinewave form a 1kHz - 20 kHz squarewave using only a simple filter. Is that theoretically even possible ? And why is it or is it not ? \$\endgroup\$ Mar 15, 2016 at 9:59
  • \$\begingroup\$ Is the input amplitude fixed, or if not, do you need an amplitude match as well ? \$\endgroup\$
    – MSalters
    Mar 15, 2016 at 11:54
  • 2
    \$\begingroup\$ What you really should be doing is explaining more about what you are trying to achieve. For example, you seem to complain that the filter responds differently with changes in frequency, but your question only states the (nominal?) frequency. Why is the frequency changing? By how much? What is the actual meaning of these signals anyway? You can't pick the best solution until you are clear about the circumstances and goals. \$\endgroup\$ Mar 15, 2016 at 13:45

7 Answers 7

11
\$\begingroup\$

Is there any other better way to get a pure sine wave from square wave without this voltage drop?

Take your square wave and use a phase lock loop to generate a frequency that is maybe 50 times higher: -

enter image description here

Then use a clock tunable filter like this: -

enter image description here

Feed your square wave at the input (Vin) and you should get a pretty decent looking sinewave at the output.

It works by tracking the input frequency using the PLL - typically at an input frequency of 20 kHz the PLL output is 1 MHz and this is used by the LTC1066 to set its cut-off frequency to 20 kHz. Here's what LT say the frequency response looks like at the extremes of operation: -

enter image description here

Given that a square wave is composed of odd harmonics you need a steep filter that gives many dB attenuation at the most dominant harmonic (3rd). Look at the graph for 800 Hz low pass operation. At 800 Hz the response is approximately 0 dB and at 2.4 kHz (3rd harmonic) the attenuation id greater than 80 dB (10,000:1).

\$\endgroup\$
3
  • \$\begingroup\$ Thanks for the answer @Andy aka. But will I get the same output frequency as that of the input square wave from your method? Maybe I will rephrase my question. \$\endgroup\$
    – Injitea
    Mar 15, 2016 at 10:25
  • \$\begingroup\$ Yes you'll get exactly the same output frequency. \$\endgroup\$
    – Andy aka
    Mar 15, 2016 at 10:28
  • 1
    \$\begingroup\$ Yes, though a PLL with a range of 20:1 is non-trivial to build. A practical implementation might well involve a micro controller, at which point you might as well synthesize the sine wave there using a lookup table indexed by the high order bits of a longer phase accumulator. \$\endgroup\$ May 29, 2016 at 2:27
5
\$\begingroup\$

One simple way to approximate a sine : integrate to a triangle wave, and "soft clip" that. You'll find lots of circuits for "triangle to sine wave conversion" via the obvious technique.

Result isn't perfect but distortion can be under 1%.

Here are a few including this elegant JFET circuit. enter image description here

One difficulty with this approach, if you are varying the input frequency, is that the integrator's gain varies inversely with frequency, while all of these triangle-sine converters require a constant input amplitude.

One possible solution is a variable gain amplifier after the integrator, or possibly even variable gain built into the integrator itself (e.g. using a VCA such as the LM13700) varying the gain such that the output amplitude is constant.

\$\endgroup\$
3
  • \$\begingroup\$ Adding the triangle wave step in doesn't really help, If you are going to put a VGA after the integrator you could have just put a VGA after the OPs filter. \$\endgroup\$ May 29, 2016 at 1:59
  • \$\begingroup\$ @PeterGreen Of course it helps : soft clipping a square wave leaves you with a square wave. Alternatively, if you're suggesting a filter to eliminate the harmonics and generate a sinewave, you now have to tune the filter. \$\endgroup\$
    – user16324
    May 29, 2016 at 10:01
  • \$\begingroup\$ @BrianDrummond can you explain to me how the biasing works in this circuit? the signal seems to be it's own drive in that a divided version of the signal is fed to the gate to control the un-divided signal at the drain, why does this work? and the diodes, positive and negative 1-diode drop above the + and - ? if so why is this needed in a JFET circuit? and how does this fit in with the gate bias? is the gate bias just for current biasing? v-confused lol \$\endgroup\$ Feb 20, 2019 at 8:27
2
\$\begingroup\$

Consider a sine wave VCO and a phase-locked loop. You can use a CD4046 for the phase detector. Here, conceptually anyway, is a voltage-controlled oscillator that may be suitable with minor modifications: enter image description here

\$\endgroup\$
0
\$\begingroup\$

You can't do this with a linear time-invariant filter. Such a filter doesn't know the difference between a harmonic and a fundamental, it just sees a frequency component at a given frequency.

To determine an acceptable soloution to this proeblem requires answers to two key questions.

  • How pure does the output waveform need to be?
  • What needs to happen when the input frequency changes? How much transisition period is acceptable? What outputs are acceptable during the trasnsition period?

One approach not yet mentioned would be to use a filter followed by an automatic gain control circuit. So as the voltage drops the AGC boosts it back up. For greater spectral purity (but at the cost of slower response times) a second filter and AGC could be added.

I would expect all analog approaches to have settling times of at least several and likely many cycles after an input frequency change. If that is not acceptable I would look to a digital approach where a FPGA (with a fast master clock) measures the input cycle period and uses those measurements to generate a waveform that is fed to a DAC.

\$\endgroup\$
0
\$\begingroup\$

Not sure of the circuit you are using, but is sounds like a joule thief to me. Those things change frequency with load in about the ranges you are talking about. To build something cheap that works, go get a 100 ohm (?) watt adjustable choke. connect one end of the choke to one side of the output and the other end to your load. Now wrap the other output wire in the same direction as the choke (x) times. This will create a simple, manually adjustable filter. If you are going to use this with a particular load, just tune it until it works the best with a light bulb of equal wattage. Tuning could require more wraps around the choke. I would start with about 10. If you have a variable capacitor, you can delete the wrapping of the choke. You could even make your own choke with small enameled iron wire and wrap it around a bolt in a few layers. Then just add a wire wound type resistor in series to bring total resistance to around 100 ohms. Again, this is certainly not a perfect solution, but would give fair results, it is inexpensive, and adjustable.

\$\endgroup\$
2
  • \$\begingroup\$ Which part of your answer answers the square wave to sine wave conversion part? \$\endgroup\$
    – User323693
    Jan 27, 2017 at 14:37
  • \$\begingroup\$ It is an adjustable, low budget RC filter with minimal loss. \$\endgroup\$ Jan 27, 2017 at 14:42
-1
\$\begingroup\$

I would say that both PLL and triangle wave converstion are maybe just a bit of overkill. Try using active low pass RC filters (that is OP AMP with some C in feedback) to cut off the first harmonics (one for 2kHz and one for 40 kHz). They should ensure that your original frequencies are not attenuated (Gain=1).

\$\endgroup\$
1
  • \$\begingroup\$ That will not support a continuous range of frequencies - the lower frequencies of the range have several odd harmonics which need to be rejected that fall below the highest fundamental frequency the system needs to pass. So filters would only work if automatically tuned based on a frequency measurement. \$\endgroup\$ May 29, 2016 at 2:30
-3
\$\begingroup\$

I need to convert them to a sine wave of the corresponding fundamental frequency.

Sine wave of some frequency have zero constant "harmonics", it's only a sine(t), a ± wave.

You may get (visually) a pretty good sine by bandpass filtering your square wave (two filters sequently — lowpass and highpass probably with not very low Q). Actually, low border of bandpass (highpass) only needed to filter some constant amplitude.

After filtering, you may need to add some amplitude to your sine wave if you need it.

Also, you need a filter with 4th and more order. After all, i think it's worth to search some other methods.

\$\endgroup\$
2
  • \$\begingroup\$ Given the wide range of input frequencies, some of which have several harmonics to be rejected below the fundamental frequency of other possible inputs, this will not work unless you automatically tune the filters. \$\endgroup\$ May 29, 2016 at 2:32
  • \$\begingroup\$ What would the high pass filter accomplish? \$\endgroup\$
    – user207421
    Jan 27, 2017 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.