AVR Based DC Motor Controller using ATmega16 with Proteus Simulation

Summary of AVR Based DC Motor Controller using ATmega16 with Proteus Simulation


This article details an AVR-based DC motor controller project using the ATmega16 microcontroller in Proteus. It demonstrates PWM speed control via Timer0 and a transistor driver stage, featuring an oscilloscope for signal monitoring. Ideal for students and hobbyists, the project includes source code for AVR-GCC and covers circuit configuration, workflow, and practical applications in robotics and automation.

Parts used in the AVR Based DC Motor Controller:

  • ATmega16 microcontroller
  • DC motor
  • 8 MHz crystal oscillator
  • 22pF capacitors
  • Reset push button
  • 1N4148 diode
  • Power indicator LED
  • 220Ω resistor
  • 10kΩ resistor
  • 0.1nF capacitor
  • TIP31 transistors
  • TIP32 transistors
  • 2SC2547 transistors
  • 1kΩ resistors
  • +12V motor supply
  • Proteus oscilloscope

Introduction

This project demonstrates an AVR based DC Motor Controller using the ATmega16 microcontroller in Proteus simulation.
It is a simple but useful microcontroller project for learning how PWM can control the speed of a DC motor.
The circuit uses the ATmega16 to generate a PWM signal and drive a motor through a transistor-based motor driver stage.
It is a practical example for students and hobbyists working on embedded systems, DIY electronics, and practical electronics.
The Proteus circuit diagram also includes an oscilloscope view, making it easier to observe the PWM waveform during simulation.

ATmega16 PWM DC motor controller test bench setup
Illustrative View of the Concept.

How the Project Works

The working principle of this project is based on PWM motor control.

The ATmega16 is configured to generate a PWM signal using Timer0. This PWM output is sent from the microcontroller to the motor driver circuit. The motor driver section uses multiple transistors to handle the higher current required by the DC motor.

In the provided schematic, the circuit also includes a direction control signal labeled DIR and a PWM control signal labeled PWM. The oscilloscope is connected to monitor the signal behavior during the Proteus simulation.

The speed of the motor depends on the PWM duty cycle. In the source code, the duty cycle is controlled using the OCR0 register.

Workflow Explanation

The project workflow can be understood like this:

8 MHz Crystal Clock
        ↓
ATmega16 Microcontroller
        ↓
Timer0 PWM Generation
        ↓
PWM + DIR Output Pins
        ↓
Transistor Motor Driver Circuit
        ↓
DC Motor
        ↓
Oscilloscope Monitoring in Proteus

The ATmega16 receives its clock from an 8 MHz crystal oscillator. After reset, the microcontroller configures specific PORTB pins as outputs. Timer0 then generates the PWM waveform, which is applied to the transistor driver stage. The driver circuit powers the DC motor from the external +12V supply.

Key Features

  • AVR based microcontroller project using ATmega16
  • PWM-based DC motor speed control
  • Designed for Proteus simulation
  • Uses Timer0 of ATmega16 for PWM generation
  • Motor driver circuit built using transistor stages
  • 8 MHz crystal oscillator used for controller clock
  • Oscilloscope included for observing PWM and motor signals
  • Simple firmware structure suitable for learning embedded systems
  • PWM duty cycle can be changed from the source code
  • Useful for understanding motor control in practical electronics

Components Used

Based on the provided schematic diagram and source code, the project uses:

  • ATmega16 microcontroller
  • DC motor
  • 8 MHz crystal oscillator
  • 22pF capacitors for crystal circuit
  • Reset push button
  • 1N4148 diode
  • Power indicator LED
  • 220Ω resistor for LED
  • 10kΩ resistor for reset circuit
  • 0.1nF capacitor in reset section
  • TIP31 transistors
  • TIP32 transistors
  • 2SC2547 transistors
  • 1kΩ resistors in motor driver section
  • +12V motor supply
  • VCC and ground connections
  • Proteus oscilloscope / virtual instrument

Applications

This type of DC motor control project can be used in many practical electronics and embedded systems applications, such as:

  • Small robotics projects
  • Motor speed control learning kits
  • DIY electronics motor driver experiments
  • Embedded systems training projects
  • PWM testing and waveform analysis
  • Fan speed control concept projects
  • Basic automation systems
  • Motor driver circuit testing in Proteus

Explanation of Code

The source code is written for the ATmega16 using AVR-GCC / WinAVR.

The firmware mainly performs three tasks:

1. Stack Pointer Initialization

The code initializes the stack pointer manually using SPL and SPH. This prepares the microcontroller for normal program execution.

2. PORTB Configuration

The instruction:

DDRB = 0x0c;

sets PB2 and PB3 as output pins. These pins are used for motor control signals shown in the Proteus schematic as DIR and PWM.

3. Timer0 PWM Setup

The code configures Timer0 using:

TCCR0 = 0x65;
OCR0 = 0xcc;

TCCR0 sets the Timer0 operating mode and clock selection, while OCR0 controls the PWM duty cycle. Changing the value of OCR0 changes the motor speed in the simulation.

There is no ADC, LCD, UART, temperature sensor, or external sensor module used in the provided source code. The project is focused on PWM-based motor control.

ATmega16 PWM motor controller Proteus simulation circuit diagram

Source Code

#include <avr/io.h>
#include <util/delay.h>
#define uchar unsigned char
#define uint unsigned int

/**** Low level port/pin definitions ****/
#define sbit(x,PORT) (PORT) |= (1<<x)
#define cbit(x,PORT) (PORT) &= ~(1<<x)
#define pin(x,PIN)   (PIN)  &  (1<<x)

Download Source Code

Proteus Simulation

In the Proteus simulation, the ATmega16 generates a PWM signal and sends it to the motor driver circuit. The motor is powered through the transistor stage using the external +12V supply.

The oscilloscope connected in the schematic allows the PWM signal, direction signal, and motor terminal behavior to be observed during simulation. The project description also mentions that the pulse train can be observed and that the duty cycle can be edited in the code to change motor performance.

This makes the simulation useful for understanding how firmware, PWM output, and motor driver hardware work together in an embedded systems project.

Conclusion

This AVR based DC Motor Controller using ATmega16 is a clean and practical example of PWM motor control in Proteus. It shows how a microcontroller can generate firmware-controlled PWM and drive a DC motor through a transistor-based circuit. For learners working on embedded systems, DIY electronics, and motor control projects, this simulation is a useful starting point for understanding the connection between source code, circuit diagram, and real motor behavior.

Complete File

AVR Based DC Motor Controller using ATmega16 with Proteus Simulation

Download Complete File

Quick Solutions to Questions related to AVR Based DC Motor Controller:

  • How does the project control motor speed?
    The speed depends on the PWM duty cycle controlled by the OCR0 register in the source code.
  • What timer is used for PWM generation?
    Timer0 of the ATmega16 microcontroller is configured to generate the PWM waveform.
  • Which pins are configured as outputs for motor control?
    PB2 and PB3 on PORTB are set as output pins to send DIR and PWM signals.
  • What provides the clock signal to the microcontroller?
    An 8 MHz crystal oscillator supplies the clock to the ATmega16.
  • Can the direction of the motor be changed?
    Yes, the schematic includes a direction control signal labeled DIR to manage this.
  • What software environment is used for the simulation?
    The project is designed for simulation within the Proteus environment.
  • Is there any external sensor module used in the code?
    No, the provided source code does not use ADC, LCD, UART, or temperature sensors.
  • How is the stack pointer initialized in the firmware?
    The code initializes the stack pointer manually using SPL and SPH instructions.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top