Need help - Interfacing an Electret mic to a microcontroller

Did you ever check your mic as a mic? Get a mic connector like below and check to see if it actually works connected to a sound card mic input. You may need to do a little more looking into audio setups to capture an audio event so it can be detected as an analog or digital input.

radioshack.com/product/index … Id=2104062

I don’t have a mic connector and for almost the same price, I may as well buy a new mic. Even if my mic worked, I would still buy a new one for easier bread boarding. The current suspected bad mic is expoxied in the aluminum skull chassis and the leads are to short to use effectively.

Judging from the image you posted, it looks as if there is nothing connected to the analog input pin. :open_mouth:

LOL! I love it when you go… :open_mouth:

I don’t know what pin to use. Give me a tinny hint.

Actually it looks like the mic is connected to a 5v pin. That’s prob why you’re getting 1023 in the IDE.

Problem is, I get 1023 on every single pin, any 4 of them. Pic a pin… any pin… :laughing:

The analog pins are the ones at the top.

. . . . Input
. . . . 5v
. . . . Ground

[size=59]
I think someone should take a look at the manual[/size] :wink:

Um, I did look at the manual and that does not explain why I get 1023 when the wire is on the correct pin. The photo I posted was taken after trying all the pins, so the wire was connected to the last “Trial” pin when I took that photo.

you have VS VL pins -----> * * Then the analog pins ----->* * * * Then the other pins ------>* * * * * * * *

I have been following this rather loosely, but I still wonder from your picture were you have the voltage ping you wish to measure connected.

From your code, I believe that it should be connected to on the bot board to IO pin P0. As Wow7 mentioned it should be connected to the inner pin (input). If it is the wire that is nearest us, it looks like you have it connected to P16

Kurt

Also, i’m not sure how much different the pro is from the basic, but the ADin command doesn’t seem right. Try this:

[code]
micValue VAR Word

Main:

ADin ax0, 1,ad_ron, micValue

'Debug [DEC micValue,13]

serout S_OUT, i57600, [dec micValue, 13]

micValue = 0

Goto Main[/code]

Mike how about some basics to verify you code works… wire a pot between 5V and GND on the ends and connect the wiper to the analog input you want to use. Now run your program and verify you can sweep the pot back and forth and see the corresponding voltage change on the output from the bap.

Once that works you can replace the pot with the resistor and photo-cell divider and go from there.

Assuming the output of your circuit is the one off by itself. The image shows the output of your circuit going to the power rail of the AX0-4 I/O group. Even if you had the output connected to the proper I/O pin it’s still the wrong group… You are close to connecting to the I/O pin 16, not the I/O pin 0, which you are using ion your code. You are sunk in both areas. :open_mouth: <- made me do it again…

Analog Input vs Bot Board II label
0 = P0
1 = P1
2 = P2
3 = P3
16 = AX0
17 = AX1
18 = AX2
19 = AX3

Looking at the schematic header “J3-A” is what I am looking at. From left to right is AX0 to AX3. So where is this darn pin 16? Not talking BAP pin numbers, only header numbers, I only see it go up to P15 in the schematic. What you posted makes perfect sense, but the pin numbers are messing me up. You have BAP pin numbers and header numbers. I need an image I guess to see where AX0 really is. I’ve lost my mind. :open_mouth:

Eddie, I love that pot idea. I will use that to test the code.

EDIT>>
LOL! I deleted that last post. Sorry!

The last pin on the board is pin 16 (0 - 15 is 16 pins total).

Thanks Wowy cazowy, you showed me the error in my mind.

Makes sense to me now, after header pin 15 far right side of the board, it goes back to the far left side of the board and continues on as:

AX0 = Pin# 16
AX1 = Pin# 17
AX2 = Pin# 18
AX3 = Pin# 19

Let me try again using Eddies pot method.

Walla! It works! When I turn the POT it goes from 0 to 1023. The input wire is connected to P0 and not P16

[code]Working code:

micValue VAR Word
Main:

ADin 0, micValue

serout S_OUT, i57600, [dec micValue, 13]

Goto Main[/code]

Stage II is to breadboard my sensor design that I am experimenting with. I’m starting from scratch.

Ok here is the finished initial circuit design I drew up. I need to get some parts and bread board it for testing. I will try the LM324 as well as the LM741 shown.

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

I will report back with the results…

**Updated code: **Turns on the red bot board LED when the threshold is exceeded. This is useful to filter out low signals.

[code]micValue VAR word

Main:

ADin 0, micValue

serout S_OUT, i57600, [dec micValue, 13]

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

Goto Main[/code]

Yeah! 8)

Ok a quick video demonstrating the simple sensor using a simple program I developed. It works very well. When I can find the time and buy the parts I need for the sound sensor, Ill post a video of that also if all goes well. Oh and I added freaky background music like I always do. :laughing: :stuck_out_tongue:

youtube.com/watch?v=29ZGaYRiee0

Using one LM741 I got my sound sensor working. My goal was to design a simple circuit that did not require the use of an ADC chip that had to be software driven. I wanted a simple design that could be “plugged in” to any MCU and work, much like the Sharp IR sensor connected to the BAP.

The circuit has two possible design modes; in fact, I might be able to add a “switchable” mode that would allow me to switch on or off one of the two modes. In the first mode as shown in the video, the sensor operates in a “variable” mode much like a photo sensor. in the second mode, the signal output is high until a sound is made such as a hand clap. Momentarily, the signal will go low. Changing the value of C1 changes the delay of how long the signal stays low.

youtube.com/watch?v=8nr43DKT_-4