SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By KamPutty
#21198
Hi all,

Well, I'm busy trying to capture sound with my PIC. Not being an Electronics person, this is an arduous and painful task!!! :( :( :( :(

BUT (theres always a big but... :P)

I have done the following...

I purchased a kit : http://www.jameco.com/Jameco/Products/ProdDS/151204.PDF

that captures sound and plays it on a speaker/headphone.

this is what i'm trying to do

#1. Capture sounds via a mic and have the Pic read it via the ADC pin
#2. pass this data to another pic and play it on a speaker/headphone

I'm not converned at this time about compression, quality etc., just that I can capture, pass and play.

Now some electronics questions oh kind people... :oops:

#1. The kit does 2 things, capture, amplify and play (okay 3 things). At what point do I capture the data? At the output of the first opamp or the second? The second has a trim pot for volume control. My thinking is the first.

#2. Once I capture the data, pass it and want to play, I need a DAC. Someone mentioned using a MAX517 http://datasheets.maxim-ic.com/en/ds/MAX517-MAX519.pdf. This requires an SPI interface (no big deal), but is there a non spi solution thats simple (remember my electronics skills :( )

#3. The microphone. http://www.mouser.com/catalog/specsheets/KT-400028.pdf. The example I'm using (the kit) is powered via a 9v, I would like it to be run via 3.3v since the pics are at that...I'm not sure how to calc the res/caps etc I would need...any thoughts?

Well, simple eh?!

Now to go and get drugs...(daughter has Tonsillitis :(, so Satan will be visiting us for the next few days... :wink: :wink: :wink: :wink: ...

~Kam (^8*
By brennen
#21219
1) For the microphone's output to be in a voltage range that your pic can read, you have to have a preamp stage (audio-speak here...preamp is a "pre-amplifier" because it is a gain stage that is before or "pre" the main amplifier). This is the purpose of the first amplifier in the schematic (it also does some filtering in addition to amplification). The second amplifier is a low-voltage power amplifier that can drive a speaker. This is used because a normal opamp usually can't source enough current to drive such a heavy load as a speaker.

You are correct that you would take your readings after the first amplifier. Be sure you take your measurement immediately before C2, though, because C2 is a DC-blocking cap. This is used to eliminate the DC offset that is introduced by using a single supply on the microphone output and the first opamp. Leaving the DC offset in the signal you are measuring is good for you because your PIC can't read negative voltages. This is why I suggest reading it just before C2.

2) The MAX517 seems to be pretty simple to deal with. However, this chip has an I2C interface, not SPI. The PIC has both, so you can still use the chip. Chances are, however, that Maxim makes an SPI-compatible version of this chip (they almost always seem to make both). In my opinion, SPI is simpler to use (2 more wires, but the software is a bit easier).

3) The microphone spec says the mic will work from 1.5V to 10V with 4.5V being the typical voltage. With that said, 3.3V should work fine. The advantage of using a higher voltage is that you can generally get more signal out before you start distorting. Also, it is typically good to have separate supplies for your analog stuff and your digital stuff, especially in the audio world. There are tons and tons of places that talk about that. I would suggest Google or even getting a book on Amazon.

As far as calculations go, the simplest way to go is to copy this circuit or another on the net. Unless you're really wanting to get into the mechanics of amplifier design, you'll probably get more confused and end up with a lower-quality circuit if you try to design it yourself. The only problem with using the Jameco circuit is that it will require you to have a 9V supply, because the gains of your amplifiers will depend on this voltage. Otherwise, you will have to change the gains. I would suggest some general reading on opamp amplifier circuits, especially those that concern audio. Google is your friend. :wink:

For the DAC, use the application information stuff in the datasheet to help you out with filtering on the supply line.