← Advanced Instrumentation

PHYS 351 · Advanced Instrumentation

Lab 7 · Distance sensor & accelerometer

PHYS 351 LAB 7
Distance Sensor and Accelerometer

© Ran Yang, Ph.D.
SUBMISSION   Submit the completed lab report as a PDF on Gradescope.

Due: 2:00 p.m. next Monday.

Policies and Instructions
  1. Report Format: Submit a formal, typed lab report in PDF format. Handwritten lab reports will not be accepted. Hand-drawn circuit schematics are allowed only when explicitly permitted in the task instructions. Include screenshots, code, and simulation or measurement results where specified.
  2. AI Policy: The use of any AI tool, including a large language model (LLM), to write, generate, debug, or modify code or any portion of the lab report is prohibited unless the course instructor grants explicit permission in advance. A teaching assistant (TA) cannot grant permission to use AI tools.

By signing below, I acknowledge that I have read and understood the policies and instructions above and agree to follow them.

Student Name (print):  

Student Signature:       Date:  

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

  1. HC-SR04 Range Finder Setup and Implementation:
    1. Show an instructor the HC-SR04 Python script you wrote and the schematic to connect this range finder to the Raspberry Pi.
    2. Build the circuit and turn on the Raspberry Pi.
    3. Before testing, show your circuit to an instructor for approval.
    4. Debug and run your script to test if the range finder can measure distance.
    5. Output measurements in m, cm, mm, and inches. Handle the significant figures appropriately.
TASK APPROVAL Task 1 (HC-SR04 Setup and Implementation)

Course Instructor or TA Signature:  

Date and Time:  

  1. Range Finder Calibration:
    1. Determine the zero offset, minimum range, maximum range, and accuracy of the range finder.
    2. Compare your measurements to the specifications in the datasheet.
TASK APPROVAL Task 2 (Range-Finder Calibration)

Course Instructor or TA Signature:  

Date and Time:  

  1. LIS3DH Accelerometer Setup:
    1. Copy the provided file LIS3DHMOD.py from a USB drive into your lab directory.
    2. Connect the LIS3DH properly to the Raspberry Pi.
    3. Detect the I2C address using the terminal.
    4. Write and run your script to validate the output of the x-axis.
    5. Show your script to an instructor.
TASK APPROVAL Task 3 (LIS3DH Setup)

Course Instructor or TA Signature:  

Date and Time:  

  1. Acceleration Data Collection and Analysis:
    1. Record at least 100 acceleration data points along each of the three axes.
    2. Determine the standard deviation with the accelerometer stationary.
    3. Theorize how a tilted plane affects the accelerometer readings.
    4. Determine the smallest angle change detectable by the accelerometer.
TASK APPROVAL Task 4 (Acceleration Data Analysis)

Course Instructor or TA Signature:  

Date and Time:  

  1. Data Averaging and Visualization:
    1. Write code to average n sequential measurements.
    2. Determine the standard deviation of these averaged measurements.
    3. Create a program to plot accelerations against time, ensuring the plot is smooth with enough data points.
    4. Record data after manipulating the accelerometer.
    5. Save all data in a .csv file and save the plots as image files.
    6. Discuss results, observations, and the plots in detail in your report.
TASK APPROVAL Task 5 (Data Averaging and Visualization)

Course Instructor or TA Signature:  

Date and Time:  

  1. Accelerometer Pendulum Motion and Data Visualization:
    1. 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.
    2. 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.
    3. 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.
TASK APPROVAL Task 6 (Pendulum Motion and Visualization)

Course Instructor or TA Signature:  

Date and Time:  

  1. Temperature-Compensated Range Finder:
    1. Connect the MCP9808 temperature sensor to your circuit.
    2. Modify your code so the range finder outputs distance based on the MCP9808 temperature reading.
    3. Show an instructor upon successful completion.
TASK APPROVAL Task 7 (Temperature-Compensated Range Finder)

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.

← All course materials