Need help - Interfacing an Electret mic to a microcontroller

Ok I have the finalized working schematic with all values updated. After experimenting with a lot of different configurations I now have an excellent performing sound sensor that works beyond my expectations. I made some minor changes to the schematic.

http://i627.photobucket.com/albums/tt358/botwire/SoundSensor.gif

This design will detect a whisper approx one foot away. Adjusting the POT will make the circuit less sensitive, however, it will become more responsive. Adjusting the POT to a higher voltage level, increases the sensitivity, but reduces the responsiveness to sound. In other words, once triggered, there is a small delay before it will reset. I find this feature useful as it offers flexibility. Changing the value of C1 to a lower value will change the reset delay and increase responsiveness with out affecting sensitivity.

I will try to get another video of the final design.

EDIT

The Note for the pot should read R5 not R4.

Very nice! I think I might want to try something like this in my robot. Can you give a list of all the components used?

BTW I am curious. what are you using to draw the schematics?

Here’s the part list:

B.O.M. All parts available at Radioshack except mabe the pot. You can use a 10kpot and run a 10k resistor in series which is what I am doing.

1 - R1 – 5k Ohm
3 - R2,R4, R6 – 1k Ohm
1 - R3 – 1Meg Ohm
1 - R5 – 20k POT
1 – C1 – .1uf to10uF (.1uF will provide a faster response)

1 - 2N3904 Transistor
1 - LM741 Op Amp
1 - LED Diode
1 - PC board condenser mic PN: 270-0090

I’m using ExpressPCB sofware. It’s a free download and it’s super easy to draw nice looking schematic files. www.expresspcb.com

They do have the 10k pots at RadioShack. I see them there every time i go. Trimmers are the same as pots, right?
radioshack.com/product/index … Id=2062301

Yeah that will work no problem. Trimmers can be caps or resistors, you just have to pay attention to the type of trimmer you are getting.

Here’s another video showing the effect the pot has when adjusted. If you don’t like the delay the LED has, then you will want to use a cap in the .1uF range. I like the delay because it keeps it from over sampling the sounds.

youtube.com/watch?v=rqckgg-Xyec

Another video demonstrating the sound sensor circuit interfaced to the Bratinator. I wanted to test out the SSC-32 Seq trigger code.

[code]Main

ADin 0, micValue ; Check for sound

serout S_OUT, i57600, [dec micValue, 13]

If micValue > 400 then
SeqIndex = 8 ; Move head left
gosub seqplayer ; Go play the sequence
Low P12 ; Turn ON LED
Endif

if micValue < 400 then goto Main ; This line prevents sending to many Seq commands

SeqIndex = 2 ; Only center the servo after the move head left command was sent
gosub seqplayer ; Go play the sequence
high p12 ; Turn OFF LED

goto Main ; Start over[/code]

The VIDEO:

youtube.com/watch?v=23s_LwDYKiQ&fmt=6

Nice! I like the music. :stuck_out_tongue:

So there’s no sensor on the right side of the head yet?

I only have the one sensor for right now but I can make two and have each one connected to seperate AD pins and do a compare.

I have a new problem. I would like to write my code so that the head moves but continues to hold position until 3 to 5 seconds has elapsed with the ADpin voltage value @ 400 or less (no sound). My previous attempts cause the center servo commands to execute after each “turn left” sequence. I can provide example code later today.

If you look at the video above, that is what my current code is doing.

Previous experiments cause the center servo command to happen when the ADpin is more than a value of 400. After the SSC-32 is busy sending a command, the sound sensor is ignored during this time and any new commands to move left is omitted. I want to be able to stay in a loop while checking the ADpin and only exit that loop if more then 3 to 5 seconds has passed with the ADpin less than 400. so in other words, have it react to the first sound and move left, hold the position, only center the servo if there is silence for more than 3 seconds. Any new sound in the 3 second time frame, will reset the 3 second counter delay.

[code]

micValue Var Word
delayTime Var Nib

Main

ADin 0, micValue ; Check for sound

serout S_OUT, i57600, [dec micValue, 13]

If micValue > 400 then
SeqIndex = 8 ; Move head left
gosub seqplayer ; Go play the sequence
Low P12 ; Turn ON LED
Endif
'--------------------------------------------------------

Restart:
For delayTime = 0 to 2
Pause 1000
ADin 0, micValue ; Check for sound
If delayTime < 3 AND micValue > 400 goto Restart ; Loop till 3 sec silence
Next

'--------------------------------------------------------

if micValue < 400 then goto Main ; This line prevents sending to many Seq commands

SeqIndex = 2 ; Only center the servo after the move head left command was sent
gosub seqplayer ; Go play the sequence
high p12 ; Turn OFF LED

goto Main ; Start over[/code]

I have not tested the above code yet. Will this work?

Some how the AD pins no longer function. My circuit only puts out a maximum of 2.5 volts and the ADpins can handle 5v. The strange thing, all the ADpins no longer function and I’ve only been using P0, but P1,P2, and P3 no longer show any values either. All I did was download another program with all connections intact and it stopped working. I reloaded the older program that was working and still no go. I turned off power to the bot board and back on, this did no good either.

The below program does nothing anymore:

[code]micValue VAR word

Main:

ADin 0, micValue

serout S_OUT, i57600, [dec micValue, 13]

If micValue > 400 then
Low P12 ; Turn on RED Bot Board LED if greater than 500
Else
High P12
Endif

Goto Main[/code]

Did you revert back to the potentiometer output to test them?

I did not revert back to the Pot test since the sensor circuit is working as it should. I can do the pot test anyway just to verify that indeed, they are blown to a crisp. :laughing:

As an alternative, I have connected the output of the sound sensor to a regular pin and using the IN6 (pin #6 as an input) I am able to react to sound the sam way as using the ADin command.

I will try the pot test tonight.

One more thing I need to check is the version of the IDE. I think I might have two versions on my PC. I’ll clean all versions off my pc and do a fresh install and then try the pot test.

Well I uninstalled and reinstalled version 8018 and my AD pins are working again. So I did not smoke the AD converter after all. Woooohooo!

Here’s the new board I’m working on. I usually spend a week tweaking stuff like silkscreen labels and a few traces. The board has two channel audio sensors and a SpeakJet. The left and right channels have independent adjustment pots and the SpeakJet has adjustable volume control. The board also has a total of five LED indicators; One for each audio channel and 3 for the SpeakJet. I have also included pull down resistors on all eight event pins eliminating the need for shunts. Oh and the board is ABB stackable (3" x 2.3").

http://i627.photobucket.com/albums/tt358/botwire/RSS.gif