DIY Audio Function Generator Part 1 - Page 1
Forum section: electronics / projects

author: EmbeddedEric
author_rank: Contributor
timestamp: May 01, 2012, 06:40:40 pm
content: Most of my Blog posts involve short 3-4 hour projects/hacks that I just build up for learning and fun. I thought it was time to develop something a bit more involved and share my design process in a series of posts over the next few months.I have lots of test equipment in my home lab from O-scopes, RF Signal Generators, a Spectrum Analyzer, RF Power Amps to a slew of Multimeters and DC Power supplies, but one piece that is missing is a simple low end Audio Function Generator. I searched eBay and anything worth wild was in the $200+ mark and to be honest I wasn't that impressed with their specs. Most $200 Function Generators only have a Sine Wave output spec'd at 1% THD....... 1% is ok for most uses, but I just got done building up Jim Williams Wien-Bridge Osc. and was able to get 0.024%.http://embeddederic.blogspot.com/2012/01/sine-waving-into-new-year.htmlI want to be able to use the Sine Wave output to test ADC resolution and as a base band signal for RF projects and having very Low Total-Harmonic-Distortion (THD) would be nice.So I've decided to build my own Function Generator. Most DIY Function Generators I found online start out with a Square Wave Oscillator feed into an integrator to get a triangle wave, then you feed the triangle wave into a wave shaper and you get a rough Sine Wave output. This is similar to a project I built up last year.http://embeddederic.blogspot.com/2011/08/remembering-jim-williams-dead-bug-style.htmlThis method works, but the wave shaped Sine wave isn't going to have the low THD I was looking for, so I am taking the opposite approach and starting with a Sine Wave Generator based on the #327 Lamp Wien-bridge Circuit to get the low THD. I'll then feed that into a Comparator to produce the Square wave; I am then using the Square Wave to turn on/off a ramp generator circuit. I would rather have a ramp output vs a triangle wave. The ramp circuit will let me play around with different single & dual slope ADC concepts later on.Below is a block diagram of my proposed design:I've added a +3.3V Square wave output to be feed into a frequency counter, so I don't need to bother to add a display to the function generator. Mine as well make use of the Frequency counter I have for a display, also having a +3.3V square wave output would be nice for any micro projects later on.I'll have a Freq. Adjust Pot, Freq. Range switch, Ramp Current Source Adjustment Pot, and an Output Amplitude Adjustment potentiometer. Below is a rough layout of the proposed design:I really like the layout of the CEE Source Measurement unit, so I'll be mounting the PCB in a similar looking plexi top and bottom when it is all done.After sketching out the concept drawings my next step was to test the Wien-Bridge Oscillator circuit I was basing this whole design around. I prototyped up the circuit with the Frequency Range Select switch and 10K pot and was pleasantly surprised to see everything worked well.The three switch selectable frequency ranges I have are: 16Hz to 600Hz, 160Hz to 6kHz, and 1.6kHz to 60kHz with the 10K potentiometer adjusting the output frequency continuously through the ranges. The one downside with this Lamp based implementation is there is a settling time of several seconds needed after each major adjustment to allow time for the Lamp to thermally settle.... this is an ok tradeoff for me given I should be able to achieve very low 0.05% or lower THD.The next step was to draft up the rest of the circuitry in LTSPICE to see if I could create the Square Wave and Ramp functions successfully.After an afternoon of playing I settled on this circuit. It works well in simulation and now I'll have to build it up and see if it works for real.More Testing, DesignSpark PCB Layout, and prototyping to come...........................

author: T4P
author_rank: Super Contributor
timestamp: May 01, 2012, 07:45:51 pm
content: Function generators are clearly meant for something other then generating audio frequenciesIf i wanted almost distortion free audio signal i hook up a buffer that is capable of at least 200mA all the way to 40000hz ( because my SC can do it )to my laptop( Using Visual Analyzer )Cheap for me since it's 24bit anyway . But anyway , it's a nice little project you did there !

author: EmbeddedEric
author_rank: Contributor
timestamp: May 01, 2012, 09:44:53 pm
content: Hey Dave,I have never measured the THD of my laptop's sound card; now you have me curiousI just downloaded a ToneGenerator App and will have to hook up my laptop to my HP 331A and see how low the THD is.http://www.ringbell.co.uk/software/audio.htm

author: amspire
author_rank: Super Contributor
timestamp: May 01, 2012, 11:36:57 pm
content: You would be doing well if you managed do get the noise level from a laptop down to the microvolt level which is what you need to get a low noise+distortion sinewave.Also there have been a lot of very tragic stories from people who have been using their audio output from a PC or iPhone as a signal generator. It is really easy to damage the output.Richard.

author: EmbeddedEric
author_rank: Contributor
timestamp: May 02, 2012, 05:11:15 am
content: I was curious so I hooked up my HP dv9000 Laptop headphone jack up to my HP331A Distortion Analyzer and measured the THD of a 1KHz sine wave. I used the ToneGenerator app to create the 1KHz sine wave and I measured the THD at 0.88%; which isn't bad considering the BK Precision 3011B Function Generator I borrowed from work had a 1KHz Sine Wave THD of 0.86% (the spec is 1%).So if I added a buffer to my laptop I'd get a Sine Wave quality on par with the $200 ebay Function Generators that are usually spec'd at 1% THD. I hope to get much better, in the range of 0.05%, THD with the Function Generator I am designing.

author: T4P
author_rank: Super Contributor
timestamp: May 02, 2012, 06:49:09 pm
content: Quote from: amspire on May 01, 2012, 11:36:57 pmThat's why buffer themQuote from: EmbeddedEric on May 02, 2012, 05:11:15 amMy Fujitsu LH520 apparently measures from output to mic input and being careful not to overdrive any inputs/outputs at 1Vrms i get 0.03% using VisualAnalyzer