Author Topic: DIY Audio Function Generator Part 1  (Read 10677 times)

0 Members and 1 Guest are viewing this topic.

Offline EmbeddedEricTopic starter

  • Contributor
  • Posts: 15
  • Country: us
    • Rants from the Embedded Hardware Guy
DIY Audio Function Generator Part 1
« on: May 01, 2012, 06:40:40 pm »
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.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://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:

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...........................
"The Brick Walls are there for a reason. They are not there to keep us out. Brick Walls are there to give us a chance to show how badly we want something." - Randy Pausch
 

Offline T4P

  • Super Contributor
  • ***
  • Posts: 3697
  • Country: sg
    • T4P
Re: DIY Audio Function Generator Part 1
« Reply #1 on: May 01, 2012, 07:45:51 pm »
Function generators are clearly meant for something other then generating audio frequencies  :o

If 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 !  :-X
 

Offline EmbeddedEricTopic starter

  • Contributor
  • Posts: 15
  • Country: us
    • Rants from the Embedded Hardware Guy
Re: DIY Audio Function Generator Part 1
« Reply #2 on: May 01, 2012, 09:44:53 pm »
Hey Dave,

I have never measured the THD of my laptop's sound card; now you have me curious  ;)

I 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
"The Brick Walls are there for a reason. They are not there to keep us out. Brick Walls are there to give us a chance to show how badly we want something." - Randy Pausch
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3802
  • Country: au
Re: DIY Audio Function Generator Part 1
« Reply #3 on: May 01, 2012, 11:36:57 pm »
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.

 

Offline EmbeddedEricTopic starter

  • Contributor
  • Posts: 15
  • Country: us
    • Rants from the Embedded Hardware Guy
Re: DIY Audio Function Generator Part 1
« Reply #4 on: May 02, 2012, 05:11:15 am »
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.
"The Brick Walls are there for a reason. They are not there to keep us out. Brick Walls are there to give us a chance to show how badly we want something." - Randy Pausch
 

Offline T4P

  • Super Contributor
  • ***
  • Posts: 3697
  • Country: sg
    • T4P
Re: DIY Audio Function Generator Part 1
« Reply #5 on: May 02, 2012, 06:49:09 pm »
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.

That's why buffer them

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


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf