12
\$\begingroup\$

A Google search will give you a few billion ideas. Which is the simplest/easiest/cheapest that you know of?

Generating a square wave and then filtering out the harmonics isn't a good solution unless the filter frequency can be varied along with the square.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ What frequency? \$\endgroup\$ Aug 8, 2010 at 4:50
  • \$\begingroup\$ Audio frequencies, I guess \$\endgroup\$
    – endolith
    Aug 8, 2010 at 22:45
  • 4
    \$\begingroup\$ easiest and cheapest are typically opposint parameters ;) \$\endgroup\$
    – vicatcu
    Aug 9, 2010 at 17:33

8 Answers 8

5
\$\begingroup\$

Making a numerically controlled oscillator (NCO) with uC + DAC is very easy. Could be a fun FPGA project. An advantage to an NCO is that you change waveforms.

I did a low frequency numerically controller oscillator Arduino sketch (see http://wiblocks.com/docs/app-notes/nb1a-nco.html). At the bottom of the webpage are a couple of references to the original articles,

\$\endgroup\$
6
  • \$\begingroup\$ There are some pitfalls to generating waveforms digitally, so you need to design the firmware well to produce low-distortion waveforms, but that goes for analog circuits, too. So relatively, this is cheap, simple, and easy. :) \$\endgroup\$
    – endolith
    Nov 23, 2010 at 20:56
  • \$\begingroup\$ At the bottom of the page there are references to the original articles published in the Computer Music Journals. These discuss the trade-offs in S/N. \$\endgroup\$
    – jluciani
    Jan 3, 2011 at 11:58
  • \$\begingroup\$ My 'advanced' uP class in college had this as an exercise in ASM on the 8051. The project was called waveform generator and we had to do a ramp, sawtooth, and sine wave. I recommend it as a learning exercise but don't do it in ASM =P \$\endgroup\$
    – NickHalden
    Jun 15, 2011 at 14:15
  • \$\begingroup\$ Use dither to keep distortion down, and if you're generating anything other than sine waves, use bandlimited synthesis methods to avoid aliasing. It's not trivial to make good quality signals. \$\endgroup\$
    – endolith
    Oct 14, 2014 at 14:28
  • \$\begingroup\$ The link seems to broken (wiblocks.luciani.org: 4003). Can you provide the essential part here (e.g. a schematic and the principle(s) it is based on)? \$\endgroup\$ Feb 2, 2018 at 22:45
7
\$\begingroup\$

Wien bridge with a pot to vary the frequency. I bet you could build one for less than one US dollar.

\$\endgroup\$
2
  • 4
    \$\begingroup\$ You should clarify that you need a dual element potentiometer to do this, and I'm not sure you can find those for much less than 1 US dollar. The circuit requires that R=R1=R2 (And C=C1=C2). Also, the gain needs to be controlled so that oscillation will continue, see this page for more details: ecircuitcenter.com/circuits/opwien/opwien.htm \$\endgroup\$ Aug 9, 2010 at 13:40
  • \$\begingroup\$ A good point, Nivek. I might suggest a dual digital pot like the Maxim MAX5496 or the Analog Devices AD5235, but that definitely increases the cost by two or three dollars. I suspect that there is also a way that you could use a current mirror made from some BJTs to make one pot do double duty, but I'll leave that attempt to someone who really knows what they're doing with analog stuff. \$\endgroup\$
    – pingswept
    Aug 9, 2010 at 14:07
3
\$\begingroup\$

You didn't specify the frequency (100Hz or 100MHz?) or how much the frequency had to be varied (0.01% or 1000% ?) or whether the frequency had to be varied by a voltage or a physical knob. Purity of sine wave and stability matters too.

A one-transistor FET Hartley oscillator is hard to beat for cheap.

\$\endgroup\$
2
\$\begingroup\$

You could also PWM or otherwise DAC values out of a table to produce sine waves. Then the filtering should be easier. A very cheap MCU could probably do it up to fair frequencies.

I might second some RC + opamp design in principle. Whether the output and adjustability suits you depends on the application.

There are also some function generator IC's, ranging from classic 8038 to various complex DDS thingies. They might not come that cheap, though.

I guess there's also the option of finding an affordable second hand lab signal/function generator. It might be a long search for a cheap one, but it's all relative. Or you could take a spare AC generator and turn the shaft with variable speed. Amplify for power/impedance/voltage :)

\$\endgroup\$
3
2
\$\begingroup\$

Cheapest DIY DDS signal generators (including sine wave):

http://www.myplace.nu/avr/minidds/index.htm

http://www.scienceprog.com/avr-dds-signal-generator-v20

\$\endgroup\$
1
\$\begingroup\$

You can still do it with a square wave and filtering out the harmonics. There are a number of high order filters that can be controlled with a microcontroller easily. This one allows the user to control the corner frequency with an outside clock (second square wave from the micro). Because of the large corner frequency to clock frequency ratio you could even do it without the need of another timer/interrupt with a simple software counter...

\$\endgroup\$
1
  • \$\begingroup\$ If you're using a microcontroller, I would think PWM output would be simpler. Then you only need a simple fixed-frequency filter. \$\endgroup\$
    – endolith
    Aug 9, 2010 at 14:52
1
\$\begingroup\$

If you want to go the direct digital synthesis route with discrete chips, capacitors, etc. the result won't be nearly as compact as what could be done with a CPLD or micro, but would be pretty reasonable, especially since a significant amount of the circuitry could be shared among the five signal outputs.

Global signal generation requirement:

  • Input clock source
  • 12-bit counter (74HC4040)
  • 14 inverters (3 of 74HC14, leaving 4 gates open)
  • 13 small-signal capacitors
  • 13 resistors

Per-output requirement:

  • 13-input NAND gate (74HC133)
  • 12-bit counter (MC14521 or CD4521)
  • Lots of jumpers to set frequency

More details to follow. Given an input of 4,096,000Hz, the circuit should be able to produce square-wave outputs from 2KHz to 512Khz in multiples of 0.5Hz for signals up to 2KHz, 1Hz for signals up to 4Khz, etc. Other techniques can be used to convert a square wave thus generated into a sine wave.

Here's a circuit diagram to show the concept:

(HERE)

This circuit includes a configurable frequency generator (5 switches select input frequencies from 1/16 of the input up to 31/16 of the input). I also threw on a rough square-to-sine converter. Note that unlike most filtering techniques, this one maintains a reasonably consistent amplitude over the frequency range. The wave is quite rough because the above circuit only uses 4-bit counters. The MOSFETs would be replaced in practice by 4066 pass-gates (4 per chip).

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

Triangle oscillator with a triangle to sine converter.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Are you being charged per-character by your ISP? I kid, but you could probably develop this answer a bit further... \$\endgroup\$ May 4, 2011 at 13:57
  • \$\begingroup\$ @Reemrevnivek, I had to rush to go to college, and had 2 mins to type out that answer... 1.5 mins of that were finding the link to what I wanted. \$\endgroup\$
    – Thomas O
    May 4, 2011 at 16:55
  • 1
    \$\begingroup\$ @ThomasO: You can edit answers to add more info at any time... \$\endgroup\$
    – endolith
    Mar 19, 2012 at 21:58

Your Answer

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

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