You Are Here: Home » AVR ATmega Projects » Sensor - Transducer - Detector Projects » Acoustic Impulse Marker Using Atmega1284

Acoustic Impulse Marker Using Atmega1284


“A device that tracks sound impluses with a three microphone array”

We designed and build a 2-dimentional Acoustic Impulse Marker system which is capable of detecting a sharp sound anywhere in its vicinity and precisely marking its source vector with a servo based pointer. Our system has a full 360 degree range, and is extremely effective at marking the source of sharp sounds to within 5 degrees of accuracy. We were able to accomplish this using a 3-microphone array and an ATmega1284p microcontroller which detects the acoustic delays between the microphones and calculates the sound’s source vector. The microphone signals are passed through an 8 stage analog system in order to convert them to a binary signal, indicating when each of them is triggered by a sound. Those 3 binary signals are analyzed for their time delays and the microcontroller selects the best 2 microphones to calculate the exact angle in which the sound originated from. The servo motor is then controlled so that it turns a pointer exactly in that direction.

Acoustic Impulse Marker Using Atmega1284



We wanted to explore the idea of microphone localization based on time delays. The speed of sound in air is roughly 340m/s, which is slow enough to measure time delays between offset microphones using a microcontroller. We measured these time delays across 3 microphones and used basic trigonometry to calculate the angle from which the sound originated from. In order to visually mark the source of the sound, our system controls a centrally mounted servo motor which spins a pointer to the acoustic source.

Background Math

All calculations use the SI units of meters, seconds, and degrees Celcius. All angles however, are measured in degrees.

Speed of sound in Air:

V = 331.3 + (0.606*T)

The speed of sound in air is approximated by this linear formula, directly proportional to the ambient air temperature.

Angle Calculation:

Theta = (180/pi) * arcsin((delay *speed_sound) / mic_distance )

Using the fixed values for “speed_sound” and “mic_distance”, we can use the sound delay time in this formula to calculate the relative angle as a value between 0 and 90 for two specific microphones.

Servo Control:

OCR0A = round(((degree*(servo_max – servo_min) / 180) + servo_min) * 62500) – 1

Using the calibrated pulse widths for “servo_max” and “servo_min”, we can input any desired degree between 0 and 180 to generate the corresponding value for the timer compare match register, which will set the duration of the servo control pulse.

Logic structure

Each microphone is processed though a precise analog circuit to convert it to. This binary signal represents the state of each microphone, either triggered by a sound pulse or not.

Once the microphones are interpreted as binary states, those values are read as inputs by the microcontroller. These inputs control a state machine, which requires all 3 microphones to start in the OFF state and then trigger in succession within an appropriate amount of time to accept it as a valid pulse. When a valid sound pulse is acquired, all the timing values are stored as variables and a variable flag is set high to indicate that the data should be processed to calculate the source angle.

During the calculation, the system determines which pair of microphones lies most perpendicular to the sound source. This gives us the most accurate calculation possible. Then the time delays between those microphones are used to compute the sound source angle relative to those two microphones.

Finally, the relative angle is converted into an absolute angle between 0 and 360 degrees around the entire system. This absolute angle is converted into a calibrated PWM signal, which is passed as an output directly to the servo motor. The servo motor moves to the angle corresponding to its signal, and thereby points in the exact direction that the sound pulse originated from.

Hardware/Software tradeoffs

The core of our system is hardware based analog circuit, which filters, amplifies, and processes the sounds obtained from the microphones. By utilizing hardware for this, we are able to high frequency signal processing without taxing the microcontroller. Also, we remove the need to use the relatively slow ADC of the microcontroller by processing all the analog signals in hardware and converting them to binary digital pulses. However, the main tradeoff here is that the analog hardware limited our accuracy in a way that is very difficult to measure. Every stage of the circuit has real world inefficiencies and tolerances, which could accumulate in minute error. No matter how fast or thorough our software system is, it can only work with the values received from the analog hardware.

The software system is a great tool for logical processing and control signals. All of our computation and servo control is done on the microcontroller in software. This gives us a fixed limit for speed, precision, and memory. However, the benefits of the software include very high reliability (excluding any designer coding errors), and very well defined constraints on speed, precision, and memory which allows us to analyze the performance capabilities of our software system accurately.

Standards and Patents

Our project is not based on any major standards from IEEE, ISO, or any others. However, the system we are designing is truly a method and apparatus for sound source direction detection. There are many patents in the realm of sound localization ranging from military applications, signal processing algorithms, and even consumer products such as videoconferencing and gaming systems. We developed this system independent from any published work on this topic, but we realize that we are not the first to develop such a system.


Mechanical Design

The physical system we designed contains a wooden base for mounting the servo and electronic hardware, with an elevated platform to hold the 3 microphones directly above the center of the base. The physical structure was made using only wood, L-brackets, and screws.

A 62-tooth gear was directly mounted to the servo. A ¼” x 3” aluminum shaft is held upright using 2 horizontal ball-bearing mounts separated by 1” standoffs. The ball bearing mounts are mounted exactly in the center of the wooden base using hot glue, and a 32-tooth gear is mounted to the aluminum shaft after it is inserted into the bearing mounts. The servo is then glued to the base as well, so that its gear perfectly aligns with the gear on the shaft. This gear arrangement gives us a 2:1 ratio, and allows us to spin the shaft a full 360 degrees by using a servo which only spins 180 degrees. The shaft serves as our primary position indicator, and it spins to the absolute position desired by our system.

The microphones are mounted 1 foot above the center of the base, by using 2 wooden beams in an L-shape. All three microphones are mounted on a thin wooden square, at the corners of an equilateral triangle with 14cm sides. The triangle is perfectly centered above the wooden base, and also the aluminum shaft. The microphones are mounted using hot glue, and they are wired down the wooden beams to neatly plug into the electrical hardware on the lower base.

The signal processing on the microphones was one of the more challenging aspects of the project. The microphone signal went through the following stages:

1.       Initial biased microphone

2.       Low pass filter with a cutoff at 500Hz

3.       High pass filter with a cutoff at 100Hz

4.       Non-inverting amplifier with gain of 100

5.       Non-inverting amplifier with gain of 2.5-5, tunable with a potentiometer

6.       High pass filter with a cutoff at 100Hz

7.       Peak detect circuit

8.       Schmitt Trigger

These stages were used to transform a microphone signal into a digital signal for the microcontroller. The microphone is biased with a 2kΩ resistor to a 5V line. This microphone signal is then passed through a low pass and a high pass filter to create a passive bandpass. This bandpass allows signals between 100Hz and 500Hz, which are the primary frequencies of human speech. This filtered signal is passed through a bandpass with a gain of 100 to amplify it to a reasonable range. It is then amplified again, but with much smaller gain. This second gain stage has two purposes. First, it allows us to have a large gain without approaching the bandwidth of the LM358 op-amps. Second, it allows us to tune the final amplification of the system. This is important when trying to keep three microphones systems identical. Since all of our resistors are only accurate within our tolerances, and we are not using extremely high quality op-amps, different circuits with the same design can respond differently, even when given the same microphone signal. We tuned these gain stages with a differential op-amp circuit. A pair of circuits would be connected to the same microphone. The output of the two gain stages was then put through a differential op-amp. By tuning the potentiometers, we were able to get the differential output as close to zero as possible. We then changed the pair of microphones in use to tune the third microphone to be identical to the first two tested.

Acoustic Impulse Marker Using Atmega1284 block diagram

After the gain stage, the signal went through another high pass filter to remove the DC offset. This was followed by a peak detect circuit. This circuit would charge a capacitor when the voltage was high, and discharge through a resistor when the voltage was low. We found that tuning these capacitors and resistors was a challenge. The relationship between size of the capacitor and resistor was the key issue. If the capacitor was comparatively too small the peak detect circuit would discharge too quickly, and would not provide meaningful peaks. If the capacitor was comparatively too large, the peak detect circuit would not rise fast enough.

This rise time became a key issue in testing the Schmitt trigger. The inverting Schmitt trigger was set to trigger low at 100mV and back high at 10mV. In order for this value to be useful, the three circuits need to have extremely similar rise times. All of the timing calculations are based upon the moment that the Schmitt trigger goes low. Since the circuits have slight differences, signals with extremely fast rise times work much better than signals we slower rise times. Because of this behavior, the system responds well to the snapping of fingers, claps, and other sounds that produce impulse-like waveforms.

Parts List:

Parts List and Costs

ComponentVendorPart #Unit CostQuantityNet Cost
Solderless Bread BoardLab Supplyn/a$6.001$6.00
Solder BoardLab Supplyn/a$2.501$2.50
DC Power SupplyLab Supplyn/a$5.002$10.00
Mega1284Lab Supplyn/a$5.001$5.00
Custom PCB BoardLab Supplyn/a$4.001$4.00
Header PinsLab Supplyn/a$0.0548$2.40
1K resistorLab Supplyn/a$ –6$ –
2K resistorLab Supplyn/a$ –3$ –
5K resistorLab Supplyn/a$ –3$ –
10K resistorLab Supplyn/a$ –3$ –
30K resistorLab Supplyn/a$ –3$ –
100K resistorLab Supplyn/a$ –3$ –
150K resistorLab Supplyn/a$ –6$ –
300K resistorLab Supplyn/a$ –3$ –
560K resistorLab Supplyn/a$ –3$ –
3M resistorLab Supplyn/a$ –3$ –
1N4004 DiodeLab Supplyn/a$ –6$ –
10nF capacitorLab Supplyn/a$ –12$ –
20nF capacitorLab Supplyn/a$ –6$ –
33uF capacitorLab Supplyn/a$ –1$ –
1K potentiometerLab Supplyn/a$ –3$ –
LM358 Op AmpLab Supplyn/a$ –6$ –
WireLab Supplyn/a$ –n/a$ –
1/4″ Bearing MountServoCity535110$5.992$11.98
1″ Aluminum StandoffsServoCity534-3489$0.704$2.80
1/4″ x 3″ ShaftServoCity634162$1.191$1.19
64 Tooth Servo GearServoCityRSA32-2HS-64$6.841$6.84
32 Tooth Bore GearServoCitySPBD32-34-32$2.361$2.36
Machine ScrewsServoCity90272A144$0.058$0.40
FET MicorphonesDigiKey102-1728-ND$1.833$5.49
Hitec ServoSparkfunHS-425BB$12.951$12.95
1×2 Pine BoardHome Depotn/a$3.581$3.58
L-Bracket 4-PackHome Depotn/a$2.271$2.27
Zinc Wood Screws PackHome Depotn/a$1.181$1.18
Round Pine BaseHome Depotn/a$4.881$4.88


For more detail: Acoustic Impulse Marker Using Atmega1284

Leave a Comment

You must be logged in to post a comment.

Read previous post:
Massive open online courses haven’t lived up to the hopes and the hype, professors say

Three years after a groundswell of online learning swept through higher education, Stanford researchers who were at the forefront of...

Scroll to top