DC Motors are small, inexpensive and powerful motors used widely in robotics for their small size and high energy out. A typical DC motor operates at speeds that are far too high speed to be useful, and torque that are far too low. Gear reduction is the standard method by which a motor is made useful .Gear’s reduce the speed of motor and increases the torque.

Choosing a DC Motor Depends on application.Prefer following:

  • DCMotor with Gear head
  • Operating voltage 12V
  • Speed

Drive basics of DC Motor

Red wire Black wire Direction of rotation
Positive Negative Clock wise
Negative Positive Anti clock wise
Logic Logic Direction
1 0 Clock
0 1 Anti clock
Direction Pulse to
Clock wise A and C
Anti Clock wise B and D

Bi-Direction control of DC Motor

H-Bridge Circuit using transistors for bidirectional driving of DC motor. H-Bridges in IC’s to reduce the drive circuit complexity . L293D is a dual H-Bridge motor driver, So with one IC we can interface two DC motors which can be controlled in both clockwise and counter clockwise direction and if you have motor with fix direction of motion the you can make use of all the four I/Os to connect up to four DC motors. L293D has output current of 600mA and peak output current of 1.2A per channel. Moreover for protection of circuit from back EMF ouput diodes are included within the IC. The output supply (VCC2) has a wide range from 4.5V to 36V, which has made L293D a best choice for DC motor driver.

As you can see in the circuit, three pins are needed for interfacing a DC motor (A, B, Enable). If you want the o/p to be enabled completely then you can connect Enable to VCC and only 2 pins needed from controller to make the motor work.

**To Move the motor Clockwise And Anticlockwise,Must be use two separate Power source,one for microcontroller and another for driving motor with Driver IC.

Here,i have used ATMEGA32 micrcontroller and  Code is written in C  using AVR Studio 5.0.

Source Code

/*
* DCMotorControl.c
*
* Created: 4/1/2011 12:08:10 AM
*  Author: sfg
*/

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
DDRD=0xFF; //PORTD declared as output
PORTD=0x00;
DDRB=0x00; //PORTB as input
while(1)
{

//Pin 0 of PORTB high,then Moves Clockwise
//A–1–PD0
//B–0–PD1
//Enable–1–PD2
if(PINB==0x01)
{
PORTD=0x05;
//_delay_ms(5000);
}
//Pin 0 of PORTB Low,then Moves AntiClockwise
//A–0–PD0
//B–1–PD1
//Enable–1–PD2
else
{

PORTD=0x06;
//_delay_ms(5000);
}
}
}

Circuit Diagram

Advertisements

Comments on: "DC Motor Interfacing With Micrcontroller" (23)

  1. hereyougo1979 said:

    This is what I have been looking for. I am working on a project of my own and I have forgot totally how to program the 8051. I took it in school about 13 years ago and now I am doing a personal project that I want to use a Pot that is read by the 8051 and then adjusts the speed of a DC motor (just not a Stepper motor) through a power transistor. Is there any place to start to relearn the programming for this?

    I do have a trainer and I have Keil uVision4 demo program.

    Any help you would like to give me would be greatly appreciated.

    Thank you

    Jeff

  2. So many tutorials available in the internet.You can follow one of these.

    Anyway,
    You can get great help from Ali Mazidi’s book.So, collect it.
    Book’s Name:The 8051 Microcontroller and Embedded Systems: Using Assembly and C

    or You will get some help from following link:
    http://ikalogic.com/tut_8051_1.php
    http://www.8051projects.net/keil-c-programming-tutorial/writing-simple-c-program.php

  3. can i get this in C lang for pic16F877A??
    thanx
    ZAM

  4. hereyougo1979 said:

    Thank you for the places to start I will take a look at these and study them when I get a second to my self.

  5. Hi friends,

    Really this is amazing blog post. I saw and read your site; this site is useful to traders.I know that it will help me in my own trading.Thanks for sharing this information which i was looking for since many days and finally got it from this site.Keep on sharing new information..more and more..

  6. Hi every one.Nice effort dude keep it up……….. My blog is

    http://ingenuitydias.blogspot.com/

    These blog may be helpful to you .
    thank you

  7. sir,can i get c code for at89c51 interfacing with dc motor ?

  8. hi sir,
    i am doing voice controlled wheel chair and i want some help for c code
    can i get c code for arduino uno to interface with dc motor…
    quick reply appreciated sir

  9. hey can u give me the code of DC Motor Interfacing With Micrcontroller in c/keil
    or mail at hasnain.bsee1344@iiu.edu.pk

  10. can u provide me the code for 12v dc gear motor interfacing with microcontroller AT89s52 in c using keil software
    and if s mail me at balathimmaiah963@gmail.com

  11. rahul arora said:

    if we are having four leds n we hv to blink them in series with last one rrmaining on with delay and then the secnd last one remains on n so on…what would be the program fr tht?plz repli tdy nly…….asap

  12. Harshitha T said:

    hey can send c program for automatic speed control of DC motor using PWM technique using AT89s52

    or mail me to
    msharshithagowda@gmail.com

  13. Gobinda Mozumder said:

    if you have avr micro controller motor driving code in proteus please send me.it’s helps me very much

  14. kavitha nallusamy said:

    can i get c code for interfacing dc motor with pic16F877A using L293D

  15. hii..can i have c programming code for H bridge motor control with pic18F45K22? thanks

  16. how to move left and right commonds suggest

  17. HELLO SIR. I WANT TO ASK THE PRACTICAL APPLICATION OF CONTROLING SPEED OF DC MOTOR, ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: