Post-Lab Week 2 Submission - Dianne Mutia

.pdf

School

University of California, Berkeley *

*We aren’t endorsed by this school

Course

MISC

Subject

Electrical Engineering

Date

Dec 6, 2023

Type

pdf

Pages

6

Uploaded by everysinglecombinationitry

Post-Lab Week 2 Submission 1. External LED Blink and Brightness: In lab 1C, you set up your Arduino with the blink and brightness programs. Describe what your multimeter would measure if you were to take a voltage measurement between digital pin 13 and GND while running the blink program. Describe what your multimeter would measure if you were to take a voltage measurement between digital pin 9 and GND while running the brightness program. The multimeter would measure between pin 13 and GND either 0 V when the light is off, or 5 volts when on. There are only 2 possible values, HIGH (5V) and LOW (0V). The multimeter measuring between digital pin 9 and GND could read any values ranging from 0 to 5 V (intermediates).
2. Plot of time-of-flight vs. distance: Present your plot of the time-of-flight of the ultrasonic chirps vs. the distance from the reflecting object. Be sure to include error bars, a best-fit line, axis labels, a title, and the legend. Include your screenshotted plot below. 3. Speed of Sound: What is the slope of the best-fit line for your plot? Based on this result, what did you determine the speed of sound to be? Include units for all your values. The slope of the line of best fit was: 0.005692089024390243 m/s. I determined that the speed of sound as 351.3648489034739 m/s. 4. Notebook for Lab 1C: Attach screenshots of the entire Collab Notebook
Error bars (example) Error In any scienti¦c plot, it is important to not only show the data points but to also show error bars, which indicate how uncertain we are about any error particular data point. Some sources of error will result from uncertainties of our measurement tools, and some come from variation in the error measurements that go into our data. Below is an example of some x points, y points, and the associated error estimates of each quantity. The x error axis are various distances (in m), and the y axis is the output from the ultrasound sensor (in seconds). However, our data points, shown in blue do not seem to represent the model very well. Text(0, 0.5, 'Ultrasound output(s)') import numpy as np import matplotlib.pyplot as plt distance_cm = np.array([5.0, 10.0, 15.0, 20.0]) distance_m = distance_cm/100 ultrasound_micros = np.array([275.8, 661.7, 897.5, 1136.6]) ultrasound_s = ultrasound_micros/1000000 plt.scatter(distance_m, ultrasound_s, label = 'Data') results=np.polyfit(distance_m, ultrasound_s,1) plt.plot(distance_m, results[0]*distance_m+results[1], color = 'red', label = 'Model') plt.legend() plt.xlabel('Distance(m)') plt.ylabel('Ultrasound output(s)') When we introduce the error bars for the measurements, we can see that the data points do match up with the model, but the measurements error have a high level of noise. We plot the error bars using the error plt.errorbar error function which takes the keyword arguments of the error of the x error values and the error of the y values. error In the example below, the distance measurement error is ¦xed at 0.01 m but the error in ultrasound output is different for each distance. error error Plt.errorbar documentation can be found here : error https://matplotlib.org/3.3.3/api/_as_gen/matplotlib.pyplot.errorbar.html error # Create arrays to store the errors distance_m_error = np.array([0.005, 0.01, 0.01, 0.01]) ultrasound_micros_error = np.array([54.0, 61.0, 55.0, 59.0]) ultrasound_s_error = ultrasound_micros_error/1000000 # Use plt.errorbar to plot values along with error bars # plt.errorbar documentation can be found here : https://matplotlib.org/3.3.3/api/_as_gen/matplo # Use fmt = 'o' to remove line connecting the data points and having it appear as a scatter plot plt.errorbar(distance_m, ultrasound_s, xerr = distance_m_error, yerr = ultrasound_s_error, label results=np.polyfit(distance_m, ultrasound_s,1) plt.plot(distance_m, results[0]*distance_m+results[1], color = 'red', label = 'Model') plt.legend() plt.xlabel('Distance(m)') plt.ylabel('Ultrasound output(s)')
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