π Project Overview This project presents the design, simulation, and FPGA implementation of an ultrasonic obstacle avoidance system using Verilog HDL. The system measures real-time distance between 0 cm and 49 cm with Β±1 cm accuracy, displays it on a 7-segment display, and transmits data wirelessly through an ESP32 module. A web-based dashboard provides live updates and proximity alerts, offering a reliable safety solution for vehicle applications.
π― Objectives
- Design a Finite State Machine (FSM) in Verilog for ultrasonic distance measurement.
- Interface the HC-SR04 sensor with the Basys 3 FPGA board.
- Display measured distance on a multiplexed 7-segment display.
- Implement UART communication for data transmission to the ESP32 module.
- Host a local web dashboard using ESP32 for remote visualization and alerting.
- Validate design using RTL simulation, synthesis, and on-board testing.
π οΈ Circuit Description
1οΈβ£ Ultrasonic Sensing & FSM Control
- The FSM handles trigger generation, echo detection, and time measurement.
- A 10 Β΅s trigger pulse initiates measurement; the echo pulse width determines distance.
2οΈβ£ Display Interface
- The measured distance is converted to BCD and displayed using a two-digit multiplexed 7-segment display.
3οΈβ£ Wireless Transmission
- A UART module sends updated distance readings to an ESP32 via serial communication (115200 bps).
- The ESP32 hosts a local webpage showing real-time distance and collision alerts.
βοΈ Key Components
| Component | Specification |
|---|---|
| FPGA Board | Basys 3 (Xilinx Artix-7) |
| Sensor | HC-SR04 Ultrasonic Sensor |
| Communication | Pmod ESP32 Wi-Fi Module |
| Software | Vivado 2025.1, ModelSim 10.5b, Arduino IDE |
| Serial Communication | TTL to Usb Convertor |
π’ Technical Parameters
| Parameter | Value |
|---|---|
| Distance Range | 0 β 49 cm |
| Accuracy | Β±1 cm |
| Update Rate | 40 Hz |
| UART Baud Rate | 115200 bps |
| Measurement Interval | ~25 ms |
π§© System Workflow
- Reset β Initializes registers and clears old data.
- Trigger Generation β Sends a 10 Β΅s pulse to the ultrasonic sensor.
- Echo Detection β Measures the return pulse width.
- Distance Calculation β Converts the pulse width to distance in cm.
- BCD Conversion β Formats data for display.
- Display Update β Refreshes 7-segment display.
- UART Transmission β Sends updated data to ESP32 when distance changes.
- Cooldown β Waits for sensor stability before the next cycle.
π§ͺ Simulation & Implementation
- Vivado & ModelSim used for RTL simulation, synthesis, and timing verification.
- Basys 3 board tested with HC-SR04 for live measurement.
- ESP32 received UART data and displayed it on a locally hosted web interface.
- Oscilloscope validation confirmed accurate 10 Β΅s trigger and echo timing.
π Results
| Condition | Simulation Output | Hardware Output | Web Output |
|---|---|---|---|
| Obstacle β₯ 5 cm | Distance stable at ~49 cm | Correct display | 49 cm (normal) |
| Obstacle < 5 cm | Alert triggered | RED indicator | 2 cm + ALERT |
β Waveform Accuracy: Β±1 cm error margin β System Stability: Consistent readings across test cases β Wireless Dashboard: Real-time update at 0.25 s refresh rate
| Challenge | Solution |
|---|---|
| Signal instability at short range | Added timeout logic and cooldown delay |
| UART sync errors | Implemented start/stop bit verification |
| Limited sensor accuracy | Calibrated COUNTS_PER_CM constant in Verilog |
π Applications
- Vehicle collision avoidance systems
- Smart robotics and autonomous navigation
- IoT-based distance monitoring systems
- Industrial proximity sensing
π References
- Xilinx Inc., Vivado Design Suite User Guide, 2025.
- HC-SR04 Datasheet, SparkFun Electronics.