Creating sine wave

  • Thread starter edmondng
  • Start date
  • #1
159
0
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
 

Answers and Replies

  • #2
berkeman
Mentor
58,432
8,504
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:

https://www.physicsforums.com/showthread.php?t=122607

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.
 
  • #3
159
0
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...?

Thanks
 
  • #5
xez
174
0
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. :)
 
  • #6
159
0
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.
 
  • #7
159
0
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...
 
  • #8
berkeman
Mentor
58,432
8,504
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...
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:

http://www.circuitsage.com/pll.html [Broken]
 
Last edited by a moderator:
  • #9
1
0
Hi,
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 ?

Regards,
Partik
 
  • #10
xez
174
0
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
means.

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.
 
  • #11
Hi..

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?
 
  • #12
berkeman
Mentor
58,432
8,504
Hi..

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?
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.
 

Related Threads on Creating sine wave

Replies
12
Views
3K
Replies
5
Views
708
  • Last Post
Replies
10
Views
7K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
4
Views
4K
  • Last Post
Replies
7
Views
7K
  • Last Post
Replies
7
Views
8K
  • Last Post
Replies
20
Views
1K
  • Last Post
Replies
9
Views
7K
  • Last Post
Replies
7
Views
36K
Top