EECS200 Homework 10 Adrian Corrales
1. Vague description.
The robot requires an audio processor which can compute the audio it is taking in
as an input, and further categorize the noises it's taking in. It then needs to report this to
the BBB.
2. More detailed description.
The desired audio processor must be compatible with the specs required by a
beagle bone and must be able to be powered by the central battery. It must synthesize
all of these things on its own before reporting elsewhere. Once that is done it should be
able to categorize the sound into different subsections such as “human voices” or “robot
motor. ” Using these categories it should be able to focus on the human voices and
collaborate with the sensors to find the robot's distance from the source of the sound.
After computing all this the robot must report its findings to the BBB in an accessible
interface which can be deciphered by the coders and used to debug/perfect parameters.
3. Overall required performance specs
The required performance specifications consist of four things. The first of which
being the limitation on how much power is needed to power the audio processor itself,
this means it must be able to function within the limitations of the current power supply
of the robot.
The second thing is it must be compatible with the BeagleBone itself, the data it
synthesizes and computes must be legible to the beaglebone so that it can be filtered
into the important information the robot will act upon.
The third thing it must be able to recognize noise from as far as 2 meters away,
this is because this is how far the sensors pick up, otherwise the robot may not be able
to compute a human in its surroundings. And within an angle of 10 degrees +/- from the
sensor
It must be able to amplify the output so as to minimize the noise and its effect on
the data, as well as categorize the data based on set frequencies. For example 90-255
Hz noises are categorized as humans while higher frequencies between 2 and 10 kHz
are categorized as the motors whirring. In the case of a disaster scenario the robot will
simply categorize it in the given categories, it is most likely not in the frequencies of a
human voice.
4. Possible technology choices (for each piece of your sub-system)
Here is one choice for Possible tech, this is prebuilt and includes a microphone
which goes to an amplifier, another choice is this Choice two another microphone which
ranges from 20Hz to 20 kHz. This is great for our parameters we have set. These
choices were made by observing available microphones and components in the market.
I observed which ones detect the ranges necessary for the robot to best function.
For signal Processing arduino is a reliable option since it's already being used by
the robot. We can apply code that is currently in use for other devices to ensure the
devices efficiency.
5. Technology and components chosen, with relevant performance specs
I will choose option one even though it's a little expensive it already has the best
components which synergize together. The specific components are a CMA-4544PF-W
microphone, the LM393 Op-amp, W104 13 potentiometer and resistors. It takes in from
the 20 Hz frequency to 20kHz. It has a fixed gain of 20dB it can take in 3.3 or 5V to
power it.
6. Overall design, with 5 or so "parts", including diagram of how connected, showing
interface with BBB.
The sensor at its position will calculate how far the sound is what angle its located at
and what type of noise it is, this will be sent to the BBB
7. Mechanical connections to the robot and each other, as needed
Mounting Brackets that do not disturb the sensor and camera that are already a
part of the robot.
8. Electrical connections to the robot and each other. Power and comms.
2 cables going from the arduino to the BBB now that the data has been
compiled.
2 cables running the sensor to the batteries so as to power the sensor
adequately.
The electrical connections between the robot and itself remain mostly
unchanged, with the small exceptions being making room for the microphone itself and
its circuitry.
9. What data the robot reads from the subsystem, how often.
The robot reads in the analog data from the robot until the user ends running the
coded program. It will read in the data every second, categorizing it and outputting it into
the command terminal as did the heat output in the thermal detecting lab.
HMW 11
LAB 9: Audio Sensing
Experiment 0: Assemble the microphone and robot system.
Attach the unit given to the robot on all the points indicated by the drawing
outlined in HW 10. Make sure the Arduino and BBB are off.
Begin by screwing the circuit to the robot and connecting the cables from the
circuit to the arduino and from the circuit to the battery.
Experiment 1: Calibrate Microphones and verify their usage
The three pins that can be found are
VCC 3V Power Supply
GND Power Ground
DO Digital Output
AO Analog Output
For the purposes of this experiment we will only need the analog output as the
digital output can be ignored.
Open the arduino software and ensure its connection to the robot. Download the
necessary files and copy and paste the following code:
const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
int const AMP_PIN = A0; // Preamp output pin connected to A0
unsigned int sample;
void setup()
{
[Link](9600);
}
void loop()
{
unsigned long startMillis = millis(); // Start of sample window
unsigned int peakToPeak = 0; // peak-to-peak level
unsigned int signalMax = 0;
unsigned int signalMin = 1024;
// collect data for 50 mS and then plot data
while (millis() - startMillis < sampleWindow)
{
sample = analogRead(AMP_PIN);
if (sample < 1024) // toss out spurious readings
{
if (sample > signalMax)
{
signalMax = sample; // save just the max levels
}
else if (sample < signalMin)
{
signalMin = sample; // save just the min levels
}
}
}
peakToPeak = signalMax - signalMin; // max - min = peak-peak amplitude
[Link](peakToPeak);
//double volts = (peakToPeak * 5.0) / 1024; // convert to volts
//[Link](volts);
}
Verify the code on arduino and run it on the beagle bone
Make a noise a verify its frequency with the noise measurement device
Device Hz Microphone Hz
Experiment 2 Calculate distance:
Use the equation distance = Pulse Width * 0.0001657 .
Pulse width being the output that comes from the first experiment..
Measured Dist Robot Distance
Experiment 3 Classify the Sound type:
To be able to organize frequencies into categories the robot must be able to filter
certain frequencies into certain values.
Using this code we will set a sound alarm which will categorize the noise as loud or
quiet using this we can further categorize the sound.
# define CONSTANT 500
setup() {
int var = CONSTANT;
}
loop() {}
//Define Microphone 1
//
int soundDetectValOne = HIGH; // This is where we record our Sound
Measurement
boolean bAlarmOne = false;
unsigned long lastSoundDetectTimeOne; // Record the time that we measured a
sound
int soundAlarmTime = 500; // Number of milli seconds to keep the sound alarm
high
void setup() {
// put your setup code here, to run once:
[Link](9600);
[Link]("Our experiment starts ....");
for (int i = 0; i < numberOfMicrophones; i++) { /// Moved the int classification
for i into this condition declaration, and the i++ is a compound opperator that
means the same thing as "i = i+1" (not a massive deal, but improves code
efficiency)
pinMode(microphoneArray*, INPUT); //input from each microphone*
}*
[Link]("all mics are set up now.");*
[Link]();*
}
void loop() {
// put your main code here, to run repeatedly:*
/// To address potential issue of previous script,will try to run different loops for
each mic.*
/// I noticed this is how other people doing triangulation with microphones
chose to operate as well.*
/// I'm not sure how this will affect your application because timing will be very
slightly off (keeping in mind arduino runs millions of instructions/sec)...*
soundDetectValOne = digitalRead(microphoneArray[1]); //read the sound alarm
time mic 1*
//----------------------------------------------------------------------------------*
if (soundDetectValOne == LOW) { // If we hear a sound*
lastSoundDetectTimeOne = millis();*
// The following is so you don't scroll on the output screen.*
if (!bAlarmOne) {*
[Link]("-------------------------");*
[Link]("sound detected on mic: ");*
[Link](microphoneArray[1]); //print the microphone number that heard
the sound*
[Link]("LOUD, LOUD");*
bAlarmOne = true;*
}*
}*
else {*
if ( ((millis() - lastSoundDetectTimeOne) > soundAlarmTime) && bAlarmOne) {
/// Added brackets. Assuming there were 2 conditions to be satisfied:
(1)(millis()-lastSoundDetectTime) > soundAlarmTime) and (2) bAlarm == true.
added brackets to make sure it does NOT say "if (millis()-lastSoundDetectTime)
is greater than soundAlarmTime and also greater than bAlarm"*
[Link]("-------------------------");*
[Link]("quiet");*
[Link]("Current time: ");*
[Link](millis()); // debug code: print vars*
[Link]("Last time when sound was detected: ");*
[Link](lastSoundDetectTimeOne); // debug*
[Link]("sound alarm Time set by user: ");*
[Link](soundAlarmTime); // debug*
bAlarmOne = false;*
}*
}*
(this code is borrowed from this link)