URGENT: Project Sound Camera (Need Guidance)

Hello,

i am doing a electronics project, i am to build a sound camera to map the sound reflections. For that i am using arduino. I dont have much knowledge about arduino so would like all the help you can provide.

The arduino will be used for three main functions. Controlling a pan and tilt mount using DC motors with encoders to track position.

Second is to generate sound between the frequencies of 30Hz to 20KHz.

Third is to use a microphone to capture the reflections of the sound and store them in a tabular form (for each position store multiple frequencies reflection)

I am able to control the pan and tilt using an H-Bridge and two DC motors, the issue starts with the sound generation. I have read a few threads but couldnt find the frequency limit arduino uno will go to.

Secondly, can anyone suggest how i would go around tackling the third problem. The sound captured by the mic will be analog so
(a) can it be fed directly to the microcontroller or does it need an amplifier circuit in between,
(b) can it be fed directly to the computer via a sound card and arduino used to communicate with the computer to store the results.

all and any help is appreciated.

thanks

P.S. i apologise if this thread is in the wrong section, if thats true, can a MOD move it to the appropriate section. Thanks.

I really don't understand what this thing is supposed to do....

Second is to generate sound between the frequencies of 30Hz to 20KHz.

That should be no problem if you can use square waves. But, generating continuous sounds while receiving continuous sounds, while "processing" the data & running the pan & tilt could get tricky. Normally with a computer, you have input & output buffers so the streaming audio can flow smoothly in & out while the processor reads & writes in quick bursts. That would be tricky with the Arduino without adding a lot of additional hardware.

30Hz to 20KHz

The "average" mic does not have flat frequency response across the audio range. You may need a high-end or "instrumentation" microphone. Speakers are even worse! If that's important, it could be a major issue. To some extent you can calibrate for it, but it's going to be difficult.

Secondly, can anyone suggest how i would go around tackling the third problem. The sound captured by the mic will be analog so
(a) can it be fed directly to the microcontroller or does it need an amplifier circuit in between,

It needs to be amplified and biased. A microphone puts-out a few millivolts (depending on the sensitivity of the mic and the loudness of the sound). The Arduino's ADC has a 0-1V range and a 0-5V range. So, typically you need a gain of around 100 (40dB) but microphone preamps always have a gain control.

A normal audio signal (and the signal from a mic) is AC... It goes positive & negative, and you can't put a negative voltage into the Arduino, so it has to be biased. Or, in some cases you can "chop-off" the negative half of the waveform. (You can get a [u]circuit board[/u] that has a microphone, an amplifier, and a 2.5V biased output.)

(b) can it be fed directly to the computer via a sound card and arduino used to communicate with the computer to store the results.

That should be possible. If you are going to us a the computer, I'd use the computer for all of the sound functions, and the Arduino for the pan & tilt.

I am able to control the pan and tilt using an H-Bridge and two DC motors...

You'll probably want servo motors if the computer/microcontroller needs to control or "know" the angles. Pan & tilt is "always" done with servos. (A servo motor has the driver circuit built-in, so you don't need the bridge... You just provide power and a timed-pulse to set the angle.)

Doug thanks for the, i didnt check back as i didnt see any replies and thought no one was replying to this thread.

  1. The sound camera will be used to map an area by capturing sound reflections form different surfaces. This sound data combined with the angle of the pan and tilt will be used to determine where in the area the worst reflections are coming from and eliminate them.

  2. I am using the atmega328, how do i go about generating frequencies between the 30Hz and 20Khz range. I can produce sound using the tone() function. I read this Google Code Archive - Long-term storage for Google Code Project Hosting.. The "ugly details" part made some sense but the timers always confuse me.

  3. I am using an AT4071A microphone. Therefore i cant use any other microphones. The mic output should be amplified and biased (using a full bridge rectifier) and then fed into the arduino. Alternatively, can you give a brief description as to how can i use the computer for the sound functions.

  4. Thanks for the suggestion of using servos. I ditched the idea of DC motors and upon further search found a pan and tilt mount which can works with servo motors. Below is my current code, but i want one servo to stay at a certain tilt angle and the other servo to do a sweep with a tone from the speaker at each angle of the sweep before the system moves to a new tilt angle.
    For example the 'tilt' servo starts from 25 degree angle and stays there while the 'pan' servo moves from -45 to +45 degrees with intervals of 5 degrees. After each 5 degree pan the speaker produces a sound and the mic captures the sound, and the data (angles, sound frequency, and mic input) recorded to a file. I was thinking if array should be used for the pan and tilt function or is there another method

#include <Servo.h>

Servo myservo1;
Servo myservo2;

int speakerPin = 7;
 
int tones[] = {261, 277, 294, 311, 330, 349, 370, 392, 415, 440};
//            mid C  C#   D    D#   E    F    F#   G    G#   A

void setup()
{
  myservo1.attach(9);
  myservo2.attach(10);
}

 void loop()
{
myservo1.writeMicroseconds(600);
delay(1000);
myservo2.writeMicroseconds(600);
delay(1000);
tone(speakerPin, tones[0]);
delay(250);
noTone(speakerPin);
delay(1000);

myservo1.writeMicroseconds(1500);
delay(1000);
myservo2.writeMicroseconds(1500);
delay(1000);
tone(speakerPin, tones[1]);
delay(250);
noTone(speakerPin);
delay(1000);

myservo1.writeMicroseconds(2400);
delay(1000);
myservo2.writeMicroseconds(2400);
delay(1000);
tone(speakerPin, tones[2]);
delay(250);
noTone(speakerPin);
delay(1000);

myservo1.writeMicroseconds(1500);
delay(1000);
myservo2.writeMicroseconds(1500);
delay(1000);
tone(speakerPin, tones[3]);
delay(250);
noTone(speakerPin);
delay(1000);


myservo1.writeMicroseconds(600);
delay(1000);
myservo2.writeMicroseconds(600);
delay(1000);
tone(speakerPin, tones[4]);
delay(250);
noTone(speakerPin);
delay(1000);
}

(This new thread has been added to my previous thread)

  1. i have written this code to move a pan and tilt mount and use a speaker to produce sound
#include <Servo.h>

Servo myservo1;
Servo myservo2;

int speakerPin = 7;
 
int numTones = 10;

int tones[] = {261, 277, 294, 311, 330, 349, 370, 392, 415, 440};
//            mid C  C#   D    D#   E    F    F#   G    G#   A

void setup()
{
  myservo1.attach(9);
  myservo2.attach(10);
}

 void loop()
 
{
  for (int i = 0; i < numTones; i++)
  {
    for (int motorTilt = 600; motorTilt < 2500; motorTilt+=900)
    {
      for (int motorPan = 600; motorPan < 2500; motorPan+=900)
      {
        myservo1.write(motorTilt);
        delay(1000);
        myservo2.write(motorPan);
        delay(1000);
        tone(speakerPin, tones[i]);
        delay(250);
        noTone(speakerPin);
        delay(1000);
      }
    }
  }
}

the increments will be changed during the final stages of the code when the pan and tilt mount is fully assembles to define the angle limitations on the mount. Apart form that any improvements on the code are welcome.

  1. I want to know how i can produce higher frequencies, my project requires me to produce frequencies between 200 Hz to 8 KHz. Lower frequencies are not a problem but producing higher frequencies eludes me.

  2. i would be using a professional recording mic to capture sound, the signal will be put through an amp which has the ability to provide phantom power and also bias the signal. I would be using a rectifier to convert the signal. My question for this part is can i provide input to an analog pin on arduino and record the voltage or not.

  3. i would like to record the position of my servo motors, the frequency produced by the speaker and the voltage input from the mic in a text file as well as on the EEPROM memory. How should i go around this task.

I started a thread in the audio section of the forums but i have received only one response in two months which did not help me much, therefore i am creating a thread in this section. I have more questions but these four are the highest priority. All help is appreciated.

Thanks

Third is to use a microphone to capture the reflections of the sound and store them in a tabular form (for each position store multiple frequencies reflection)

May I ask what for? Is it some kind test of reflectivity or sound absorption?
I hope you know that 30 Hz freq. in the air has wavelength about 11 m, so reflective area must be at least of this size. 200 Hz is less demanding, but still I don't think pant and tilt approach is going to work with flat surface like a wall, as reflected wave according to laws of optic go anywhere but back, except wave falling 90 degree (perpendicular) to the surface.

Magician:

Third is to use a microphone to capture the reflections of the sound and store them in a tabular form (for each position store multiple frequencies reflection)

May I ask what for? Is it some kind test of reflectivity or sound absorption?
I hope you know that 30 Hz freq. in the air has wavelength about 11 m, so reflective area must be at least of this size. 200 Hz is less demanding, but still I don't think pant and tilt approach is going to work with flat surface like a wall, as reflected wave according to laws of optic go anywhere but back, except wave falling 90 degree (perpendicular) to the surface.

yes, the project given to me was to design such a device as to capture sound reflection. I agree the approach is flawed but i think they just want to see what i have learnt rather than the project actually working to its full potential. My supervisor told me that my project will form the basis for future Masters projects.

I would be using this device to determine sound reflections in a room so hopefully will get some results. According to the polar diagram in the spec sheet, the mic gives a good response on higher frequencies.

What would you suggest?

I don't think you can get any meaningful results in a room, multipath reflection would create reverberation, and magnitude of the reflected wave would much more depends on position of a speaker and mic than the properties of the surface. Better to measure in open space.

Magician:
I don't think you can get any meaningful results in a room, multipath reflection would create reverberation, and magnitude of the reflected wave would much more depends on position of a speaker and mic than the properties of the surface. Better to measure in open space.

so if the speaker and mic are facing the same direction, the reflected wave would have higher magnitude? its a highly directional mic so it cancels out a majority of reverberated waves.

ts a highly directional mic so it cancels out a majority of reverberated waves.

Directional mic isn't a panacea. Because two or more waves sumed up before they get into a mic. Imagine rectangular room, than sound reflected from one wall is gonna to be reflected at least from one another - opposite wall, and interfere with initial source, I think they called it standing waves. Depends on geometry - wave length (freq.) and room size waves summed up in phase or in antiphase. It also would depends on the distance between a speaker and the wall it's facing. You can do a simple test, running single tone sound from your PC speakers and moving a mic . Sure you would discover interesting diffraction pattern, more complex - 3D, than you can see on a water surface 2D. To complicate everything , your own body position in the room would change a pattern.

Magician:

ts a highly directional mic so it cancels out a majority of reverberated waves.

Directional mic isn't a panacea. Because two or more waves sumed up before they get into a mic. Imagine rectangular room, than sound reflected from one wall is gonna to be reflected at least from one another - opposite wall, and interfere with initial source, I think they called it standing waves. Depends on geometry - wave length (freq.) and room size waves summed up in phase or in antiphase. It also would depends on the distance between a speaker and the wall it's facing. You can do a simple test, running single tone sound from your PC speakers and moving a mic . Sure you would discover interesting diffraction pattern, more complex - 3D, than you can see on a water surface 2D. To complicate everything , your own body position in the room would change a pattern.

Like i said earlier, my project is the basis for further development, so my professor is more interested in getting something built that can be improved on in future. Probably make the device handheld so readings can be taken perpendicularly. If you can help with the four tasks, i would be really grateful.

O'K, it looks to me your project similar for those:

except you want to use an audio freq. range.
Anyway, here is couple links how to generate sound with arduino and connect to a mic:
http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/
http://interface.khm.de/index.php/lab/experiments/arduino-realtime-audio-processing/
You also 'd need an audio amplifier to drive your speaker, or you can use USB PC speakers. Depends on size and weight of the speaker you than choose appropriate servo motors, or you can find pan & tilt already made kit.
Example: http://www.seeedstudio.com/depot/s/Pan%2Band%2BTilt%2Bkit.html?search_in_description=0
To store data, also there are many SD card shield exist, what you can buy or find on-line tutorial how to build.
In overall your project looks 4x more complicated compare to "average" , and not advisable for beginning. It would make sense to build 4 separate projects, test them, and as a last step integrate all in one complex system.

Magician:
O'K, it looks to me your project similar for those:
http://www.instructables.com/id/Introduction-14/
(DOC) Arduino based Ultrasonic RADAR system | Anuj Dutt - Academia.edu
Ultrasonic Rangefinder As Scanning Radar | Hackaday
except you want to use an audio freq. range.
Anyway, here is couple links how to generate sound with arduino and connect to a mic:
http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/
http://interface.khm.de/index.php/lab/experiments/arduino-realtime-audio-processing/
You also 'd need an audio amplifier to drive your speaker, or you can use USB PC speakers. Depends on size and weight of the speaker you than choose appropriate servo motors, or you can find pan & tilt already made kit.
Example: http://www.seeedstudio.com/depot/s/Pan%2Band%2BTilt%2Bkit.html?search_in_description=0
To store data, also there are many SD card shield exist, what you can buy or find on-line tutorial how to build.
In overall your project looks 4x more complicated compare to "average" , and not advisable for beginning. It would make sense to build 4 separate projects, test them, and as a last step integrate all in one complex system.

thanks for the link, a few questions though.

  1. arduino generates square wave rather than sine wave, cant square wave be used for the purpose of this project.

  2. i dont know if i would call my setup as realtime audio processing. I want it to produce sound of a certain frequency, then go quiet while the mic picks up the reflection, save the servo positions, the frequency generated and the voltage generated by the mic.

  3. for the above process, do i need to get an SD card sheild or the EEPROM memory is big enough. Can i connect the setup to a computer/laptop and display this information on the serial monitor. And save the serial monitor output to a file?

  1. arduino generates square wave rather than sine wave, cant square wave be used for the purpose of this project.

  2. i dont know if i would call my setup as realtime audio processing. I want it to produce sound of a certain frequency, then go quiet while the mic picks up the reflection, save the servo positions, the frequency generated and the voltage generated by the mic.

  3. for the above process, do i need to get an SD card sheild or the EEPROM memory is big enough. Can i connect the setup to a computer/laptop and display this information on the serial monitor. And save the serial monitor output to a file?

  1. I still have a very little comprehension of the purpose of the project. Looks like you need to build something , for report or marks, w/o meaningful physical concept behind it. If the objective to show your ability to design , assembly, and program , that it may pass. If you really need to measure reflectivity/absorption at specific frequency than you can't use square wave, simply because it's composed of multiple freq., and measurements would have even less sense .
  2. To measure echo, they transmit 8-10 periods of ultrasound wave. Minimum measurable distance defined by this value, as transmition has to be completed before you get echo back: T = 1 / F ; 1 / 40 kHz = 25 usec ; 8 periods = 25 us x 8 = 200 usec.
    Sound pass in the air distance: 330 m/s x 200 usec = 0.066 metres, or 6.6 cm. Dividing by 2 ( go forth and back) minimum measurable distance is 3.3 cm.
    Now, if you move down freq. you have 33 cm at 4 kHz, and 3.3 m at 400 Hz, 33 metres at 40 Hz. Plus, as I already mention, reflective surface has to be at least the size of falling sound wave.
  3. All depends on the ammount of data. EEPROM size of the UNO 1 k. So you may store 20 - 20.000 audio range with 20 Hz spacing.

Magician:

  1. arduino generates square wave rather than sine wave, cant square wave be used for the purpose of this project.

  2. i dont know if i would call my setup as realtime audio processing. I want it to produce sound of a certain frequency, then go quiet while the mic picks up the reflection, save the servo positions, the frequency generated and the voltage generated by the mic.

  3. for the above process, do i need to get an SD card sheild or the EEPROM memory is big enough. Can i connect the setup to a computer/laptop and display this information on the serial monitor. And save the serial monitor output to a file?

  1. I still have a very little comprehension of the purpose of the project. Looks like you need to build something , for report or marks, w/o meaningful physical concept behind it. If the objective to show your ability to design , assembly, and program , that it may pass. If you really need to measure reflectivity/absorption at specific frequency than you can't use square wave, simply because it's composed of multiple freq., and measurements would have even less sense .
  2. To measure echo, they transmit 8-10 periods of ultrasound wave. Minimum measurable distance defined by this value, as transmition has to be completed before you get echo back: T = 1 / F ; 1 / 40 kHz = 25 usec ; 8 periods = 25 us x 8 = 200 usec.
    Sound pass in the air distance: 330 m/s x 200 usec = 0.066 metres, or 6.6 cm. Dividing by 2 ( go forth and back) minimum measurable distance is 3.3 cm.
    Now, if you move down freq. you have 33 cm at 4 kHz, and 3.3 m at 400 Hz, 33 metres at 40 Hz. Plus, as I already mention, reflective surface has to be at least the size of falling sound wave.
  3. All depends on the ammount of data. EEPROM size of the UNO 1 k. So you may store 20 - 20.000 audio range with 20 Hz spacing.

thanks for clearing up things for me, this means i have to choose the frequencies which produce the best result within the mic's frequency bracket, which is at higher frequencies. I am thinking frequencies between 1 KHz to 12-14 KHz.

You have been very helpful, actually the only person who has stuck around to help me for this long. I am very thankful. I will bother you more if i get stuck. Thanks again.

So you may store 20 - 20.000 audio range with 20 Hz spacing.

. . . though to record at 20kHz, you'll have to sample at at least 40kHz.

Quote
So you may store 20 - 20.000 audio range with 20 Hz spacing.
. . . though to record at 20kHz, you'll have to sample at at least 40kHz.

Not exactly. Well known theorem states that sampling 2x relatively to Bandwidth. With single tone sine wave , when bandwidth narrow, nothing restrict to do undersampling, 1-2 ksps for 20 kHz audio wave. Though, in this particular case, if OP choose a "burst" method of measurements: transmit - wait echo - receive , I 'd suggest to sample as fast as possible., to get better SNR ratio.

Magician:

  1. I still have a very little comprehension of the purpose of the project. Looks like you need to build something , for report or marks, w/o meaningful physical concept behind it. If the objective to show your ability to design , assembly, and program , that it may pass. If you really need to measure reflectivity/absorption at specific frequency than you can't use square wave, simply because it's composed of multiple freq., and measurements would have even less sense .

I should have asked this before but

  1. The sound generated doesn't have to be biased and smoothed. It can be a simple sine wave. The DDS method seemed too complicated as i am not a very good at coding but i found this http://www.instructables.com/id/Arduino-Audio-Output/#step0. Is this a better approach.

  2. edit found the answer to this question :D.