Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

DC Motor Control using PWM with ADC

By Gurmeet Singh April 21, 2008

 

Requirements:

1.AT89S52 microcontroller
 
2.ADC0804 ADC chip
 
3.Preset (10K)
 
4.555 timer (with apt. resistor and capacitor values)
 
5.7805 IC
 
6.L293D IC
 
7.DC motor
 
This project involves a combination of PWM (pulse width modulation) and ADC (Analog-Digital converter) to drive a DC motor at various speeds and in both clockwise and anti-clockwise directions.
 
PWM is a concept with which one can modify the pulse voltage varying from 0% to 100% duty cycle.
 
Duty cycle represents the time for which pulse is high when compared to the full pulse length.
 
For eg:
 
This image below represents various percentage of duty cycles for a 4ms wave.

Timing Diagram showing different duty cycles

Fig. 1: Timing Diagram showing different duty cycles

This means for a 25%  cycle, you’ll we get 25% of the input voltage and the criterion is same for the rest of them. Now in the coding part I have made changes in the duty cycle in accordance with the digital output  obtained from the ADC. The ADC is connected to my microcontroller at PORT1. The preset which I have used here to send the analog input can be replaced by a “joystick” with inbuilt preset to make it more realistic and interesting to operate.
 
Now talking about the ADC, it’s an 8 bit analog to digital converter  that converts all the analog values to 8 bit digital data i.e. (0-255 for which it requires a reference voltage. The resolution or step-up voltage is 19.531mV. This means that for every 19.531Mv rise in the analog input, ADC will increase the digital value by 1 starting from 0 and ending at 255.
 
The resolution depends upon the reference voltage as well as the type of ADC you’re using. Here the reference voltage is 5v, while I’m working on an 8 bit ADC therefore:

             Resolution = 5(Reference voltage)/256(due to 8 bit i.e. 2^8=256) = 19.531mV

AADC also requires a clock frequency to work  upon. I have given it a 640 KHz using a 555 timer IC in a-stable mode.

For further information about ADC, check out my project: ADC interfacing with 8051.
 
L293D is connected to microcontroller via pin P2^1 and P2^6

Prototype of 8051 Microcontroller based DC Motor Speed Controller

Fig. 2: Prototype of 8051 Microcontroller based DC Motor Speed Controller

 

 

Project Source Code

###



#include<reg51.h>
#include<delay.h>
sbit R=P3^0;
sbit WD=P3^1;
sbit INT=P3^2;
sbit n=P2^1;
sbit p=P2^6;
int read_ADC()
{
        int temp;
                       R=1;
                       WD=0;
                       WD=1;
                       while(INT==1);
                       R=1;
                       R=0;
                       temp=P1;
            return temp;
}
void main()
{
           unsigned char value=128;
           INT=1;
           P1=0xff;
           value=read_ADC();
           while(1)
            {
                        if(value>125 && value<130)
                                   {n=0;p=0;}
                        else if(value<=125)
                                    {
                                              n=0;p=1;
                                              delay_msec(6-(value/25));
                                              n=0;p=0;
                                             delay_msec(value/25);
                                    }
                        else if(value>=130)
                                    {
                                               value=255-value;
                                                n=1;p=0;
                                                delay_msec(6-(value/25));
                                                n=0;p=0;
                                                delay_msec(value/25);
                                    }
                        value=read_ADC();
           }          
}

###

 


Circuit Diagrams

Circuit-Diagram-8051-Microcontroller-Based-Dc-Motor-Speed-Controller

Project Video


Filed Under: Electronic Projects
Tagged With: 8051, adc, dc motor, pwm
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Voltage mode pushpull is a nonsense SMPS?
  • Input impedance matching network
  • High Side current sensing
  • The comparison of different Tcl script checkers
  • Reducing "shoot-through" in offline Full Bridge SMPS?

RSS Electro-Tech-Online.com Discussions

  • Is AI making embedded software developers more productive?
  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe