DIY Function Generator... if you're interested

Started by empress_effects, May 26, 2006, 09:52:19 PM

Previous topic - Next topic

empress_effects

Hi Guys,

I've stalked this forum for quite awhile, but I've finally registered and this is my first post.

I'm going to be making myself a simple function generator to help with testing out circuits. I had a friend ask me if I could make him one too so I figured why not share the thing with anyone who wanted one. I'll cook up the circuit and make a working pcb layout. Instead of using analog oscillators, it's going to use a PIC with a basic 6 bit ( I think) D/A to make the waveforms. I'll program the PICs and sell them to anyone at cost. Shipping of a little chip should be really cheap... (I'm in Canada)

As for the design of the function generator, I was thinking it would have a control for frequency (from 1 Hz to 20kHZ) and a control for amplitude (0V to 5V peak to peak). It would have a number of waveforms: sine, triangle, square, sawtooth, possibly others.

If you have any suggestions or if you're interested in this little project, please let me know.

Steve.

R.G.

Kewl. A $5.00 function generator.

With one of the PICs with 10 bit PWMs you should be able to do a 10 bit accuracy low frequency setup. Or use one of the Microchips $1.50 digital pots and have the PIC just be an 8 bit pot turner.

I guess you could do an 8 bit R-2R ladder, but the accuracy really isn't there.

R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

empress_effects

Thanks for the idea about using the PWM on the PIC RG. I've only used PWM to control motors, never used it for audio purposes. For the output filter, would an inductorless Butterworth be a good idea?

Steve.

Peter Snowberg

Welcome to the forum! 8)

Excellent project!

You can get really good results with R-2R ladder D/As if you use the right parts. Try using an octal flip-flop like a 74HC574 and 0.1% resistors for the ladder. You have to clock it with an additional pin, but you can then use the D/A data pins for other purposes besides just D/A data. The HC574s also provide a very consistent drive. If you don't want to re-use the pins, a 74HC573 will provide the same consistent drive without the clocking requirement.
Eschew paradigm obfuscation

BN

I'm no sure if this will help you but it's a tone generator I've been thinking of building myself some time. It's using an AVR instead of a PIC but I figure it's possible to use the same approach of the problem even if the code will vary.

EDIT: Sorry, I forgot to post the URL... Here it is: http://www.myplace.nu/avr/minidds/index.htm

I'm interested in your design anyhow. Good luck!

//BN
"Rock 'n roll keeps you young, but you can only get away with that for so long. Eventually you become too old to stay young. And I think that's the point I reached" - David St. Hubbins

empress_effects

Thanks for the ideas Peter. I've used R-2R ladders before for D/A conversion, but I've never used PWM for audio, so I'm going to go the PWM road.

After looking at acouple PIC datasheets, I've come up with a couple numbers. If I run the internal osciallator at 8MHz and use the x4 PLL, I'll have the clock frequency at 32Mhz. If I set the PWM frequency to 125kHz, I should be able to get close to 8 bit resolution.

I was thinking that the sample rate would be variable and would depend on the frequency. So say you wanted a 100Hz triangle wave: a triangle wave that was sampled 256 times per period would be used, so that the output of the function generator would be a nice triangle wave. Then if you wanted a 10kHz triangle wave, a triangle wave that was sampled 8 times per period would be used, not the nicest looking triangle, but at least you'd get higher frequencies.

Is this idea crazy?

I'm going to breadboard this pretty soon...

Steve.

Floyd Pepper

Don't know if this helps but describes using a PIC as a tone generator.  http://ww1.microchip.com/downloads/en/AppNotes/00543c.pdf

There's a whole load of stuff on signal generation here http://www.epanorama.net/links/oscillator.html