Dangerous Prototypes

In development => Project development, ideas, and suggestions => Topic started by: embeddederic on April 30, 2012, 04:56:41 am

Title: DIY Audio Function Generator Part 1
Post by: embeddederic on April 30, 2012, 04:56:41 am
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://http://embeddederic.blogspot.com/2012/01/sine-waving-into-new-year.html
I 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://http://embeddederic.blogspot.com/2011/08/remembering-jim-williams-dead-bug-style.html
 
This 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:
[attachment=5]
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:
[attachment=4]
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.
[attachment=3]
[attachment=2]
[attachment=1]
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.
[attachment=0]
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...........................
Title: Re: DIY Audio Function Generator Part 1
Post by: brian on April 30, 2012, 08:28:19 pm
I'll be interested in how low THD you can actually get. Certainly mostly an issue with audio I should think more than most anything else.
Title: Re: DIY Audio Function Generator Part 1
Post by: embeddederic on April 30, 2012, 10:55:02 pm
I built up the LT1037 Wien-Bridge Osc a few months ago and got 0.024%..... the noise floor of my uncalibrated HP 331A Distortion Analyzer is at 0.01%; Jim Williams stated he got 0.0025% (an order of magnitude better than my results) with the exact same circuit. So either my construction isn't as good as his, or my HP 331 is just not the right tool for measuring the THD of this circuit.

It is fun pushing the limits of my test gear though. Once I get the function generator built up I may have to send one off to someone with a better Distortion analyzer than me to get a second opinion.
Title: Sv: DIY Audio Function Generator Part 1
Post by: honken on May 04, 2012, 06:43:59 am
You should look into adding a PLL feedback loop into your design. Then the readjustment part would vanish and you get to integrate analog and digital design.
Title: Re: DIY Audio Function Generator Part 1
Post by: arhi on May 04, 2012, 12:21:43 pm
Nice project, I do think you should build and not purchase this but
[quote author="embeddederic"]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%. [/quote]

for ~100$ you can get HP 3310A frequency generator. I have few pic's of inside the device here (http://https://picasaweb.google.com/117119526632711464397/HP3310A?authuser=0&feat=directlink).

I measured less then 20ns rise and fall times on full range (spec is less then 30ns)
On the sync output I measured 12ns rise/fall (spec is under 20ns)
Capable of 30Vpp output
High and Low outputs overlap for range greater then 60dB
Sine Wave Distortion (thd): 0.0005Hz to 10Hz greater then 40dB
so THD by spec is under 1% but we measured THD on the full range (0-5MHz) and it is below 0.01%, on the audio range it's less then 0.001%.

So, this ancient device can get you what you need for ~100$, of course, it's nicer to make your own :D

Another interesting thing is that there's a schematic of 3310A available so you can use it in design of your own device :D
Title: Re: DIY Audio Function Generator Part 1
Post by: embeddederic on May 04, 2012, 09:35:28 pm
Hey Honken,

My original idea was to use a AD9850 125 MHz Complete DDS Synthesizer and hook it up to an Atmel micro running some Arduino code, but I didn't think I could get as good of THD from this DDS solution so I was always going to still have a separate BNC output for the wien-bridge oscillator. I also wanted to hook up an SD card and DAC IC to the Atmel micro and have a "wav" file programmable wave form generator. I used Scilab to create a bunch of sine, square, ramp and ECG wave forms in a wav file format. the Arduino would then play the wav file out one of the Outputs of the function gen and produce a programmed signal..... but the project was getting too big in my head, so inorder to do more than think about it I broke the project up into a "Analog" function gen and I'll later build up the DDS Arduino based programmable function gen.
Title: Re: DIY Audio Function Generator Part 1
Post by: embeddederic on May 04, 2012, 09:39:25 pm
Hey arhi,

I was actually looking at buying a HP 3310A very seriously on ebay, but i still wasn't able to find one for under $200. My function gen isn't really going to be an less expensive by the time I buy the precision LT opamps and order some raw PCBs.... but design and build something form scratch will be fun and I'll learn a few things. Also if it works will I may offer it as a OSHW kit.... I got to get it built up and working first though :)
Title: Re: DIY Audio Function Generator Part 1
Post by: arhi on May 04, 2012, 11:24:47 pm
[quote author="embeddederic"]
I was actually looking at buying a HP 3310A very seriously on ebay, but i still wasn't able to find one for under $200
[/quote]

my first ebay search shown one for $99 :D
Can't find that one now but here's one: http://www.ebay.com/itm/HP-3310A-Functi ... 500wt_1413 (http://www.ebay.com/itm/HP-3310A-Function-Generator-to-2-Mhz-/130689402749?pt=BI_Signal_Sources&hash=item1e6db2077d#ht_500wt_1413)

99$ starting bid, 0bids, 125$ buy now

[quote author="embeddederic"]
My function gen isn't really going to be an less expensive
[/quote]
most probably but what you will learn + the spec you can achieve will make it worth it... but check out schematic for 3310A might give you some good ideas :) ... it has some valuable options like positive and negative DC component etc etc (and I see you have THD meter from the same generation so they would look awesome one next to another :D )
Title: DIY Audio Function Generator Part 1
Post by: embeddederic on May 05, 2012, 01:37:58 am
Cool, a function gen like that for $125 is a good deal.

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01172098952session_write_close ( )...(null):0
20.01202230544ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01202231320Database_MySQL->query( ).../DatabaseHandler.php:119
40.05462370056Database_MySQL->error( ).../Db-mysql.class.php:273