Manan Dua
Fully Assembled HAML Device

Device Description: High-Accuracy Mapping Lidar (HAML)

The High-Accuracy Mapping Lidar (HAML) is designed to map indoor areas up to 4 meters away using a rotating Time-of-Flight (ToF) sensor mounted on a stepper motor. It leverages the MSP432E401Y microcontroller, a VL53L1X ToF sensor, and a 28BYJ-48 stepper motor to create 2D radial measurements that are converted into 3D point clouds via a Python script.

Key Features:

  • Microcontroller: MSP432E401Y running at 26 MHz with 17 kB program memory.
  • User Interface: Two push buttons—one to start the scan, one for homing.
  • ToF Sensor: VL53L1X captures distance readings every 5.625° for a full 360° sweep (64 measurements).
  • Stepper Motor: 28BYJ-48 controlled via ULN2003 driver in Full-Step mode for maximum torque.
  • Power: 5 V DC via micro-USB; VL53L1X powered at 3.3 V from the MCU.
  • Connectivity: I²C between MCU and ToF sensor; UART between MCU and PC at 115200 bps.
  • Indicators: LEDs for data measurement, UART status, and error indication.
  • Data Visualization: Python (v3.12) and Open3D (v0.19) convert measurements into 3D point clouds.
  • Cost: Approximately $105 total: MSP432E401Y ($75), VL53L1X ($15), stepper kit ($10), 3D prints ($5).
Block Diagram of HAML Data Flow

Device Characteristics

CharacteristicDetail
Microcontroller Bus Speed26 MHz
SCL (ToF Pin)PB2 on MSP432E401Y (I²C clock)
SDA (ToF Pin)PB3 on MSP432E401Y (I²C data)
Vin (ToF Power)3.3 V
GND (ToF Power)GND
IN1–IN4 (Motor Driver Inputs)PH0, PH1, PH2, PH3 on MSP432E401Y
Motor Driver Power (V+)5 V
Push Button 1PM0 (start scan)
Push Button 2PM1 (home)
Power LEDPN1
UART LEDPN0
Error LEDPF4 (failed measurement)
UART Baud Rate115200 bps
Python Version3.12.0
Open3D Version0.19.0
Serial Porte.g., COM6

Detailed Description: Distance Measurement

printTOF() Function Code Snippet

The HAML uses the VL53L1X ToF sensor to measure distances up to 4 m with millimeter accuracy. A 940 nm VCSEL emits an IR pulse, and a SPAD array detects returning photons. The time difference between emission and reception—divided by twice the speed of light—yields the distance.

Distance formula example:

Distance = (20 ns) / (2 × 3 × 108 m/s) = 3 m (3000 mm)

The sensor communicates via I²C. At startup, the MCU configures GPIOs for buttons, the ToF sensor, and motor driver. When Push Button 1 is pressed, the spin() function rotates the stepper 32 steps (5.625°) and calls printTOF() to read and validate distance data. This repeats 64 times for a full 360° scan (2048 steps total). After completion, the motor returns to –90° home.

Each radial measurement point is converted from polar (angle, distance) to Cartesian (Y, Z) using sine and cosine. After each full scan, the user moves the device +300 mm along X to capture the next slice.

Visualization

Python UART Data Acquisition Code

After data collection, the Python script (O3DCreateData.py) reads distance values via UART (COM6), including the number of points per run and total runs. It computes XYZ coordinates: Z = cos(angle) × distance, Y = sin(angle) × distance, and X increments by 300 mm per run.

Once converted, the script launches Open3D to render a raw point cloud and a connected mesh, visualizing the scanned environment in 3D.

Python Code Converting to Cartesian Coordinates

Application, Instructions, and Expected Output

Photo of Scanned Hallway Location

Application

HAML is useful for indoor mapping: construction planning, security, robotics navigation, and home automation. It identifies structural defects, estimates repairs, or aids robotic path planning. While optimal indoors (≤4 m range), future sensors could expand outdoor use.

Instructions

  1. Assemble circuit per schematic: connect MSP432E401Y, VL53L1X (I²C), 28BYJ-48 stepper (ULN2003), buttons, and LEDs. Refer to the folloring figures for wiring and enclosure photos.
  2. Mount components in a 3D-printed chassis; align ToF sensor on motor shaft, pointing downward. Place Push Button 1 to start scan, Push Button 2 for homing.
  3. Connect to PC via USB; note COM port in Device Manager (e.g., COM6).
  4. Upload Keil code (duam4 – 2DX3 Final Project Code.c) to MSP432E401Y; press reset.
  5. Update O3DCreateData.py with correct COM port (line 15).
  6. Place HAML at starting position; press Button 1 to scan. After full 360° rotation, device returns home.
  7. Move device +300 mm along +X and press Button 1 for next scan. Repeat as needed. Press Button 2 at any time to abort and return to home.
  8. After all runs, execute O3DCreateData.py to retrieve data and visualize.

Expected Output

Scans of location I (John Hodgins Engineering Building hallway) should resemble the following figures. Areas beyond 4 m show gaps filled using previous valid readings. The Open3D point cloud and connected mesh match hallway geometry, with minor inaccuracies on reflective or uneven surfaces.

Open3D Point Cloud Visualization
Open3D Connected Mesh Visualization

Limitations

The MSP432E401Y’s FPU supports single-precision; complex trigonometric calculations are offloaded to Python (64-bit). MCU memory (2048 integers) limits scans to 32 runs of 64 points. VL53L1X ADC quantization error (~1 mm) matches sensor resolution. UART set to 115200 bps; PC maximum ~128000 bps. I²C limited to 100 kbps. Bus speed is 26 MHz; can go to 120 MHz but stepper speed and ToF response limit scan rate (2 ms step delay required for reliability). ToF struggles with glass or brightly lit surfaces; accuracy improves at closer range.

Circuit Schematic

HAML Circuit Schematic

Programming Logic Flowcharts

Flowchart of Microcontroller Code

Flowchart of Python Code