16

I'm trying to make a simple but good sine wave generator that will produce 1Vpp @ 1kHz.

Sine waves are nature's oscillations. They're everywhere. So you'd think that it would be a piece of cake to make an electronic sine wave. Apparently not so. SE is riddled with questions on how to make them. There are currently 9 Similar Questions showing on the right hand side of this screen. Most of them seem to have problems.

Low pass filters, high pass filters, ring oscillators and Wien bridges with exotic filament bulbs from 1960. Digital to analogue converters and Arduinos. Most don't seem to work or can't be made to oscillate in a simulation package. Some produce triangles instead of sines. Some designs require knowledge of inductors.

Why is this so hard? Square, saw tooth and triangular waves seem to be easy, yet they don't readily exist in nature. Since they are so useful, I would have thought that I'd just buy a sine oscillator chip (like a NE555 sine variant) , add a resistor and capacitor and off I go with a 99.99% pure wave. Am I missing something, but it seems that simple electronics are not particularly compatible with sine wave generators?

Paul Uszak
  • 7,327
  • 5
  • 37
  • 69
  • Bottom line - the companies tooled to make them feel there are things they can be doing that are more consistent with their corporate goals. – Scott Seidman Aug 31 '16 at 01:19
  • @dwelch -- even radio mixers run on square waves these days! – ThreePhaseEel Aug 31 '16 at 01:45
  • I may be way off base, but what about converting a square wave to sine with this simple circuit? Then you could use an off-the-shelf 555, add 3 resistors and 3 caps. http://www.learningaboutelectronics.com/Articles/Square-to-sine-wave-converter-circuit.php – Ryan Griggs Aug 31 '16 at 02:14
  • 3
    Also, it appears the AD9833 by Analog Devices is still in production: http://www.analog.com/media/en/technical-documentation/data-sheets/AD9833.pdf – Ryan Griggs Aug 31 '16 at 02:18
  • 5
    "...1Vpp @ 1kHz" Yes, but at what THD, noise, frequency vs temperature stability...? There's a reason Audio Precision still sells multi-thousand dollar testers, which are often used outside the audio arena, purely because they're built around a very high purity sine wave generator, good to ~200 kHz. – Warren Young Aug 31 '16 at 02:18
  • @dwelch but 50 Hz is getting towards the lower limit for ac coupled circuitry. It might not get through with lots of dB roll off... – Paul Uszak Aug 31 '16 at 03:09
  • "Sine waves are nature's oscillations. They're everywhere." - what 99.99% pure 1kHz sine waves do you see in Nature? "like a NE555 sine variant" - does a 555 produce 99.99% pure square waves? – Bruce Abbott Aug 31 '16 at 03:16
  • 4
    I think some of the challenge is requirements. If you have very low requirements for quality, its easy enough to build your own or go digital. If you have very stringent requirements, you're going to find yourself in a niche market very quickly. – Cort Ammon Aug 31 '16 at 04:13
  • The AD9850 module is also quite popular among hobbyists. It can be had for around $10 on Ebay. –  Aug 31 '16 at 08:27
  • @dwelch actually, the AC generator is the most serious answer, as OP brought nature as example. Electric motor is a natural sine generator. – Agent_L Aug 31 '16 at 11:23
  • @BruceAbbott Simple tuning fork - "Gentle striking of a steel, 256 Hz. fork on the thenar eminence produces tones comparable in purity to those generated by ANSI-calibrated audiometers" – Paul Uszak Aug 31 '16 at 12:16
  • Square wave generation isn't easy at all. Getting a steep enough flank without ending up with tons of harmonics for a reasonable price with small footprint can be a challenge. – Mast Aug 31 '16 at 12:26
  • I remember there existed an IC that sounded similar to a 555. Though I think the only ones that exist now are counterfeits. – Bradman175 Aug 31 '16 at 12:41
  • 1
    "Simple tuning fork" - but amplitude decays quickly. To get a continuous tone you have to keep striking it (= not pure tone). Electronic equivalent is a simple coil and capacitor (tuned circuit). Same problem, to get continuous oscillation you have to keep 'hitting' it with a pulse stream or amplifier with positive feedback. – Bruce Abbott Aug 31 '16 at 13:19
  • Microprocessor and a digital to analog converter. – Steve Aug 31 '16 at 20:19

4 Answers4

26

The main problem with sine wave generation is that it takes two resonant elements to tango in producing a 180° phase shift -- classically, an inductor and a capacitor. At RF, this isn't a problem -- inductors are easy. However, as you get into lower frequencies, the large inductors involved become unwieldy, which is why alternative sine generation approaches based on multiple RC networks, filters, or shaper networks are used. RC network or filter approaches are good for fixed frequency sines -- the Wien bridge of Hewlett's day is still quite a viable circuit, and simple enough to implement around a dual opamp without a lamp, as there are alternatives to the incandescent bulb for gain stabilization -- Figure 43 in LTC AN43 is your friend here, reproduced below (the appnote has better versions, but Figure 43 suffices to show the concept).

LTC AN43 Figure 43

However, if you need an agile sine source at low frequencies, the Wien-bridge's requirement for a dual gang potentiometer or equivalent electronic element is a downer. This is where all-analog function generator ICs such as the ICL8038/MAX038 and the XR2206 came in -- providing basically what you asked for with reasonable (within a % or two) THD, across several decades. These ICs all used the same basic approach -- an astable with tracking square and triangle outputs, followed by feeding that triangle wave into a circuit known as a "sine shaper". There are several sine-shaper approaches, covered well here -- overdriven pairs can be used to good effect in an IC design, although a more sophisticated approach uses a fully translinear sine shaper circuit a la the (obsolete) AD639. The JFET approach mentioned in the overview link is more practical for discrete parts experiments, despite its amplitude sensitivity, though.

What eventually killed the monolithic analog function generators, though, was digital technology. Modern agile sine sources, such as the AD9833, are the digital equivalents of the triangle-to-sine approach, using what's called a Direct Digital Synthesis technique, in which a phase accumulator is used to divide down a fast square-wave clock into a numerical ramp, which then feeds a ramp-to-sine lookup table. This can be done on a microcontroller as well of course, although such does limit the frequency of operation quite significantly.

Interestingly enough, the demand for accurate sines in the analog world has been reduced nowadays, even at RF -- the realization that the RF mixing function is best implemented by way of digital switching means that square-wave RF local oscillators are a much more viable option than they first seem.

ThreePhaseEel
  • 8,858
  • 4
  • 26
  • 41
  • As for DDS @ 1kHz and ~1V, a PC with a sine wave generator program makes a pretty good test source. PC sound outputs benefit from extremely high production scale (hence good performance for nearly $0) and the fact that human ears are pretty good at detecting noise, so almost every PC is capable of putting out well over 90 dB of SNR near full-scale. A PC is piss-poor if you need a 1mV sine wave, though. – Warren Young Aug 31 '16 at 02:22
  • One intermediate step before digital synthesized sines was the switched-capacitor filter; figure 15 here is an example of an easily tuned oscillator. – Whit3rd Aug 31 '16 at 02:35
  • I think that this proves my point. I can kick a rusty bucket and it will resonate with a sinusoidal pattern. My £1 plastic recorder makes them. Have you seen Figures 26, 27 and 28 for initialisation and operation of the AD9833? It might require C programming. I can make a square wave oscillator with a pair of back to back transistors, but you're suggesting a multi gigahertz PC with a hard disk? – Paul Uszak Aug 31 '16 at 03:01
  • i would also dispute that there is little demand for sine waves in the analogue world. I want them to calibrate my sound card oscilloscope. Audiophiles want them to test their amplifiers of what ever class. Even the class D digital ones. Ham operators probably want them. Basically isn't a sine wave generator the only way to test anything analogue & audio? Yet it appears that it's difficult to make them and I wonder if there is some fundamental principle that thwarts us? – Paul Uszak Aug 31 '16 at 03:06
  • @PaulUszak your calibration is only as good as your reference standard, minus your ability to transfer measurements from that standard to your instrument to be calibrated. How do you plan to calibrate your sine wave calibrator in both frequency and amplitude? Then keep it stable? – user2943160 Aug 31 '16 at 03:12
  • @PaulUszak -- actually, it's been the hams that have led the charge on switching mixer designs and the square-wave LOs to match, especially on the receive side. – ThreePhaseEel Aug 31 '16 at 03:42
  • 2
    @PaulUszak, "I can kick a rusty bucket and it will resonate with a sinusoidal pattern", yes, but it will not be a sustained oscillation. It is not difficult to make something "ring" with a sinusoidal variation in amplitude. The difficulty lies in sustaining that oscillation without it dying out or distorting, as mentioned in several answers. – Johannes Aug 31 '16 at 08:00
  • 4
    @PaulUszak your £1 plastic recorder only "makes sine waves" if you don't care about 25% or more total harmonic distortion. And if that is the case, any simple electronic oscillator circuit will be "good enough". – alephzero Aug 31 '16 at 10:49
  • @PaulUszak Everything you've described are niche applications, the very exact definition of not "little" but "negligible" demand. – Agent_L Aug 31 '16 at 11:19
  • 1
    @PaulUszak "Basically isn't a sine wave generator the only way to test anything analogue & audio?" Actually no, because if you're looking at audio then it's very unrepresentative of what it's actually used for. Pink noise is often a much better solution. – Graham Aug 31 '16 at 11:34
  • 2
    @PaulUszak -- squares are actually very good for analog testing too -- you can gather a wealth of data based on the step response of a system. – ThreePhaseEel Aug 31 '16 at 11:46
  • 1
    @Agent_L Not sure what *niche* means, but as I type this there are 10 *Related* questions showing next to it. Some one some where is trying to build them and having issues. I'm the 11th. – Paul Uszak Aug 31 '16 at 12:23
  • @ThreePhaseEel First thing I tried with my sound card and valve amp were squares. Totally trashes the FFT, can't measure THD at all and the on screen trace looks more like triangular when f > 1kHz. Are you sure that you can get anything useful putting square waves though audio amplifiers? – Paul Uszak Aug 31 '16 at 12:30
  • @PaulUszak 11 people in the whole world - that's what niche means. – Agent_L Aug 31 '16 at 13:22
  • 2
    @PaulUszak *"I want [a sine wave reference] to calibrate my sound card oscilloscope."* Well, perhaps you'd be better off posting *"How should I calibrate my sound card oscilloscope?"* as a question, because there are many severe limitations to using a sound card as an oscilloscope digitizer, including some that will completely distort waves you might be interested in - such as the common square and triangle waves. Calibrating it to a sine wave might give you a false impression of usefulness. – Adam Davis Aug 31 '16 at 18:06
  • @PaulUszak: A square wave "...totally trashes the FFT..." Of course it does. A pure square wave is composed of [infinite odd-integer harmonics](https://en.wikipedia.org/wiki/Square_wave#Examining_the_square_wave), and a real-world square wave will have various distortions on top of that, throwing spikes all over an FFT plot. The purpose of square wave tests is not to generate clean FFT plots, unless your notion of "clean" is an infinite regress of odd-integer harmonics. – Warren Young Sep 02 '16 at 15:00
  • @PaulUszak: A square wave "...can't measure THD at all..." Nor do we expect it to. We use square wave tests for [other purposes](https://tangentsoft.net/audio/pimeta2/bench/square.html). – Warren Young Sep 02 '16 at 15:01
  • 1
    @PaulUszak: "...the on screen trace [of a square wave] looks more like triangular when f > 1kHz" That means your square wave generator is running out of bandwidth, losing out on the higher harmonics necessary to a true square wave. You need a bunch of the higher harmonics to approximate a square wave, which is an exponential function, 2ⁿ, where *n* is the number of harmonics. For n=10, that's 1024 × your fundamental, so at 1kHz you need ~1MHz of bandwidth. It isn't easy to generate good-quality high-frequency square waves. – Warren Young Sep 02 '16 at 15:01
11

"Am I missing something, but it seems that simple electronics are not particularly compatible with sine wave generators?"

Let me start my answer with the following sentence:

"A good harmonic (linear) oscillator needs a suitable non-linearity" .

The reason for this apparent contradiction was explained in another answer already: Each "sinusoidal" oscillator needs an amplitude regulation mechanism. For small amplitudes (start of oscillation) the loop gain must be slightly larger than unity - thus allowing oscillation to build up. However, before hard-limiting takes place (supply rail) the loop gain must be reduced automatically to stop further increase.

Hence, we need a circuitry that is amplitude-dependent - which means: Non-linear. As a result, the loop gain swings periodically around "1" - and the closed-loop poles slightly swing between the right half of the s-plane (rising amplitudes) and the left half (decaying amplitudes). It is not possible to place the poles (as required by the theoretical oscillation criterion) directly on the imag. axis of the s-plane.

Now - the problem is as follows: The non-linearity must be (a) large enough to allow a safe start-up of oscillations (with consideration of all tolerances) and (b) as small as possible with respect to harmonic distortions. Hence, a trade-off is necessary.

There are various non-linear elements in use for this purpose (diodes, FET-resistor, OTA as resistor, light bulbs, thermistors,...). However, the best results are obtained using an extra regulation loop (containing rectification and controlled active gain blocks) with a relatively large time constant. This time constant determines the periodic movements of the poles (as mentioned above). Using such principles, THD values in the order of 0.01% are possible.

EDIT: (additional information).

There are oscillator topologies with two or even more opamps which have nice features: One of the opamps performs "soft amplitude limiting" and the ouput of the other amplifier unit is a lowpass/bandpass filtered version of the first opamp. This structure allows surprisingly small THD values. Examples are: Two-integrator loops (with different time constants) and GIC-based oscillators.

LvW
  • 24,857
  • 2
  • 23
  • 52
6

There used to be a couple of nice function generator ICs, the Exar XR2206 and Maxim MAX038.

The XR2206 produced sine, square, triangle, ramp, and pulse waveforms from 0.01 Hz to 1 MHz; the Maxim the same from 0.1 Hz to 20 MHz.

Both are now listed as obsolete on Digi-Key, but you can still find them around, e.g. here at Jameco. Note: "Clearance" for $7.95. For the same price you can get a kit from Hong Kong for a dollar more.

Don't know why they have been discontinued, perhaps people think it's easier just to use a microcontroller + DAC + lookup table.

tcrosley
  • 47,708
  • 5
  • 97
  • 161
  • (+1) And there was the (old and now also obsolete) [Intersil ICL8038](https://www.intersil.com/content/dam/Intersil/documents/icl8/icl8038.pdf) too. I wonder if that is why Maxim chose the **038** part of their MAX038 part number...? – SamGibson Aug 31 '16 at 01:01
  • Name those people, because I think they're mad... – Paul Uszak Aug 31 '16 at 01:17
  • 2
    ~2% THD doesn't count as "sine wave" for many applications. Test gear meant to check for distortion in other circuits, for one. The chips you talk about are basically triangle wave producers with post-processing to either square the output up or round it off a bit. – Warren Young Aug 31 '16 at 02:12
  • 6
    Production IC manufacturing requires an extraordinary amount of overhead, and fabs don't idle well, so it's not feasible to run at low volume. Maxim seldom kills parts, but MAX038 had no volume design wins, despite seemingly every engineer sampling 1 unit and building themselves a bench oscillator. So between no new wafer starts, and no design wins, and the fab upgrading to new equipment (making the masks obsolete), and the distributors charging rent for their shelf space, nobody wants to pay what this part really costs. Maxim would have been better off giving this part away for free. – MarkU Aug 31 '16 at 06:31
3

If you want a 99.99 % pure signal, the usual square, saw tooth and triangle signal generators fail. As you wrote those signals don't exist in nature and a really precise technical signal of this shape doesn't exist too. A perfect step transition does not exist and a perfect ramp is not real too.

The problem with an exact analog signal generator is the necessary amplitude regulation. A little bit less amplification and the signal slowly disappears, a little bit to much and the sinus signal is distorted. The perfect amplitude regulation is difficult for slow sinus signals.

Uwe
  • 1,602
  • 7
  • 6