Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Creating sine wave

  1. Jun 11, 2007 #1
    Trying to create a sine wave. Any oscillator or chips that do it? Looking at 100kHz. Seems like most of the oscillators i find put out 0~3.3/5V square wave.
    But i am m looking for -2.5~2.5V 100kHz sine wave output.

    I would think the chips create the square wave by taking the sine wave and going through some sort of comparator/inverter thus digitizing the signal but how do i get sine out?

    I must be missing something....and i need the resolution so no DACs

    Thanks for help
  2. jcsd
  3. Jun 11, 2007 #2


    User Avatar

    Staff: Mentor

    Pretty funny -- I googled audio oscillator tutorial, and got lots of good hits. One of the first ones was to a thread that I was in here on the PF a while back! Here's that thread, which has some useful links itself to audio oscillator info:


    BTW, don't necessarily reject the DAC approach just yet. Depending on your distortion specs, you may find that an 8-bit DAC with a follower multi-pole LPF will give you superior specs to a simple oscillator, and it is much more controllable and stable in frequency. You can even make a 16 bit R-2R DAC (or use a 12b industry DAC or whatever), if you want a more smooth starting waveform to put through the LPF.

    Welcome to the PF, BTW.
  4. Jun 11, 2007 #3
    thanks berkeman. those links don't work anymore though.
    anyway maybe DAC isn't so bad either. Only thing is i want to create a smooth sine wave and not see any 'steps'. I suppose this can all be done in software by giving finer points plus maybe at 100kHz is should be smooth enough?

    When i was looking for DACs, a lot of the R-R DACs only have Vdd and Gnd (not Vss). Can this still give me -2.5 to 2.5V? I would think i will need +-5V at least. AD7304 allows +-5V but i don't require 4 output. Maybe there's another chip out there...?

  5. Jun 11, 2007 #4


    User Avatar

    Staff: Mentor

  6. Jun 11, 2007 #5


    User Avatar

    Once upon a time the fairly obvious, cheap, and widely
    available answer to your question was to use an integrated
    circuit function generator / waveform generator such
    as the ICL8038, XR2206, MAX038, or a handful of similar
    devices that would output a fairly good sine wave for any
    frequency between DC and around 100-200kHz for some
    of them.

    Nowdays, they've mostly been discontinued, though if
    you search you can probably find some small electronics
    distributor with a few in stock, or find some old kit
    project that includes one for sale.

    There is a NTE864 chip which is apparently available now
    from Mouser for $30 or so per chip (maybe it's less elsewhere); apparently it's about the same as the old
    ICL8038 chip. $30 seems like highway robbery to me,
    since in the good old days the original parts of identical
    function were under $3 in quantity one.

    Your misunderstanding is that common oscillators oscillate
    with sinusoidal oscillators and then convert that to a square
    wave. Actually they usually oscillate with either a
    triangle wave, saw tooth, or exponentially rising pulse
    then convert that to a square wave based on the crossing
    of a logic level threshold by that timing waveform. It's
    uncommon to have access to anything BUT a square wave
    for most oscillators. The 555 timer IC hooked up as an
    astable multivibrator is a common example of using an
    exponential RC time constant charging waveform followed
    by a logic level comparator et. al. to generate an
    square wave oscillator, though that doesn't help you.

    I'd probably suggest going with the approach of
    using a microcontroller and 10-12 bit DAC and
    just outputting samples of a 100kHz sine wave with a
    sample rate of something like 3 MHz - 10 Mhz for good
    waveform fidelity and easy filtration. Then filter the
    DAC output with a couple of stages of RC or LC lowpass
    filtering. Use a dual op-amp so you can drive the first
    op-amp with the DAC's RC filtered output, filter the
    signal more on the output of that 1st op-amp, then use
    the 2nd stage op-amp to generate the right output
    amplitude / impedance / power you may want.

    Even with all the cost of the uC, DAC, Op-Amp, PCB, you'll
    spend less than the $30 one NTE chip will cost, and it'll
    be a higher fidelity signal that you can adjust trivially
    easily in frequency / waveform or whatever by just
    reprogramming the sample table (use a simply in circuit
    reprogrammable flash programmable uC like a PIC/AVR
    chip of some appropriate kind).

    I do recall that there are a couple of companies besides
    NTE still offering integrated circuit function generator /
    waveform generator parts which would make 100kHz
    sine waves easily. However the parts and company names
    don't come easily to mind for me now; if you search for
    a while you could probably find one. Though you'll
    still have to find a distributor with those in stock that will
    sell a low quantity for a good price, and that's a bit harder
    with more obscure parts than with mainstream ones.

    Alternatively if you just need a fixed frequency without
    such easily tunable options as a digital waveform
    synthesizer will give you, and you can tolerate a bit of
    temperature / mechanical instability of the frequency,
    you could just build one of the op-amp based sine wave
    oscillator circuits that've been discussed.

    If you can settle for a frequency under say 20kHz you
    could always just program a PC sound board to emit the
    tone and get the signal from the headphone jack. :)
  7. Jun 12, 2007 #6
    thanks berkeman and xez. Probably in the long run the DAC method would be the best then i suppose. i'll take a look at all options, currently in the testing stage.
  8. Jun 12, 2007 #7
    another quick question. whats the main difference between clock oscillator and crystal? Does crystal put out sine/sawtooth and clock oscillator is square wave?

    I was wondering maybe could just use a 100kHz crystal and then just filter out the harmonics, but then i suppose there will be a DC offset...
  9. Jun 12, 2007 #8


    User Avatar

    Staff: Mentor

    You can design a crystal oscillator to put out either a sine or a square wave. A "clock oscillator" is just a canned crystal oscillator -- a crystal oscillator is usually what you call it when you make your own oscillator with a crystal, some discretes and an inverter (or the Xin/Xout pins on a microcontroller, for example).

    I googled crystal oscillator tutorial to get you more info, and got lots of good hits. Here's one with a number of tutorial links (scroll down the page) from circuitsage.com:

  10. Jul 2, 2007 #9
    I am generating sine wave of 50Hz using 10-Bit DAC. I have connected two stage LPF also after DAC . But still sine wave is not that much smooth so can anyone tell me how to solve this problem ?

    How to make it smooth in hardware ?

    i have used Lookup table method to generate sine wave . So is there any other method to generate sine wave ?

  11. Jul 2, 2007 #10


    User Avatar

    Are you sure you're calculating your sine values properly?

    Are you normalizing the amplitude of the sine wave's
    sampled values in the digital table so that you are using
    the full 10 bits of DAC range as you go from the positive
    peak of the sine wave to the negative peak of it?
    It will help the smoothness if you do that, and if you
    control the overall output amplitude via external analog

    Is your sampling frequency of the sine table values
    and for the DAC output frequency quite high compared to
    the 50 Hz frequency of the sine wave? I would suggest
    a sample rate of at least 50,000 Hertz so you have
    1000 sample points or more along the time interval
    corresponding to one full sine wave cycle. It is ok to use
    less if that is the limit of your hardware, but using a larger
    number is better for the smoothness.

    Since you're wanting a 50 Hz sine wave, it would be ideal
    to have an analog filter after the DAC's signal is
    properly converted to analog.

    A good filter would be at least a 2nd order
    12dB/octave frequency roll-off rate band-pass filter
    whose frequency is centered on the sine wave's frequency,
    50 Hz.

    It would also be possible to use a 2nd order (or higher
    order) low-pass filter with a -3dB corner frequency
    well higher than 50Hz, perhaps somewhere
    in the range of 200 Hz.

    If you do have most of these things implemented to
    some reasonably good degree, your DAC system
    will yield exceptionally smooth sine-wave outputs!

    It is not bad to use a DAC for your synthesis, but it is
    often a necessity to apply a little filtering on DAC outputs
    to remove the quantization step effects and resultant
    waveform distortion and high frequency components
    from the stair-step output of the DAC.

    You generally get best results from a DAC waveform
    synthesis when the sampling rate of the digital
    waveform is high compared to the highest frequency being
    usefully synthesized in the analog domain waveform.
    At least 2x the highest analog frequency being generated
    is the minimum possible digital sample rate, but for
    easiest filtering it is not uncommon to use 64x or 128x
    or 256x or some similarly large over-sampling rate.
    At 50Hz base-band frequency you should be able to get
    quite an excellent high over-sampling rate even with
    very slow digital circuitry and DACs.
  12. Sep 12, 2007 #11

    I want to generate 50KHz-60KHz sinewave using a microcontroller.

    Please guide me how shall I proceed? Which would be the best microcontroller for this application?
  13. Sep 12, 2007 #12


    User Avatar

    Staff: Mentor

    The most straightforward was would be for the uC to read the sinewave data out of a ROM, and output the data on a regular timer interrupt to an external DAC. Or instead of a DAC chip, you could just form an R-2R ladder DAC using some of the uC's IO lines.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Creating sine wave
  1. Arduino Sine waves? (Replies: 4)

  2. LM324 - Sine Wave (Replies: 3)