Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kareemmoneeam/ultrasonic-distance-measurement-system
This project implements a distance measurement system using an ultrasonic sensor HC-SR04 and an ATmega32 microcontroller. It is designed to measure the distance to an object and display the result on a 4x16 LCD. The system is based on a layered architecture model.
https://github.com/kareemmoneeam/ultrasonic-distance-measurement-system
Last synced: 3 days ago
JSON representation
This project implements a distance measurement system using an ultrasonic sensor HC-SR04 and an ATmega32 microcontroller. It is designed to measure the distance to an object and display the result on a 4x16 LCD. The system is based on a layered architecture model.
- Host: GitHub
- URL: https://github.com/kareemmoneeam/ultrasonic-distance-measurement-system
- Owner: KareemMoneeam
- Created: 2023-10-21T15:04:25.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-21T15:09:41.000Z (about 1 year ago)
- Last Synced: 2023-10-21T16:24:36.393Z (about 1 year ago)
- Language: C
- Size: 773 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ultrasonic Distance Measurement System
## Overview
This project implements a distance measurement system using an ultrasonic sensor HC-SR04 and an ATmega32 microcontroller. It is designed to measure the distance to an object and display the result on a 4x16 LCD. The system is based on a layered architecture model, with separate HAL (Hardware Abstraction Layer), MCAL (Microcontroller Abstraction Layer), and Application layers.
## Hardware Requirements
- ATmega32 Microcontroller with a clock frequency of 8MHz.
- HC-SR04 Ultrasonic Sensor.
- 4x16 LCD with an 8-bit data interface.
- Components for connecting the ultrasonic sensor, LCD, and microcontroller (wires, resistors, etc.).## System Architecture
The system follows a layered architecture model:
1. *HAL (Hardware Abstraction Layer):* Responsible for handling specific hardware components such as the LCD and Ultrasonic sensor. It includes the LCD and Ultrasonic drivers.
2. *MCAL (Microcontroller Abstraction Layer):* Provides drivers for the GPIO (General-Purpose Input/Output) and ICU (Input Capture Unit) of the ATmega32 microcontroller.
3. *Application Layer (Distance_Measurement.c):* The application layer where the main code resides. It manages the overall functionality of the system.
## GPIO Driver
The GPIO driver is used for general-purpose input/output operations. It remains the same as the one implemented in the course.
## ICU Driver
The ICU driver configures the Input Capture Unit of the ATmega32 to detect the rising edge as the first edge and is set to run at F_CPU/8. It includes the ICU_init and ICU_setCallBack functions.
## LCD Driver
The 4x16 LCD is connected to the ATmega32 using an 8-bit data interface. The control pins are connected as follows:
- RS → PB0
- RW → Ground
- E → PB1
- Data Bus → All PORTA pins.## Ultrasonic Driver
The Ultrasonic driver is a full driver that utilizes the ATmega32 ICU driver. It provides the following functions:
- void Ultrasonic_init(void): Initializes the ICU driver for ultrasonic operation, sets up the ICU callback function, and configures the trigger pin as an output.
- void Ultrasonic_Trigger(void): Sends a trigger pulse to the ultrasonic sensor.- uint16 Ultrasonic_readDistance(void): Initiates the distance measurement by triggering the sensor and returns the measured distance in centimeters.
- void Ultrasonic_edgeProcessing(void): The callback function called by the ICU driver, used to calculate the high time (pulse time) generated by the ultrasonic sensor.
## How to Use
1. Connect the ATmega32 microcontroller, HC-SR04 sensor, ICU Driver, and 4x16 LCD as described in the project documentation.
2. Compile the code using AVR-GCC.
3. Flash the firmware to the ATmega32.
4. Power up the system.
5. The distance to an object will be measured and displayed on the connected 4x16 LCD.