Due: 2:00 p.m. next Monday.
Introduction
In Lab 6, you worked with a digital temperature sensor that communicates with a Raspberry Pi through the I2C protocol. In this lab, you will explore an ultrasonic range finder and an accelerometer. Capture screenshots, photographs, and videos as necessary, and add descriptive comments to your Python scripts.
Tasks
- HC-SR04 Range Finder Setup and Implementation:
- Show an instructor the HC-SR04 Python script you wrote and the schematic to connect this range finder to the Raspberry Pi.
- Build the circuit and turn on the Raspberry Pi.
- Before testing, show your circuit to an instructor for approval.
- Debug and run your script to test if the range finder can measure distance.
- Output measurements in m, cm, mm, and inches. Handle the significant figures appropriately.
Course Instructor or TA Signature:
Date and Time:
- Range Finder Calibration:
- Determine the zero offset, minimum range, maximum range, and accuracy of the range finder.
- Compare your measurements to the specifications in the datasheet.
Course Instructor or TA Signature:
Date and Time:
- LIS3DH Accelerometer Setup:
- Copy the provided file
LIS3DHMOD.pyfrom a USB drive into your lab directory. - Connect the LIS3DH properly to the Raspberry Pi.
- Detect the I2C address using the terminal.
- Write and run your script to validate the output of the x-axis.
- Show your script to an instructor.
- Copy the provided file
Course Instructor or TA Signature:
Date and Time:
- Acceleration Data Collection and Analysis:
- Record at least 100 acceleration data points along each of the three axes.
- Determine the standard deviation with the accelerometer stationary.
- Theorize how a tilted plane affects the accelerometer readings.
- Determine the smallest angle change detectable by the accelerometer.
Course Instructor or TA Signature:
Date and Time:
- Data Averaging and Visualization:
- Write code to average n sequential measurements.
- Determine the standard deviation of these averaged measurements.
- Create a program to plot accelerations against time, ensuring the plot is smooth with enough data points.
- Record data after manipulating the accelerometer.
- Save all data in a
.csvfile and save the plots as image files. - Discuss results, observations, and the plots in detail in your report.
Course Instructor or TA Signature:
Date and Time:
- Accelerometer Pendulum Motion and Data Visualization:
- Setup and Swing Test: Secure the accelerometer and connect it to the Raspberry Pi using the correct pins. Configure your script to capture and log acceleration continuously along all three axes (x, y, and z) while the accelerometer swings as a pendulum. Mount the accelerometer so that it can swing freely, and record at least 100 data points over at least 10 s and multiple oscillations.
- Data Visualization: Plot the acceleration data over time for all three axes using Matplotlib, with each axis represented by a different color (e.g., X-axis in red, Y-axis in green, Z-axis in blue). Label the axes clearly and add a legend to distinguish between them.
- Data Analysis: Analyze whether the measured oscillation frequencies correspond to the expected pendulum motion. In your report, discuss whether the frequencies observed along each axis match the physical motion of the pendulum, and explain any discrepancies.
Course Instructor or TA Signature:
Date and Time:
- Temperature-Compensated Range Finder:
- Connect the MCP9808 temperature sensor to your circuit.
- Modify your code so the range finder outputs distance based on the MCP9808 temperature reading.
- Show an instructor upon successful completion.
Course Instructor or TA Signature:
Date and Time:
Submission Reminder
- Detailed schematics of your sensor circuits (HC-SR04 and LIS3DH).
- Your complete Python scripts for both the range finder and accelerometer, with clear comments.
- Calibration data and analysis for the HC-SR04 range finder, including the use of temperature compensation (if applied).
- Acceleration data analysis, including standard deviations, angle change detection, and a discussion of whether the frequencies observed in the data match the physical pendulum motion.
- Plots of acceleration data for all three axes (X, Y, Z), each shown in a different color. Provide explanations of your observations and any discrepancies.
- A discussion of any challenges encountered and how you overcame them.
- The script for the temperature-compensated range finder, if completed.
- (Optional) Link to your YouTube video demonstrating the sensor operations.