Skip to content

gokulkrishnaks/AVR-auto-fill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

AVR Auto-Fill Bottle System Using ATmega32A Microcontroller

This project demonstrates an Automated Bottle Filling System using an AVR ATmega32A Microcontroller. It uses a keypad for quantity input, sensors for bottle detection, a DC motor for filling, and a 16x2 LCD for user interface.

Project Description

  • Microcontroller: ATmega32A (AVR)
  • Features:
    • Quantity selection via 4x4 Keypad (1-9 units)
    • Bottle presence detection using IR Sensor
    • Manual Stop Button during filling
    • Real-time status display on 16x2 LCD
    • Motor-driven liquid filling mechanism
  • Application: Industrial Automation, Embedded Control Systems, Academic Projects.

Hardware Requirements

  • ATmega32A Development Board
  • 16x2 LCD (HD44780 Compatible)
  • 4x4 Matrix Keypad
  • IR Sensor Module (for bottle detection)
  • Push Button (for manual stop)
  • DC Motor (Filling Mechanism)
  • Motor Driver (L293D or equivalent)
  • Power Supply (5V regulated)
  • Breadboard, Resistors, Jumpers

Software Requirements

  • Atmel Studio / AVR-GCC (for code compilation & HEX generation)
  • Proteus Design Suite (for circuit simulation)
  • USBasp Programmer (if flashing to hardware)

Project Folder Structure

avr-auto-fill/
├── src/
│   └── main.c               # C Source Code
├── simulation/
│   └── project.pdsprj       # Proteus simulation file
└── README.md                # Project Overview & Instructions

Steps to Compile HEX File in Atmel Studio

  1. Open Atmel Studio.
  2. Create a New Project:
    • File > New > Project > GCC C Executable Project
    • Name: AVR_AutoFill
    • Select Device: ATmega16
  3. Add Source File:
    • Right-click Source Files > Add > Existing Item.
    • Select main.c from /src/.
  4. Configure Output HEX File:
    • Project > Properties > Toolchain > AVR/GNU Linker > General.
    • Enable "Generate HEX File".
  5. Build the Project:
    • Press F7 or Build > Build Solution.
    • HEX file will be generated inside the project folder.

Running the Simulation in Proteus

Simulation Prerequisites:

  • Proteus component libraries:
    • ATmega32 Microcontroller
    • HD44780 LCD (16x2)
    • 4x4 Keypad
    • IR Sensor Module
    • Push Buttons
    • DC Motor + L293D Driver

Simulation Steps:

  1. Open Proteus Design Suite.
  2. Open the Provided Simulation File:
    • Navigate to /simulation/ folder.
    • Open project.pdsprj.
  3. Load HEX File to ATmega32A:
    • Double-click ATmega16 symbol.
    • In Program File field, browse and select the generated HEX file.
  4. Run Simulation:
    • Click Play (Run Simulation).

Operation Flow:

  • Keypad Input: Press '1' to '9' to set quantity.
  • Bottle Placement: Place bottle in front of IR Sensor (Active LOW).
  • Filling Process: Motor starts filling for selected quantity.
  • Stop Button: Press any time to abort filling.
  • Completion: LCD shows "Done!" after filling.

How the Code Works

  • LCD is interfaced in 4-bit mode (PortB).
  • Keypad connected to PortA (Columns: PA4-PA7, Rows: PA0-PA3).
  • Motor controlled via PD2.
  • Sensor and Stop Button connected to PC0 and PC1 respectively.
  • Program waits for user quantity input, detects bottle presence, activates motor for filling, and monitors stop button.

Flowchart

Start
  |
  |---> Initialize LCD
  |---> Initialize Keypad, Sensor, Motor pins
  |
Main Loop:
  |
  |---> Prompt User for Quantity (Keypad Input)
  |        |
  |        +--> Store Selected Quantity
  |
  |---> Wait for Bottle Detection (Sensor PC0)
  |
  |---> Start Motor (PD2 HIGH)
  |
  |---> Loop for Quantity Seconds
  |        |
  |        +--> Check Stop Button (PC1)
  |        +--> If pressed, Stop Motor & Display "Stopped"
  |
  |---> After Filling, Turn Off Motor
  |---> Display "Done!"
  |
Repeat Main Loop

Notes

  • Keypad scanning uses column-wise active LOW detection.
  • LCD is controlled via RS, EN, and data lines using PortB.
  • Sensor and Stop Button inputs are active LOW and require pull-up resistors.
  • Simple software debouncing implemented for keypad inputs.

Troubleshooting

  • Keypad Not Responding?
    • Verify PORTA connections and pull-ups on rows.
  • LCD Not Displaying?
    • Check contrast setting and LCD pin mappings.
  • Motor Not Operating?
    • Verify motor driver connections and PD2 logic.
  • Sensor Not Detecting Bottle?
    • Ensure correct placement and active LOW behavior of IR sensor.

License

This project is licensed under the MIT License. You are free to use, modify, and distribute this code and simulation files.

Preview (Add Screenshots in /docs/)

  • Simulation Circuit Diagram
  • LCD showing Quantity Input
  • LCD displaying Filling Status

Author

GOKUL KRISHNA K S

About

AVR ATmega32A Based Automated Bottle Filling System with Keypad and Sensor Integration

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages