PDA

View Full Version : Microphone to PIC



scaenix
- 17th February 2007, 02:59
I'm planning to build a bot with two microphones as ears. Basically, the robot will function like this: It has two microphones as ears, one for the left and one for the right. If it hears a sound (though not cognitively) from one of its ears, it would go in that direction.
I've been considering that the two mic would compare with each other so as to move accordingly in the direction of the sound. I've searched through Google and most search results would tell me that I would need an ADC converter before I could connect it to the PIC. But as I've seen in this website: http://www.restena.lu/convict/Jeunes/PhaseSound.htm , the mics were connected to a comparator before they were connected to the PIC. Now I'm getting confused. I'm planning to make the program using PBP where the PIC would treat the mic input like a light sensor input. Is there anyway to clear this up. Any suggestions would greatly help. Thanks very much! :)

ronsimpson
- 17th February 2007, 07:03
I am looking at http://www.restena.lu/convict/Jeunes/PhaseSound.htm .
I see MIC, 2 amplifiers, a peak detector, amplifier and a comparator. R11 & R20 set the lever for the comparator. The audio is above or below the level. The input to the PIC is a 1 or 0.

The PIC measures the delay from left to right. If the sound arrives at the same time then the sound came from directly in front or back. If the right ear hears the sound first then by and amount of delay the sound is to the right at some angle. Sound is 1100 feet/second. If the ears are 1 ft apart and the delay is 1mS then the sound is directly to the side. If the sound is 0.1mS delayed then the sound is only slightly to the side. Do the math.

My first thought is to drop the comparator and run the output of the last amplifier into the ADC of the PIC. The compare function then is done in software. If ADC > 53 then ear=1 else ear=0. The compare value (53) can be automatically adjusted for week/strong signals. There is probably too much delay through the ADC.

Next idea: Keep the comparators and replace R11 + R20 with a DAC. This way software chooses the compare level to match the sound level.

In your case you want to compare the sound “level” to determine left/right. You will want the ears facing left and right not front like the first example. Because you are thinking level not delay, I would drop the hardware comparator. The PIC must have 2 or more analog inputs! You will compare ADC1 and ADC2 and head in the correct direction. You may have trouble knowing if the sound is in front or in back. Worst case you may have to rotate 360 degrees before you know which way to go. I think you will have to go zigzag, drive [walk] +10 degrees then –10 degrees. If the sound is behind not in front you will know! Zigzagging may give you more accurate information.

You will find the audio level range is far greater then you think. (I have done this before.) In the first example the level is not very important, just the delay. The second example the level is all you have. A 8 bit ADC will gave you a maybe 100:1 range in level so about 10:1 range in distance. (10 feet to 1 foot) Not good. By changing the amplifier and adding AGC you could measure 1,000:1 or more. I think I have a PIC measuring audio levels to 10,000:1.

Sounds fun…Good luck.

mister_e
- 17th February 2007, 17:24
There's still the option to use a PIC with 2 comparator and set their reference with resistors , trim pot OR HPWM. I like the HPWM stuff... full control of the beast... and when you want :D

Now you just need an amplifier/Microphone and poll the comparator output to know what's happen.

scaenix
- 18th February 2007, 12:46
There's still the option to use a PIC with 2 comparator and set their reference with resistors , trim pot OR HPWM. I like the HPWM stuff... full control of the beast... and when you want :D

Now you just need an amplifier/Microphone and poll the comparator output to know what's happen.


I don't quite get what polling the comparator means! :D

mister_e
- 18th February 2007, 13:03
to do simple... read the comparator output.



If Comparator1=1 then Goto GotSoundFromLeftEar
If Comparator2=1 then Goto GotSoundFromRightEar


where Comparator1 and Comparator2 represent dedicated I/Os OR internal register (like CMCON for a PIC16F628A and/or PIC16F88)

scaenix
- 18th February 2007, 14:23
ok got that! thanks very much! :D

scaenix
- 8th March 2007, 03:46
There's still the option to use a PIC with 2 comparator and set their reference with resistors , trim pot OR HPWM. I like the HPWM stuff... full control of the beast... and when you want :D

Now you just need an amplifier/Microphone and poll the comparator output to know what's happen.


Sir, if this method is to be done, how should I place the microphone? front or facing left and right as said in the previous post?

mister_e
- 8th March 2007, 03:53
it will depend of what type of mic you are using. A good unidirectional is suggested but you can use an omnidirectional and hack it's pattern.

with both, you need to place them in such way they will detect ONLY what you want to. Hence, face left, and face right.

Maybe you could try midpoint between right and middle, midpoint between left and middle.

With some experiment you should find the best match.

scaenix
- 8th March 2007, 03:54
How about this link sir?

http://www.extremenxt.com/sound.htm

the creator of the project said that the circuit is a simple sound sensor but I can't quite figure out the purpose of the diode array with the label RCX. I tried to look for a way to contact the creator of the project but I didn't find any. I know that the circuit is made for RCX from Lego Mindstorms, but I just want to know how to use this sensor for a PIC, specifically 16F84A, so that I could make a PBP program for my project. Any help would be gladly appreciated. Thanks in advance.

mister_e
- 8th March 2007, 04:04
the diode thingy is use to supply the OP-AMP AND also use to modulate the OP-AMP signal to the supply line. I don't know how the RCX handle it but to me , for your application it's way too complicated.


Now if you want to use this grand'pa 16F84, you will need to boost the MIC signal. A single rail op-amp will do the job.

Did you already know which mic model you will use?

scaenix
- 8th March 2007, 04:53
Well, I'm hacking an old earphone to be used as mic, which, correct me if I'm wrong, makes it a unidirectional mic. I've tried the mic on an stereo amplifier and worked though. Sir, isn't the signal coming from the mic an analog signal? Please correct me again if I'm wrong.

mister_e
- 8th March 2007, 05:37
well any speaker/earphone could be more directional. But their sensitivity are usually pretty bad too. Never tried with any earphone (walkman or else).

What range of frequency you need to detect?

One thing is sure, you'll have to use a high pass filter to avoid any type of interference caused by your robot motor/floor/gear noise.

I really have to do something like that one day. As many other i've buyed the Robosapiens, dismantle it... and let him gathering dust :D

And yes the mic signal is analog.

PS: you don't need to call me sir. I'm not as old as Darrel Taylor is ;)

Darrel Taylor
- 8th March 2007, 06:05
Hey, Hey now! I resemble that remark.


As many other i've buyed the Robosapiens, dismantle it... and let him gathering dust.

<table><tr><td align=center valign=top>What? Like this ...

http://www.pbpgroup.com/files/Dusty_Robo.jpg</td><td><br><br><br>http://www.pbpgroup.com/files/Robo_Shelf.jpg

Sitting on the shelf, next to my Teddy. :)</td></tr></table>

mister_e
- 8th March 2007, 06:10
yeah! at least yours is in one piece :D

Some part of mine have been a little bit chewed by my dog... he will really need an extreme makeover... well the Robosapiens :D

scaenix
- 8th March 2007, 07:39
well any speaker/earphone could be more directional. But their sensitivity are usually pretty bad too. Never tried with any earphone (walkman or else).

What range of frequency you need to detect?

One thing is sure, you'll have to use a high pass filter to avoid any type of interference caused by your robot motor/floor/gear noise.

I really have to do something like that one day. As many other i've buyed the Robosapiens, dismantle it... and let him gathering dust :D

And yes the mic signal is analog.



Apologies for calling you "sir"...

Hmm... I guess I should by a mic though. :D I need to detect frequencies above 15KHz. I'm bit pressured now 'coz the project I'm making is due next friday and I'm still in the design stage. Actually, this project was just thought out last January after realizing that our previous project proposal for our class is not going to materialize. :)

mister_e
- 8th March 2007, 19:01
above 15khz :eek: make sure of your mic spectrum specs before. forget the speaker.

scaenix
- 9th March 2007, 04:08
above 15khz :eek: make sure of your mic spectrum specs before. forget the speaker.

i don't quite understand why i should "make sure of my mic spectrum before". before what? I'll use a tweeter instead of mic if i have to.. :)

mister_e
- 9th March 2007, 04:13
speaker/tweeter are good to reproduce sound, but i doubt of their reliability/efficiency as microphone. Worth a try for sure.

scaenix
- 9th March 2007, 07:22
what would likely be better to use for the circuit? condenser or dynamic? can you suggest any easy method of determining the leg configuration of a 3 wire condenser mic? Thanks in advance. :)

mister_e
- 9th March 2007, 16:37
any model for this mic? is this a professionnal XLR connector or just a 3 wire capsule?

Any picture or part # would be handy.

Condenser or dynamic? Who knows, the best way will be to evaluate them with a pink noise and a spectrum analyser.

Few days ago i found the following freeware for someone here. I've tried it, and i'm really impressed how good it is... for a freeware.
http://www.sillanumsoft.com/

scaenix
- 10th March 2007, 14:35
It's just a simple 3 wire capsule.

I am feeding the mic into an amplifier which will turn the signal into pulses. I want to measure the pulse width and compare the widths of the two mic inputs. The problem is I do not know what commands to use in the PBP program. I've read the manual and PULSIN seems to be a good command. I reallt need some hints on this. Thanks again very much for helping me even until this far.

mister_e
- 10th March 2007, 20:13
You could use Count as well. To me using the internal Timer/Counter have it's advantages.