AhmedYasser20 / Distance-Measuring-System

- Developing a system that measure the distance and display it on LCD. - Drivers: GPIO, ICU, Ultrasonic Sensor and LCD - Microcontroller: ATmega32.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Distance-Measuring-System


Welcome to the Mini Project 4 repository! This project focuses on creating a distance measurement system using an ultrasonic sensor HC-SR04 and an ATmega32 Microcontroller. Below, you'll find detailed instructions on system requirements, drivers to be used, and hardware connections for successful implementation.

System Requirements

Hardware and Components

  1. ATmega32 Microcontroller with a frequency of 8 MHz.
  2. Ultrasonic sensor HC-SR04.
  3. 4x16 LCD.
  4. Appropriate cables and connectors for wiring.
  5. Power supply for the components.

Drivers

  1. GPIO Driver: Implement a GPIO driver for controlling general-purpose input/output pins without referencing any specific course material.

  2. ICU Driver: Create an Input Capture Unit (ICU) driver for capturing time intervals without referring to any particular course materials. Configure the ICU to work with a frequency of F_CPU/8 and to detect the rising edge as the first edge. The ICU_init and ICU_setCallBack functions should be used for setting up the ICU.

  3. LCD Driver: Implement an LCD driver to control the 4x16 LCD display without referring to any specific course material. Use an 8-bit data mode. Connect the control pins and data pins as follows:

    • RS → PB0
    • RW → Ground
    • E → PB1
    • Data Bus → all PORTA pins.
  4. Ultrasonic Driver: Develop a complete Ultrasonic Driver using the ICU driver. This driver should contain the following functions:

    • void Ultrasonic_init(void): Initialize the ICU driver, set up the ICU callback function, and configure the trigger pin as an output.
    • void Ultrasonic_Trigger(void): Send a trigger pulse to the ultrasonic sensor.
    • uint16_t Ultrasonic_readDistance(void): Send a trigger pulse, start the measurements with the ICU, and return the measured distance in centimeters.
    • void Ultrasonic_edgeProcessing(void): This callback function is called by the ICU driver to calculate the high time (pulse time) generated by the ultrasonic sensor.

Project Structure

image

The project should be designed and implemented based on a layered architecture model. Ensure that the following layers are properly organized and functioning:

  1. GPIO Driver.
  2. ICU Driver.
  3. LCD Driver.
  4. Ultrasonic Driver.

Hardware Connections

For successful operation of the system, make the following hardware connections:

  • Ultrasonic Sensor HC-SR04: Connect the sensor as follows:

    • VCC → 5V
    • GND → Ground
    • Trig → Connect to a GPIO output pin
    • Echo → Connect to the ICU input pin
  • LCD: Connect the 4x16 LCD as specified in the LCD Driver Requirements section.

  • ATmega32 Microcontroller: Ensure proper power supply and connect the control pins of the Ultrasonic Driver as per the provided driver requirements.

How to Use

  1. Clone or download this repository to your local machine.
  2. Set up your development environment and ensure the required tools and libraries are installed.
  3. Open the project in your preferred development environment.
  4. Implement the drivers and connect the hardware components as described above.
  5. Compile and upload the code to your ATmega32 Microcontroller.
  6. Power up the system.
  7. The LCD will display the measured distance in centimeters.

ScreenShot

image

About

- Developing a system that measure the distance and display it on LCD. - Drivers: GPIO, ICU, Ultrasonic Sensor and LCD - Microcontroller: ATmega32.


Languages

Language:C 85.8%Language:Makefile 14.2%