Need help with a Stamp audio circuit
SN96
Posts: 318
Hello all,
I am trying to build a circuit that will take two eletret mics and have the audio output hook to a stamp. What I want the circuit to do is have a left and a right mic detect audio and have the stamp determin which mic has the loudest output. What needs to happen is if the stamp detects the left mic for example having a stronger signal from the right, it needs to move a servo to the·right or to·the·left depending on which mic had the largest input signal.
I'm not very good with circuit design which is why I need all the help I can get. Another concern I have is since the mic is analog, how would I make the signal a digital signal. Since I am not reproducing sound, the signal can be any kind the stamp can read. I am guessing once I have a circuit that can output to the stamp, that you would use the PULSIN command?
Here is the circuit I have so far.
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
I am trying to build a circuit that will take two eletret mics and have the audio output hook to a stamp. What I want the circuit to do is have a left and a right mic detect audio and have the stamp determin which mic has the loudest output. What needs to happen is if the stamp detects the left mic for example having a stronger signal from the right, it needs to move a servo to the·right or to·the·left depending on which mic had the largest input signal.
I'm not very good with circuit design which is why I need all the help I can get. Another concern I have is since the mic is analog, how would I make the signal a digital signal. Since I am not reproducing sound, the signal can be any kind the stamp can read. I am guessing once I have a circuit that can output to the stamp, that you would use the PULSIN command?
Here is the circuit I have so far.
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
Comments
Im hoping others will weight in with thier ideas, since·Im busy at the moment as we discussed already [noparse]:)[/noparse].
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 12/16/2005 8:43:34 PM GMT
Any input from anyone is welcome! I'm sure others would benefit from this project as well since ther are so few of this type of stamp project on the web. (I looked)
Thanks,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
Post Edited (SN96) : 12/16/2005 8:52:37 PM GMT
<edit> after further search I found the LT319AN·which has 2 comparators in a package for <$4 </edit>
<edit> Aha! theres the old standby, the LM311·for $0.59 apeice </edit>
BTW, you can use the same part number for both, but on the second comparator, you feed both signals into the same terminal (V+) just as you would for a summing configuration for opamps, I think hyperphysics has an example circuit (for summing opamps).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 12/16/2005 9:22:12 PM GMT
How about Amp'ing your microphone/s and running that into one of those bargraph generators (LM3915, LM3916.)· You'd have a·display of the sound it's "hearing", too, if you'd like.· You could pick off the voltage from the LEDs' cathodes (going LO/LOwer when ON) and put that into a comparator (LM339, config'd as a COMP), which you could then run to the STAMP.· Additionally, you can use the 3915/3916 to establish your threshold/s by adjusting the range.
I think you are on the right track with your schematic.... "Hear" is a schematic, based
on yours with a few changes. I basically changed the input configuration you had going
to the op-amps to make them inverting amps ( better gain ). On the outputs you will need
to use a Dual input ADC so that the Stamp can read each channel. Basically in this circuit,
if both inputs are equal, then the ADC value for both channels will be equal. If one input is
different from the other, then the ADC value will swing HIGH on one channel, and swing LOW
on the other channel. You should also be able to determine magnitude (volume) with this
circuit. ( ADC#1 + ADC#2 ) / 2 or something similar to that.
I might also add....
I would strongly recommend building this in a SBB (Solderless Bread Board) and experimenting
with things such as gain ( The 100K resistors across the OUTPUT and INPUT of each Op-Amp) as
well as the input resistors ( The other 100K resistors). Something like 10Meg or 1Meg would
not be out of the question for this type of project. Balance is important, so if you change a value
on one Op-Amp, make sure that you also change it on the other Op-Amp. For "test" purposes,
you might consider building your design with two LM741 Op-Amps rather than a single LM1458.
This is simply to help reduce "visual confusion" around a single IC version.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 12/17/2005 12:33:45 AM GMT
I appreciate the time you took to modify my design. It helps me understand so much better what you said by looking at the schematic. I guess I am more of a "visual learner" than anything else. I bought a solderless breadboard just for this project, and I will also try experimenting with the values like you suggested.
I do have one question about the schematic, what is the +2.5v circuit in the middle of the design? I'm guessing it is the power source for the two LM741's?
Thanks again!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
Q: I do have one question about the schematic, what is the +2.5v circuit in the middle of the design?
I'm guessing it is the power source for the two LM741's?
A: Your right, it is a voltage reference for the Op-Amps. If you look closely, there are two 1K resistors
that form a voltage divider between ground and your +5V supply. The divided voltage is 2.5V because
BOTH resistors (1K's) are the same value. This is a common "trick" with Op-Amps so that you do not
need to supply a negative voltage to the Op-Amp. If you reference 2.5V to the Op-Amp then a
"GROUND" signal ( 0V ) on the input is seen by the Op-Amp as -2.5V while a +5V signal on the input
is seen by the Op-Amp as +2.5V.
Input Voltage - Reference Voltage = What Op-Amp "sees"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
ADC0832 datasheet
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
This is one of the preferred ADC's that many people are using.
Nuts and Volts article:
www.parallax.com/dl/docs/cols/nv/vol6/col/nv118.pdf
This article starts out with a ADC0831 and then goes on to talk about
the ADC0832.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 12/17/2005 4:42:55 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I am waiting on my part ADC0832 to be shipped to my house. In the mean time, can someone take a last look at my latest schematic to see if anything needs to be changed or added before I begin to bread board this circuit? I want to make sure there are no obvious erros.
Thanks for any help!
[url=http://forums.parallax.com/forums/][/url]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
Post Edited (SN96) : 12/28/2005 7:05:27 PM GMT
Two 100K's allow for 25uA while two 1K's provide 2.5mA to the Vref of the Op-Amp.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I appreciate all the help you have provided as well as evryone else who has help me with this project. When my part comes in, I will test this circuit out and report my findings.
Thanks again.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
What happened to the 100K resistors on each of the op-amp negative input lines ?
Cheers,
Peter (pjv)
JK, thanks Peter for pointing that out! I have looked at this schematic dozens of times and still failed to see that. I'm going to make that change right now...
<<EDIT>> I updated the schematic image and made some fine tweeks to it. Thanks Pete.
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
Post Edited (SN96) : 12/28/2005 7:07:06 PM GMT
I tested the basic design of my project and it worked. I am still waiting on my ADC0832 part before I begin to write code for it. I know this is a simple circuit and it has been done before, but I am proud of my self because I·have such little knowledge of circuit design and having my design come to life from idea, to paper, to reality is a very rewarding experience for me personally.
Below·is a short video of my design. For some reason, when I attach the ground to the Electret mic, the LED goes HIGH for just over a second and then goes·LOW and reacts to sound. Any ideas why?
http://www.youtube.com/?v=AcivtKS9Cy8
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
Post Edited (SN96) : 12/30/2005 2:31:29 PM GMT
What happened to the 2.2K mirophone powerline resistors?
I believe your mic. is a simple FET with its gate connected to the capacitive microphone disk, and it should have a load resistor for optimal performance. You are being rather hard on it by omitting that 2.2K; the FET operates kind of as a current sink to ground, and you ought not rely on its internal resistance to limit the current. It's just not "good" design.
The positive input DOES need to be connected to a reference point such as the 2.5V orgiginally planned. The circuit as you now have it should NOT work, or at best, if the leakages are just right, operate in a rather unstable manner. Hook it up; it's "proper".
When first you connect the ground to the microphone, when all else is already powered, the 10 uF input capacitor gets a discharge kick, and that reflects through to its output, pinning the output to the rail and charging the C1 "integrating hold" capacitor and lighting the LED. Also, with the positive op amp input floating, it is difficult to analyze how the circuit will react to such large input disturbances.
Connect the positive input to the 2.5 V reference, and then see how it reacts.
Also, I would put some limiting resistor in the LED circuit; again it's just "proper".
If I were to build what you are attempting, and based on my assumption of a relatively low sensistivity requirement, I would simplify the approach considerably; I just hate putting in more circuitry than the absolute minimum......I'm kinda freaky that way.
I would simply use the 2 electret microphones and connect them to an SX input (I don't think you can do this on a Stamp input) which I would configure with a couple of resistors and a small capacitor as an A/D input. The software for such a configuration is very simple, and beside linear, you can also get logarithmic output from the algorithm; probably exactly what you want.
No external A/D needed; 2 channels all done with 2 mics, 4 resistors, and 2 small caps.
Man how I like that SX chip!
Cheers,
Peter (pjv)
The breadboard circuit·does not represent its final design. I just threw it all together last night after work just to see if I could get something to work, and to play with values to update my latest schematic. Many of the values on the latest full design were mainly guessed values as a starting references. My goal is to fine tune the circuit and then "plug-in" the actual values that work best in the schematic. It's a W.I.P. project, and I am changing things around to learn what happens along the way·with many mistakes that make me lean what I am doing.
I have not spent hardly any time experimenting with this circuit, but I plan to try several things after work today. I will try using different resistors for the mic to see what happens and also play around with the voltage reference values as well.
There are several ways to do this design I admit, but I like this design even though it might use more parts than needed because I am learning so much more going this rout.
Thanks for your input, I plan to do the things you suggested.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
Post Edited (SN96) : 12/30/2005 8:41:05 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
The +input of the op-amp should be connected to a voltage half way between the plus and minus supply rails.
Cheers,
Peter (pjv)
>>EDIT<< I found this PDF document and on page 9 it shows a almost exact setup that I am using which is why it probably works with no problems not using a Vref circuit. I'm not certain, which is why I need some help in this area.
http://www.stanford.edu/class/ee122/Handouts/Lab2.pdf#search='op%20amp%20circuit%20explained'
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
Post Edited (SN96) : 12/31/2005 2:10:59 AM GMT
Well, actually the schematic is NOT like your circuit when you leave the +input floating. But it IS the same if you terminate your +input at the 2.5 volt level.
The purpose of doing that is to give the op-amp's input a reference point, or a "virtual ground" for the junction of the input and feedback resistor at the -input.
In the document, all their examples assume a dual power supply; a positive and a (usual) equal negative one, both with respect to ground. This way the input signal can swing positive as well as negative with respect to ground. That ground is half way between the power rails, just like the 2.5 V reference is in your circuit.
Its just the way op-amps work.
Cheers,
Peter (pjv)
Also, depending on how quickly you want the circuit to respond to changes in audio level, you should experiment with the size of the caps which average the opamp outputs going to the ADC inputs. You can also put a resistor (or trimpot) in parallel with each of the caps to tune the hold time to keep the output stable and also giving the Stamp time to do other tasks. Too short of a time constant could keep a servo jittering back and forth constantly.
Rick
One example: If the left side of the head receives the strongest audio signal, I could have the code move the bot head to the left and then have the robot walk in that direction.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
There are two new problems:
1.) I need to have a wider range of values, perhaps a scale of 1 to 9 with 9 being the loudest. I need·one of you math gurus out there to figure out a way to make the output values to reflect only a 1 decimal value. I have tried to capture the output value of adc and put it in a variable so I can code an if-then-else based on a threshold of 0-9.
2.) Also, I noticed that the values begin to slow way down when there is no sound. As the values begin to lower, the rate at which the value updates in the debug window begins to slow. This is not a real problem but I would like to have consistent speed at which it reads values. If a sudden loud sound takes place, the debug window does respond with out delay, however, it takes a while for the numbers to settle back down again. I only have one mic input to channel 0 and 2.5 volts feeding into channel 1.
The two pics attached at the bottom are screenshots of actual output results. One is with sound and one is without sound.
any help is greatly appreciated!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
Post Edited (SN96) : 1/6/2006 1:59:38 AM GMT
Also, try smaller capacitors on the output of the OpAmps. This should help with "...it takes a while for the numbers to settle back down again".
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
On Dec 30 I posted a reply to you with some recommendations as to how I would go about this project, as I could see your current situation coming from a mile away.
With the circuit you proposed, you are going to produce SOME results, but FAR from the best results.
Dumping an op-amp into a capacitor and using a LED as a bleed-off path is just not kosher. Too many things are uncontrolled and up to chance.....hence SOME results. I expect that the second channel will behave rather differently as you can't readily control the actual values of components such as the capacitors, current curves of the LEDs. And that is even without taking temperature variations into account.
As Beau suggests, you need to get rid of those large charge holding capacitors behind the op-amp rectifier diodes. In fact, figure out a way (there are many ways) to get rid of the diodes. You need a logarithmic sensing algorithm here.
Let me repost the salient line from my earlier post:
"I would simply use the 2 electret microphones and connect them to an SX input (I don't think you can do this on a Stamp input) which I would configure with a couple of resistors and a small capacitor as an A/D input. The software for such a configuration is very simple, and beside linear, you can also get logarithmic output from the algorithm; probably exactly what you want."
That again is my recommendation; hopefully this time you might follow it. There are lots of examples in the Ubicom/Parallax/SXList sites to show you how to make that A/D and its software.
I don't mean to be pounding on you like this, but it pains me to see someone on a path that does not have an optimum result when the other path is so obvious. Of course, you don't have to listen to my or anyone else's advice, but I think that IS why you are asking questions on this forum.
I do commend you for at least getting somewhere and learning in the process; many are not even venturing down ANY path.
Cheers,
Peter (pjv)
Thanks Beau,
·
Peter,
I sense your frustration with me, and I know you think you are giving me recommendations and I am ignoring them and going down my own path. The truth is, I have been pulled in several directions because no matter who I talk to, each recommendation is very different, probably because there are so many ways to approach a·task. I listen to every person's recommendations and then make a decision as to what to do. Sure your idea is the simplest and perhaps the best approach, however, you your self had to start somewhere to get to that level where you know how to approach a idea you have in your mind.
I am not looking for the simplest circuit, I choose to stay this path as I have mentioned in my previous post, to learn as much as I can from this current design.
At times I feel as though I am in the middle of a tug-of-war. Person "A" saying to do ABC, and person "B" saying to do xyz. I fully respect all your advice and pounding, but the bright side is: I do listen, I do benefit, and I do learn. I went from an idea in my head to a working circuit all with only buying the "What's a microcontroller" book, and a heck of a lot of reading and research and question asking.
I'm happy with how things are turning out and I am very grateful with all the help I have received.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
Based on what Peter mentioned "You need a logarithmic sensing algorithm here" ... I seem to remember, for an ultrasonic distance measuring application
I did several years ago, that I used an Op-Amp with an inverse log gain (<-originally designed/used for RF applications). The benefit of this would be to
"linearize" the output. Simply put, the inverse log component combined with the natural log component cancels each other out leaving you with a linear
relationship. As Peter pointed out there are better ways of doing things, and a "logarithmic sensing algorithm here" might produce better results. Although
I believe Peter was talking about creating a logarithmic algorithm in software, however it can be done in hardware as well if you don't have the processing
overhead ( thus the mention of the SX processor ). I will try to find the part number for the Op-Amp that I mentioned, just in case you might be interested.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.