Lab 5 Fall 2023
pdf
keyboard_arrow_up
School
University of California, San Diego *
*We aren’t endorsed by this school
Course
170
Subject
Aerospace Engineering
Date
Dec 6, 2023
Type
Pages
11
Uploaded by GeneralFlowerDragon7
MAE 170 [FA23]: LAB 5
Scanned Measurements and Averaging: Characterizing the
Spatiotemporal Output of a Speaker (
and resulting acoustic wave
propagation
)
Submit your answers to the questions posed in this lab to gradescope and turnitin via
the Canvas course website by 11:59 pm (midnight) the evening before your next lab
section.
The short answer questions will be graded at this deadline
.
Points for the
technical writing section will be given assuming a reasonably complete first draft
is turned in.
The final grade for your technical writing component will be made based
on the report turned in by 11:59 pm (midnight) the evening before your lab section after
next (i.e. one week after the drafts were turned in).
Learning objectives:
●
LLO5-1: Gain familiarity pressure transducers and sensors (e.g. speakers and
microphones)
●
LLO5-2: Understand the value of, and be able to conducted scanned
measurements
●
LLO5-3: Understand the value of feedback/control in measurement (including
servos)
●
LLO5-4: Understand motor driving/control automation with Arduino and Matlab
via G-Code
●
LLO5-5: Gain familiarity with application of uncertainty principles and proper
notation (significant figures, etc.)
●
LLO5-6: Be able to use signal conditioning (in this lab, time domain averaging
and filtering) to enhance signal quality (e.g. signal-to-noise ratio).
●
LLO5-7: Understand how, and be able, to communicate context and motivation
for your work in a technical writing scenario.
●
LLO5-8: Be able to generate a clear figure with high information density for
communicating the results of your work.
●
LLO5-9: Gain experience with making observations and providing supported
interpretations of experimental data.
●
LLO5-10: Become familiar with the universality of frequency domain analysis,
including within the spatial domain.
●
LLO5-11: Gain familiarity with sources of random vs. systematic error.
●
LLO5-12: Be able to process high dimensional (>2) datasets, and be able to
reduce the data into meaningful, visualizable forms (e.g. 2 and 3 dimensional
plots).
●
LLO5-13: Gain experience with norms and ethics in signal conditioning, data
analysis and data presentation.
1
PRE-LAB
View the
Lab 5 demonstration video
. Note this video was developed for an earlier,
remote version of MAE170, and you will be working with an updated version of the
scanning acoustic probe experimental setup herein.
Read the following via the custom course textbook:
●
Part A. 5, 6, 20
●
ASTM standard E177-14
●
ASTM standard E29-13
Consider reviewing some basics regarding wave propagation.
The following few
Wikipedia pages can provide an overview:
Wave
,
Sound
,
Acoustic Wave
.
Q1:
The
soundspeed
of
acoustic
waves
in
air
is
~340
m/s.
Calculate
the
wavelength of a 5 kHz acoustic wave in air.
2
IN-LAB
In this lab, we would like to
characterize how sound propagates in time and space
,
using a
speaker
to generate the wave. A
microphone
(e.g. a pressure sensor) will be
scanned, such that the experiment will be automatically repeated with the microphone
at different positions with respect to the speaker. The setup is shown in Fig. 1. The
scanning is accomplished using a
mostly-printed CNC kit
. To control the scanning, we
use
a
Matlab
code
that
sends
serial
commands
to
the
Arduino-based
“Rambo”
controller. The Rambo Arduino system controls four stepper motors, which move the
microphone’s position.
Figure 1:
Speaker characterization experimental setup.
The
Rambo Arduino
motor controller uses the same type of Arduino source code you
have used in your prior labs. The control script is called
Marlin, and can be downloaded
for free from GitHub
. The Marlin script has already been uploaded to your Rambo
Arduino, and it will wait for
G-Code
commands, via the serial port, to drive the stepper
motors.
G-Code
is
a
standard
commonly
used
for
3D
printing,
amongst
other
3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
automation applications.
To generate sound from the speaker, we use the Arduino
tone()
command via the
following Arduino script.
float Tmillis=0, freq=0;
String freq_str=" "; // initialize frequency string variable
void setup() {
Serial.begin(115200); // start serial reader
}
void loop() {
while (Serial.available() > 0) { // loop while there are strings in read buffer
freq_str = Serial.readString(); // read string
freq=freq_str.toFloat(); // convert string to float type
Tmillis=1/freq*1000*10; // calculate duration for 5 cycle pulse of given frequency
tone(9,freq,Tmillis); // generate tone at given frequency for above duration on pin 9
}
}
In the above script, the Arduino uses pulse width modulation to generate a 5 cycle long
pulse at a specified frequency from digital pin 9. For this experiment, we will use 5 kHz,
as per the following Matlab script.
To measure the acoustic wave generated by the speaker, we use our microphone,
which contains a built-in amplifier. This microphone requires a 5 V power supply, which
we will provide from your station’s breadboard.
Thereafter, we will work with the following two signals, both sent to your oscilloscope,
The signal sent from pin 9 to the speaker will be referred to as your “reference signal”,
and go to Channel 1 on your oscilloscope. The output signal from your microphone will
be sent to Channel 2 on your oscilloscope.
The Matlab script available on Canvas is used to control the scanning stage, drive the
speaker, and extract data from the oscilloscope. The origin of the scanning stage is
presumed to be in the top right, with the speaker in the middle of the left side of the
stage, as per the layout shown in Fig. 1.
Ensure that your speaker is placed 30 cm
away from the microphone in the direction of the speaker axis (x-axis) and 15 cm
away from the microphone perpendicular to the speaker axis (y-axis).
The script will generate a figure as shown in Fig. 2.
4
Figure 2:
A five cycle, 5 kHz acoustic wave generated by a speaker and measured with
a
microphone,
averaged
over 64 repetitions. [Top] A single acquisition of the 64
repetitions. The title denotes the repetition number and the measurement location. Both
signals are normalized to their maximum amplitude. Averaged [Middle] reference, and
[Bottom] microphone signal, over the 64 repetitions (units of un-normalized voltage).
The script furthermore produces the key variables:
-
t
: The measurement time vector in seconds
-
wave_ref
and
wave_sig
: The measured amplitude vector for the last acquisition,
for the reference and microphone signals, respectively.
-
recMatrix_ref
and
recMatrix_sig
: A three-dimensional matrix containing the
running average value of the measured amplitudes for all measurement positions
as a function of time. The first index corresponds to time, the second to x
positions, and the third to y positions.
5
Part I: Study the effect of averaging on signal to noise ratio
In this part, we are going to explore how averaging can drastically improve signal to
noise ratio of a measurement, and enable observations that would not have been
otherwise possible.
To start, make sure your scanning stage is positioned near the
origin of the coordinate system (a couple centimeters from the corner in each
axis) etched into the base plate of your scanning stage. Ask for help from the TAs
for repositioning, if the stage is not already positioned there.
To reduce the signal
amplitude, and simulate a lower signal to noise ratio condition,
insert a
voltage divider
(composed of two, 1 k
resistors) directly following pin 9
, before it goes to the
Ω
speaker and oscilloscopes. This will reduce the voltage output from pin 9 by half.
Figure 3:
Lab 5 Part 1 wiring diagram with voltage divider inserted between
Arduino output and speaker.
Make sure the oscilloscope has the following settings:
-
AC measurement mode on Channels 1 and 2
-
BW limit on for the reference channel (Channel 1)
-
Trigger of 70 mV rising edge, witn “normal” sweep setting, for the reference
channel (Channel 1)
Make sure your Matlab code is synchronized for the ports and names of your two
Arduinos and oscilloscope (yellow highlighted regions).
In the yellow highlighted
“parameters to set” section of your Matlab code, set the pointsx and pointsy
variables to 1 and the Navg variable to 64.
This will allow you to conduct a running
average of 64 acquisitions at the same position.
6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
In MATLAB set the following variables, paying attention to units
-
50 mV/div on the reference channel (Channel 1)
“verticalscale1”
-
20 mV/div on the microphone channel (Channel 2)
“verticalscale2”
-
500
s/div on the time axis
“timebase”
µ
-
Trigger of 2.000 ms (to the left of center)
“time_offset”
Q2: Turn in a plot with the last acquired microphone signal overlaid with the
averaged signal. Discuss the differences.
Consider that the standard deviation of a
normally distributed random number decreases as
, where N is the number of times
𝑁
the measurement is repeated and averaged together. This strategy is predicated on the
assumption that the “noise” components are normally distributed.
Q3: Measure/calculate the distance between the microphone and the speaker. Use
the time delay between the averaged reference and microphone signal to estimate
the soundspeed of air. Explain your process.
7
Part II: Using a scanning probe (the microphone) to characterize the
spatiotemporal response of a speaker
For this part, you will scan the spatiotemporal sound field of a 15 cm x 30 cm quadrant
in front of the speaker.
Remove the voltage divider from Part I. In the yellow
highlighted “parameters to set” section of your Matlab code, set the pointsx = 30
and pointsy = 15 and the Navg variable to 1 (i.e. not averaging). Note, your code is
set up to move in 1 cm steps. Be sure to record the
initial and final position
of
your speaker with respect to your measurement grid. In the matlab script, there is
a line that waits for a keystroke at the final position, before the stage returns to
the original position.
Figure 4:
Lab 5 Part 2 wiring diagram, without voltage divider.
Update the oscilloscopes to have the following settings:
-
Trigger of 200 mV rising edge, with “normal” sweep setting, for the reference
channel (Channel 1)
In MATLAB update the following variables, paying attention to units
-
500 mV/div on the reference channel (Channel 1)
“verticalscale1”
-
200 mV/div on the microphone channel (Channel 2)
“verticalscale2”
8
Q4: Create a plot that describes the time delay of the sound pulse arrival for
points along the scanning x-axis, where position (in meters) is on the x-axis of
your plot and time (in seconds) is on the y-axis of your plot.
●
Add error bars to your plot in both x- and y- directions. You may use the
matlab command
errorbar(x,y,yneg,ypos,xneg,xpos)
. Note that the yneg,
ypos, xneg, and xpos arguments are vectors. Consider what would make a
decent quantification of error for both axes in your plot, and explain your
rationale.
●
Overlay the plot with a line corresponding to the sound speed in air
●
Overlay a line of best fit, and use the slope to extract the experimentally
determined sound speed (report the experimentally determined speed)
Q5. Compare the distance between the prescribed and measured distance moved
by the scanning stage. What might cause any differences? Discuss the difference
between a stepper motor (what we are using) and a servomotor. How might a
servomotor increase confidence in our measurements? In addition, suggest a
method, perhaps using concepts explored in prior labs, to significantly reduce
the positioning uncertainty.
Q6: Use the
pcolor
command in matlab to create a plot that shows position along
the scanning x-axis for the plot’s x-axis, time as the y-axis, and color corresponds
to the normalized amplitude of the signal. The amplitude should be normalized so
that the data for each x position is divided by its absolute maximum amplitude.
Include a color scale bar by using the
colorbar
command. You will also want to
use the
shading flat
command;
You can format the colorbar by using the following code:
c = colorbar
set(c,’FontSize’, 20);
Overlay the plot with a line corresponding to the sound speed in air,
c
= 340 m/s
(you can use the command
hold on
and make a second plot).
Q7: Use the pcolor command again to create a plot that shows the sound field at
a time t = 2 ms. In this case, the x- and y-axes of your plot will correspond to the
scanning system’s x- and y-axes. Color scale bars should again be included.
Q8: Use the following script to create an animated gif where a similar plot as you
just
created
in
Q7
is
animated
such
that
each
frame
corresponds to each
sequential
time
step
in
t_pcolor.
This
will
allow
you
to
fully
visualize
the
spatiotemporal sound field generated by the speaker. Color scale bars should
again be included. Note that the color bar range is fixed in the script below using
the
caxis
command.
Upload
this
gif
animation as a separate file with your
assignment.
9
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
filename =
'scanning.gif'
;
for
k=1:length(t_pcolor)
*** your pcolor plot (as created in Q4) but for time t_pcolor(k) ***
caxis([-1 1])
pause(0.5);
drawnow;
frame = getframe(h);
% You can either remove the argument h
% or define a figure above, e.g., h=figure(01);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
% Write to the GIF File
if
k == 1
imwrite(imind,cm,filename,
'gif'
,
'Loopcount'
,inf);
else
imwrite(imind,cm,filename,
'gif'
,
'WriteMode'
,
'append'
);
end
end
Q9: Calculate approximately how long it took to run the scan for this part (in
hours), based on the code provided. How long would it take if you averaged 64
times for each position (in hours)?
Q10: What is the ratio of the spatial step size to the acoustic wavelength (where
sound speed
, where
c
is the sound speed in air (343 m/s),
is the acoustic
𝑐 = λ𝑓
λ
wavelength,
and
f
is
the
frequency.
Does
it
satisfy
the
Nyquist
sampling
frequency? (The Nyquist theorem also applies to the spatial resolution where you
need to sample two points along a period in the spatial domain)
Part III: Technical writing
Questions:
Q11: This question pertains to WLO2. Main task:
Be sure the figures from Q2, Q4,
Q6, Q7, and Q8 satisfy the WLO2 dimensions, including having a descriptive caption.
Purpose:
to gain practice presenting data visually in an accessible and information
dense manner.
Q12: This question pertains to WLO3. Main task:
Write an introduction (including a
couple references) that follows the WLO3 dimensions. This introduction should explain
the motivation behind the experiment you are conducting and the physics you seek to
explore. (Make sure to follow the points included in the Writing Learning Objectives
document thoroughly.)
.
10
Q13:
This
question
pertains
to
WLO1.
Main
task:
Write
a
results
section
(observations) followed by a discussion section (interpretations) that describes the data
contained in the figure you created as part of,
at least
, [
Q4 or Q6] and Q7
. The results
section should also describe how the data was collected,
and reference a figure
containing a schematic that you will create detailing your experimental setup
(that should satisfy WLO2)
.
Purpose:
To gain experience with making observations
and providing supported interpretations of experimental data.
11