...I'm coming back to this; I have one last problem to solve. I am now using an AVR ATmega168 (teamed up with the BS2e through serial communication;
this will be for the complete robot). The ATmega has 6 channels of A/D @ 8 bit res, so I can do this a LOT easier now. I'm sorry to bring you all through the trouble, but I really
appreciate the support; Parallax, from what I've observed, has the best support than any other company I've dealt with! Ok, so now that I have some A/D, I'm SURE this will be
simplified greatly. I am still using the circuit listed here: http://forums.parallax.com/attachment.php?attachmentid=39948, but with a few modufications. The electrolytic cap is
actually 3.3uf, and I have a 1.5M resistor across (in parallel to) the ceramic disc capacitor so that the readings don't have to 'settle',which are actually either .01uf or .047uf (I
can't remember and I don't have a fancy multimeter to tell). This setup is not giving me good results, but I must note that I'm NOT using the 2.5V reference to the LM741. Why?
Because how in the world am I going to get 2.5V easily from a 5V regulated supply? Should I use a zener diode? This circuit is VERY insensitive; I have to clap really
loud right in front of it in order for it to register much. If I add the ref. to the op-amp, will it work a lot better? Maybe to save time for you all, I could implement one of Beau's circuits
into this design, and optimize it from A/D conversion...? I don't want to have to go out to Ratshack and buy a myriad of electronic parts and spend a lot of money again. I have about
a billion resistors, a lot of electrolytic caps (*but the values are large ~ 3.3 to 2200uf), a few ceramic disk caps, 3 LM741's, some regular diodes, and of course some electret mics.
I would like, if possible, for this circuit to be flexible - this is a robot in 'prototype' stage; I need it to be sensitive, but still be able to pick out a handclap in a room with few people carrying
out regular conversation. Thanks!
NoBo780, · "This setup is not giving me good results, but I must note that I'm NOT using the 2.5V reference to the LM741. Why?· Because how in the world am I going to get 2.5V easily from a 5V regulated supply?" · To get a 2.5V reference, you select two resistors of the SAME value, that are not going to kill your quiescent current, to form a voltage divider across your regulated 5V supply. If you want a different reference voltage you can change the resistor ratio to achieve that. · ·
You didn't list a potentiometer among the current assets, but that would be more interesting than the fixed 2.5 volts. Say, a 10kOhm potentiometer, but any potentiometer from 1kOhm up would work. Connect one end to Vdd=5 volts, the other end to Gnd, and the wiper to pin 3 (+) of the op amp. Also, put a ~100 ohm resistor in series with the indicator LED at the output, to limit current. Now, as you adjust the potentiometer (sensitivity control), you might find a sweet spot where the response to sound is best.
Great! That potentiometer idea works really good; thanks. Just in case anyone was wondering, this is going to be 'Room-Bot'. I am taking a iRobot Roomba Red, and using the BS2e and an Arduino (ATmega168) to turn it onto something else. I am working towards a 'Roo-Maid' (serves drinks, snacks, etc)....
Ok. I've been kinda busy lately, so now that I've gotten back into this, I got a third circuit going (so 3 'ears' in total now), so I can have tri-directional sound sensing. I can
theoretically get this to do poly-directional (5) sound sensing (left, left center, center, right center, right) with the right software, but this has proven to be pretty tricky.
How do I work that out?I know how how to get it to distinguish between handclaps coming from dead left and dead right, but not center and left/right-center. Just FYI,
if this helps, I am testing this on a breadboard at the moment, so the mics are spaced only ~3" apart with no fixtures to channel in the sound. They will eventually be
mounted on the actual robot, but even then, they will still only be spaced ~6" apart. Is that OK?
Here's the code. Once again, I'm sorry it's in the 'Arduino Language', but it shouldn't be too hard to interpret. And again, Parallax's forums are still unparalleled, so that's
why I'm posting here and not in the Arduino forums (well, I did, but I kinda figured posting here would be better.)
int leftmicPin = 0;
int rightmicPin = 1;
int centermicPin = 2;
int val1 = 0;
int val2 = 0;
int val3 = 0;
void setup() {
Serial.begin(9600);
}
void loop()
{
val1 = analogRead(leftmicPin);
val2 = analogRead(rightmicPin);
val3 = analogRead(centermicPin);
if(val1 > 500 || val2 > 500 || val3 > 500)
if(val1 > val2)
Serial.println("Left Detect!");
else if(val2 > val1)
Serial.println("Right Detect!");
//else if()
//Serial.println("Center Detect!");
//else if()
//Serial.println("Left Center Detect!");
//else if()
//Serial.println("Right Center Detect!");
}
I...don't quite see how that works; I don't know how to interpret that diagram. And by 'delta fixture', you mean some kind of directional cone for each mic? Please elaborate.
Thanks!
UPDATE: Ok, I figured out the code. I'm posting it below. Now I still don't quite get that diagram...
int leftmicPin = 0;
int rightmicPin = 1;
int centermicPin = 2;
int val1 = 0;
int val2 = 0;
int val3 = 0;
int maximumVal = 0;
int directionVal = 0;
void setup() {
Serial.begin(9600);
}
void loop()
{
val1 = analogRead(leftmicPin); //Read all the sound sensor outputs
val2 = analogRead(rightmicPin);
val3 = analogRead(centermicPin);
if(val3 > 500) //If the center sensor has been tiggered
maximumVal = max(val1, val2); //Find the highest value out of the left and right sensors
if(maximumVal == val1) //If the result is the left sensor, continue statement
if(maximumVal > 500) //If the sensor has been triggered, continue statement
{directionVal = val2 - val1; //Determine how far; more negative = more to the left; 0 = at absolute center
Serial.println("Left");
Serial.println(directionVal);}
if(maximumVal == val2) //If the result is the right sensor, continue statement
if(maximumVal > 500) //If the sensor has been triggered, continue statement
{directionVal = val2 - val3; //Determine how far; more positive = more to the right; 0 = at absolute center
Serial.println("Right");
Serial.println(directionVal);}
}
A 'delta fixture' would basically mean that each sensors location, if you 'connected the dots', would create an equilateral triangle or delta.
From the diagram, Sensor1 and Sensor2 would be oriented so that they are located towards the front.
To translate the three sensors into a vector direction that would fit a standard 4 quadrant Cartesian coordinate system....
Left would be Sensor1 plus half of Sensor3
Right would be Sensor2 plus half of Sensor3
Front would be 75% of Sensor1 plus Sensor2
Back would be the remaining 25% of Sensor1 and Sensor2 plus Sensor3
To translate Front, Back, Left, and Right into X and Y vector values...
X equals the Right sensor minus the Left Sensor
Y equals the Front sensor minus the Back Sensor
When this is applied X and Y should "rest" at Zero...
Any noise would create a direction (a change in X and Y) and Magnitude proportional to the volume level perceived by the three sensors.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I am sorry; I don't quite understand about 85% of that. Maybe since you may feel in the wrong position to ask this, I will get it out there? I am not in college yet; I guess you may
study '4 quadrant Cartesian coordinate system's' in a college-level math class? I am currently in Algebra II (10th grade), and I have not studied 3D graphs yet (I'm
guessing that's where the 'vector' stuff comes from? If you could take it down a notch, that would be great . I would love to use your advice to improve this design.
Thanks for the help.
I didn't mean that to sound harsh, by the way. I think I need to clarify, though. This is going to be used for detecting the position (heading) of a handclap from across the room. After
a LOT of frustration and trial and error, I now have the code right. But I need the microphones to be directional. I am now only using TWO electret mics, about 6" apart, at about a 120
degree angle. Do you have any advice for making them more directional? Thank you for your time.
You didn't sound harsh. I'm Sorry that I didn't reply sooner.... I have been out of town, and while I do have something that I was working on that I was going to show you, I haven't had the time to complete it.
The only way that I know of without mechanical interaction to make two mic elements directional is to compute the difference between them. Unfortunately doing this with two mics produces two possible results for indicating the direction. Unless your mics are directional to begin with, I'm not sure that placing them at 120 degree angles to one another will do much.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Beau Schwabe
IC Layout Engineer
Parallax, Inc.
That's what I am doing at the moment. The program calculates the difference between the two mics. It works O.K., but it's not very accurate. What do you suggest I do to increase the
accuracy? Make them 'mechanically directional'? Like, with a servo turret?
The microphones need to be designed to be directional. Most simple microphones are omnidirectional.
Look up "directional microphone" in the Wikipedia for a discussion. Unfortunately, at audible frequencies,
directional microphones usually need to be physically large to get reasonable directionality.
Another way to find the direction of an impulse sound like a handclap, is to measure the time difference between arrival at the two mics. If the sound arrives at the same time, then the source is on the bisector plane between two mics. The robot could turn toward the one where the sound arrives first. It would take three mics to tell front from back.
Electronically it takes a different kind of circuit. Instead of the analog to digital, it needs a fast comparator and timer to detect which one came first and to time the arrival at the second (and third). The time differences are on the order of 0.1 millisecond.
I know this is a very old post, but I'm interested in the circuit posted by Tracy Allen on 11/13/2007. I prototyped this on a bread board and it seems to work fine, but I had some questions.
1. The audio signal will be coming in centered at 0V DC. The op amp I'm using, an LM324, says the input voltage limit should be limited to -300mV max. Is this likely to be a problem?
2. When measuring Vout with an analog input pin and no input signal, I get a very slowly climbing voltage. Something is charging the capacitor, but what?
1) It is unlikely that the input signal from a microphone would exceed -300mV or that it would be able to supply enough current to damage the op-amp input. However, if the input comes from a preamp or line, then it could potentially cause a problem. In that case, a diode (schottky type preferrably) in parallel with the 100kohm input resistor and with the cathode at the top, signal side should provide protection.
2) The gradually increasing voltage on the capacitor could come from leakage currents that come from the inverting input of the op amp or from the input circuit of your analog to digital converter. If the analog input is floating, an increase in capacitor voltage could also be due to AC pickup at the input. The quick solution is to reset the peak detector.
Comments
this will be for the complete robot). The ATmega has 6 channels of A/D @ 8 bit res, so I can do this a LOT easier now. I'm sorry to bring you all through the trouble, but I really
appreciate the support; Parallax, from what I've observed, has the best support than any other company I've dealt with! Ok, so now that I have some A/D, I'm SURE this will be
simplified greatly. I am still using the circuit listed here: http://forums.parallax.com/attachment.php?attachmentid=39948, but with a few modufications. The electrolytic cap is
actually 3.3uf, and I have a 1.5M resistor across (in parallel to) the ceramic disc capacitor so that the readings don't have to 'settle',which are actually either .01uf or .047uf (I
can't remember and I don't have a fancy multimeter to tell). This setup is not giving me good results, but I must note that I'm NOT using the 2.5V reference to the LM741. Why?
Because how in the world am I going to get 2.5V easily from a 5V regulated supply? Should I use a zener diode? This circuit is VERY insensitive; I have to clap really
loud right in front of it in order for it to register much. If I add the ref. to the op-amp, will it work a lot better? Maybe to save time for you all, I could implement one of Beau's circuits
into this design, and optimize it from A/D conversion...? I don't want to have to go out to Ratshack and buy a myriad of electronic parts and spend a lot of money again. I have about
a billion resistors, a lot of electrolytic caps (*but the values are large ~ 3.3 to 2200uf), a few ceramic disk caps, 3 LM741's, some regular diodes, and of course some electret mics.
I would like, if possible, for this circuit to be flexible - this is a robot in 'prototype' stage; I need it to be sensitive, but still be able to pick out a handclap in a room with few people carrying
out regular conversation. Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Giggly Googley!
·
"This setup is not giving me good results, but I must note that I'm NOT using the 2.5V reference to the LM741. Why?· Because how in the world am I going to get 2.5V easily from a 5V regulated supply?"
·
To get a 2.5V reference, you select two resistors of the SAME value, that are not going to kill your quiescent current, to form a voltage divider across your regulated 5V supply.
If you want a different reference voltage you can change the resistor ratio to achieve that.
·
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Giggly Googley!
theoretically get this to do poly-directional (5) sound sensing (left, left center, center, right center, right) with the right software, but this has proven to be pretty tricky.
How do I work that out?I know how how to get it to distinguish between handclaps coming from dead left and dead right, but not center and left/right-center. Just FYI,
if this helps, I am testing this on a breadboard at the moment, so the mics are spaced only ~3" apart with no fixtures to channel in the sound. They will eventually be
mounted on the actual robot, but even then, they will still only be spaced ~6" apart. Is that OK?
Here's the code. Once again, I'm sorry it's in the 'Arduino Language', but it shouldn't be too hard to interpret. And again, Parallax's forums are still unparalleled, so that's
why I'm posting here and not in the Arduino forums (well, I did, but I kinda figured posting here would be better.)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Giggly Googley!
Post Edited (NoBo780) : 2/3/2008 10:30:06 PM GMT
You should really have the mic's spaced further apart, and some kind of delta fixture.
If you just want a simple vector approach, this should work if the sensors are orientated correctly.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Thanks!
UPDATE: Ok, I figured out the code. I'm posting it below. Now I still don't quite get that diagram...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Giggly Googley!
Post Edited (NoBo780) : 2/5/2008 1:31:14 AM GMT
A 'delta fixture' would basically mean that each sensors location, if you 'connected the dots', would create an equilateral triangle or delta.
From the diagram, Sensor1 and Sensor2 would be oriented so that they are located towards the front.
To translate the three sensors into a vector direction that would fit a standard 4 quadrant Cartesian coordinate system....
Left would be Sensor1 plus half of Sensor3
Right would be Sensor2 plus half of Sensor3
Front would be 75% of Sensor1 plus Sensor2
Back would be the remaining 25% of Sensor1 and Sensor2 plus Sensor3
To translate Front, Back, Left, and Right into X and Y vector values...
X equals the Right sensor minus the Left Sensor
Y equals the Front sensor minus the Back Sensor
When this is applied X and Y should "rest" at Zero...
Any noise would create a direction (a change in X and Y) and Magnitude proportional to the volume level perceived by the three sensors.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
study '4 quadrant Cartesian coordinate system's' in a college-level math class? I am currently in Algebra II (10th grade), and I have not studied 3D graphs yet (I'm
guessing that's where the 'vector' stuff comes from? If you could take it down a notch, that would be great . I would love to use your advice to improve this design.
Thanks for the help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Giggly Googley!
a LOT of frustration and trial and error, I now have the code right. But I need the microphones to be directional. I am now only using TWO electret mics, about 6" apart, at about a 120
degree angle. Do you have any advice for making them more directional? Thank you for your time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Giggly Googley!
You didn't sound harsh. I'm Sorry that I didn't reply sooner.... I have been out of town, and while I do have something that I was working on that I was going to show you, I haven't had the time to complete it.
The only way that I know of without mechanical interaction to make two mic elements directional is to compute the difference between them. Unfortunately doing this with two mics produces two possible results for indicating the direction. Unless your mics are directional to begin with, I'm not sure that placing them at 120 degree angles to one another will do much.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
accuracy? Make them 'mechanically directional'? Like, with a servo turret?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Giggly Googley!
"What do you suggest I do to increase the accuracy? Make them 'mechanically directional'? Like, with a servo turret?"
You would use an uni-directional microphone.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Look up "directional microphone" in the Wikipedia for a discussion. Unfortunately, at audible frequencies,
directional microphones usually need to be physically large to get reasonable directionality.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Another way to find the direction of an impulse sound like a handclap, is to measure the time difference between arrival at the two mics. If the sound arrives at the same time, then the source is on the bisector plane between two mics. The robot could turn toward the one where the sound arrives first. It would take three mics to tell front from back.
Electronically it takes a different kind of circuit. Instead of the analog to digital, it needs a fast comparator and timer to detect which one came first and to time the arrival at the second (and third). The time differences are on the order of 0.1 millisecond.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Giggly Googley!
1. The audio signal will be coming in centered at 0V DC. The op amp I'm using, an LM324, says the input voltage limit should be limited to -300mV max. Is this likely to be a problem?
2. When measuring Vout with an analog input pin and no input signal, I get a very slowly climbing voltage. Something is charging the capacitor, but what?
1) It is unlikely that the input signal from a microphone would exceed -300mV or that it would be able to supply enough current to damage the op-amp input. However, if the input comes from a preamp or line, then it could potentially cause a problem. In that case, a diode (schottky type preferrably) in parallel with the 100kohm input resistor and with the cathode at the top, signal side should provide protection.
2) The gradually increasing voltage on the capacitor could come from leakage currents that come from the inverting input of the op amp or from the input circuit of your analog to digital converter. If the analog input is floating, an increase in capacitor voltage could also be due to AC pickup at the input. The quick solution is to reset the peak detector.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com