Connect with us

square to sine

Discussion in 'Electronic Basics' started by Sandeep, Nov 4, 2005.

Scroll to continue with content
  1. Sandeep

    Sandeep Guest

    Hi all,
    I want to know how to convert a 1KHZ square wave into a stable sine
    wave .Please can anybody help me out
    Many Thanks
  2. You just need a good 1kHz filter. Sine will be as stable as your square.

    petrus bitbyter
  3. John Fields

    John Fields Guest

  4. I could be wrong, but wouldn't a low-pass filter be easier to construct,
    and more to the point?
  5. Never mind I suppose, I just notice a separate thread on SED covering
    that very topic. It would appear that the bandpass method may be
    preferred in some situations.
  6. Ralph Mowery

    Ralph Mowery Guest

    I would use a low pass filter also. It needs to start cutting off somewhat
    above the fundamental frequency. As the square wave is all the odd
    harmonics, if your cutoff is below 3 khz (using your 1 khz square wave) then
    you will have a very good sine wave. after the filter.
  7. skeptic

    skeptic Guest

    The problem with filters is that they work well only over a narrow
    range of frequencies. Another method that will work over a wider range
    of frequencies is to run the square wave through two integrators. The
    first one will convert it to a triangle wave and the second one will
    convert it to something very close to a sine wave. Of course the
    amplitude of the resultant sine wave will vary inversely with the
    frequency. Now you know why function generator ICs put out square
    waves, triangle waves and sine waves.
  8. Ever since I've heard of the 8038 and the phase-locked loop, I've had a
    fantasy of locking in a sine wave to some square wave by PLL of some kind.

    Set up an 8038 (or maybe these days it's the XR220whatever) as a 1 KHZ
    oscillator, and run a phase detector output into the freq. control input.
    Should be a piece of cake. ;-)

  9. Two op amps in series with 100K on each (-) input and feedback from the
    output to the (-) input through a .01mF capacitor. Both (+) inputs
    grounded? Or should the values be changed?

  10. OP is only concerned with 1KHz, that's a pretty narrow range.
  11. John Fields

    John Fields Guest

  12. John Fields

    John Fields Guest

  13. Bob Masta

    Bob Masta Guest

    It would be a sine wave, if the input was a true square wave
    with +/- swing, otherwise it would be a true sine wave with
    some DC offset.

    The advantage of the bandpass is simply higher Q, but
    in theory a lowpass form should be superior since the
    bandpass is wasting half of its slopes on the low side
    where they do nothing useful. The trick is to use a
    lowpass with high Q giving a peak at 1 kHz. The fact
    that there is a plateau on the lower side is of no
    consequence, since there isn't anything there anyway.

    Whether lowpass or bandpass, at high Q there will be
    the issue of stability. If the tuning drifts slightly, the
    output amplitude may change substantially. This is
    one argument for a more-typical flat passband lowpass,
    since you can make it less sensitive to drift in components
    or the input square wave frequency... if you are willing to
    put more stages into the circuit.

    The OP doesn't mention where the original square wave
    comes from. If it is being generated in a circuit under your
    control, you can instead generate at a much higher frequency
    and divide it down to 1 kHz. This opens up two new

    1) Use a switched capacitor filter where the high frequency becomes
    the filter clock, insuring solid stability even at high Q.

    or 2), you can make a cute little D/A type of circuit where you
    sum different amounts of the higher components such that
    the harmonics cancel. I've seen several designs like this over
    the years, but I don't know what they would be called to search
    for them in Google. The big advantage is that they work over
    a broad range of frequencies, and they virtually elimiante all
    harmonics below 2^N - 1 where N is the number of divider
    stages in the original (I think!). Basically, a handful of resistors
    and a few divider stages is all this takes, and you can follow
    it with a simple lowpass to remove the higher trash.

    Best regards,

    Bob Masta

    D A Q A R T A
    Data AcQuisition And Real-Time Analysis
    Home of DaqGen, the FREEWARE signal generator
  14. How so? I can see that there is a slight difference in the skirt slopes
    of the two filters. But since no filter is perfect, can you really say
    that the output of the low pass filter is not a sine wave, but the
    output of the bandpass filter is? What is the distinguishing factor?
  15. mike

    mike Guest

    Best help I can offer is to suggest that you disclose the secret
    operation that you're trying to perform. You're question is incomplete.
    The solution depends a LOT on unstated requirements.

    The simplest thing I can think of is a high Q resonator.
    I'd make a simple coaxial cavity resonator. But it'd have
    to be somewhat bent to compensate for the curved surface of the earth.

    Wanted, Serial cable for Dell Axim X5 PDA.
    Return address is VALID but some sites block emails
    with links. Delete this sig when replying.
    FS 500MHz Tek DSOscilloscope TDS540 Make Offer
    Bunch of stuff For Sale and Wanted at the link below.
  16. John Fields

    John Fields Guest

    My thinking was that with a simple single-pole lowpass with a
    square-wave input:


    You wind up with an integrator which merely charges and discharges
    the cap as the square wave makes its excursions.

    Run this through Linear's simulator to see what I mean:

    Version 4
    SHEET 1 880 680
    WIRE -32 192 -32 160
    WIRE -32 304 -32 272
    WIRE -32 336 -32 304
    WIRE 48 160 -32 160
    WIRE 160 160 128 160
    WIRE 160 192 160 160
    WIRE 160 304 -32 304
    WIRE 160 304 160 256
    FLAG -32 336 0
    SYMBOL voltage -32 176 R0
    WINDOW 3 24 104 Invisible 0
    WINDOW 123 0 0 Left 0
    WINDOW 39 0 0 Left 0
    SYMATTR InstName V1
    SYMATTR Value PULSE(-1 1 0 0 0 5e-4 1e-3)
    SYMBOL res 144 144 R90
    WINDOW 0 -38 58 VBottom 0
    WINDOW 3 -36 62 VTop 0
    SYMATTR InstName R1
    SYMATTR Value 1000
    SYMBOL cap 144 192 R0
    WINDOW 0 41 34 Left 0
    SYMATTR InstName C1
    SYMATTR Value 159n
    TEXT 0 320 Left 0 !.tran 0 .01 0

    OTOH, a simple bandpass filter, like this:


    will give you a beatiful sine wave out:

    Version 4
    SHEET 1 880 680
    WIRE -80 192 -80 160
    WIRE -80 288 -80 272
    WIRE -80 336 -80 288
    WIRE 0 160 -80 160
    WIRE 128 160 80 160
    WIRE 272 160 208 160
    WIRE 368 160 336 160
    WIRE 368 192 368 160
    WIRE 368 288 -80 288
    WIRE 368 288 368 272
    FLAG -80 336 0
    SYMBOL voltage -80 176 R0
    WINDOW 3 24 104 Invisible 0
    WINDOW 123 -91 84 Left 0
    WINDOW 39 -111 109 Left 0
    WINDOW 0 -75 53 Left 0
    SYMATTR Value PULSE(-1 1 0 0 0 5e-4 1e-3)
    SYMATTR Value2 AC 1
    SYMATTR InstName V1
    SYMBOL cap 272 176 R270
    WINDOW 0 32 32 VTop 0
    WINDOW 3 0 32 VBottom 0
    SYMATTR InstName C1
    SYMATTR Value 159n
    SYMBOL ind 112 176 R270
    WINDOW 0 72 56 VTop 0
    WINDOW 3 70 55 VBottom 0
    SYMATTR InstName L1
    SYMATTR Value 159e-3
    SYMBOL res 352 176 R0
    SYMATTR InstName R2
    SYMATTR Value 100
    SYMBOL res 96 144 R90
    WINDOW 0 -36 59 VBottom 0
    WINDOW 3 -31 59 VTop 0
    SYMATTR InstName R1
    SYMATTR Value 1000
    TEXT 48 320 Left 0 !.tran 0 .02 0
    TEXT -24 352 Left 0 !;ac oct 128 100 10000
  17. John Fields

    John Fields Guest

  18. Bob Masta

    Bob Masta Guest

    To get the lowpass to work here, the corner frequency
    needs to be just above the 1 kHz square wave frequency.
    An RC circuit like the above is only a good integrator
    approximation if its time constant is long, such that the
    effective corner is well below the input frequency.

    A simple RC is probably not going to be adequate
    to recover a very good sine wave approximation, though.

    Best regards,

    Bob Masta

    D A Q A R T A
    Data AcQuisition And Real-Time Analysis
    Home of DaqGen, the FREEWARE signal generator
  19. Bob Eldred

    Bob Eldred Guest

    As has been mentioned, you can filter the higher harmonics out using a band
    pass or preferably a low pass filter but that only works at a small range of
    frequencies. Depending on the required purity of the sine wave, filtering
    may prove to be difficult requiring a steep slope multi-pole filter to clean
    out harmonics. If the square wave has any asymmetry, even a percent or two,
    there will be a significant second harmonic present. This is a bitch to get
    rid of because of its closeness to the fundamental. Even the third harmonic
    can be troublesome.

    Another idea is the synthesizer scheme: Use the squarewave to switch an
    integrator to ramp positive then negative on each half cycle producing a
    triangle wave from the square wave. Run the triangle wave into an automatic
    gain stage to generate a constant amplitude. Use a diode-resistor shaping
    network to round the triangle wave into a sine wave form. Run this into
    another variable gain stage controlled by the amplitude of the original
    square wave to re-constitute the original amplitude of the square wave for
    the sine wave.

    This scheme creates a sine and triangle wave out of the square wave and can
    work over a range of frequencies. If the amplitude is not important, the
    variable gain stages can be ommited.
  20. Bob Monsen

    Bob Monsen Guest

    The OP can see this in action (or a similar scheme in action) by searching
    for and viewing the ICL8038 datasheet. It uses this scheme by making a
    triangle wave from a couple of current sources and a flipflop, and runs it
    through an array of PNP transistors. There is a schematic for the chip in
    the datasheet.

    The ICL8038 is now quite pricy, since it appears to be out of production.
    However, so you may as well go for the Cadillac:


    For $20, you can get a signal generator on a chip that goes from .1Hz to
    20MHz. It also appears to feature a PLL input, which allows the chip to
    lock the chip to an external reference, such as a square wave. I haven't
    spent much time looking at it, but it might be just the thing the OP needs.

    Bob Monsen

    When earlier, new functions were invented, the purpose was to apply them.
    Today, on the contrary, one constructs functions to contradict the
    conclusions of our predecessors and one will never be able to apply them for
    any other purpose.
    - Poincare
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day