DC motor interfacing using AT89C51RD2

SIMULATOR: PROTEUS 8.0

SOFTWARE: KEIL 4.0

CIRCUIT DIAGRAM:


PIN DESCRIPTION of L293D:

VSS and VS: +5v to +9v

GND: GND

EN1: Enable pin of motor 1

EN2: Enable pin of motor 2

IN1 and IN2: Input pin of motor 1

IN3 and IN4: Input pin of motor 2

OUT1 and OUT2: Output pin of motor 1

OUT3 and OUT4: Output pin of motor 2

CIRCUIT DESCRIPTION:

EN1 and EN2 are the enable pins of dc motor 1 and dc motor 2 respectively. Both the enable pins must be connected to VCC to run the dc motors.

IN1and IN2 pins are connected to p2.0 and p2.1 respectively.IN3 and IN4 pins are connected to p2.3 and p2.4 respectively.OUT1 and OUT2 pins are connected to dc motor1.OUT3 and OUT4 pins are connected to dc motor2.

Switch 1 and Switch 2 are connected in pull-up arrangement to port1.0 and port 1.5 respectively.

WORKING:

In this project, I have interfaced two dc motors using the AT89c51RD2 controller. Motor driver L293D is used to drive both the dc motors.

Whenever switch1 is pressed, dc motor1 will rotate in a clockwise direction and dc motor2 will rotate in an anti-clockwise direction.

Whenever switch2 is pressed, dc motor1 will rotate in an anti-clockwise direction and dc motor2 will rotate in a clockwise direction.

PROGRAM:

#include<reg51.h>

void delay(unsigned int t); // delay function

sbit IN1 = P2^0; // input pin for dc motor1

sbit IN2 = P2^1; //input pin for dc motor1

sbit IN3 = P2^3; //input pin for dc motor2

sbit IN4 = P2^4; //input pin for dc motor2

 

sbit sw1 = P1^0;

sbit sw2 = P1^5;

 

int main()

{

while(1)

{

if(sw1 == 0)  // switch1 is pressed

{

// Dc motor 1 in a clockwise direction

IN1 = 1;

IN2 = 0;

// Dc motor 2 in  an anti-clockwise direction

IN3 = 0;

IN4 = 1;

 

delay(100);

 

}

else if(sw2 == 0)  // switch2 is pressed

{

// Dc motor 1 in an anti-clockwise direction

IN1 = 0;

IN2 = 1;

// Dc motor 2 in a clockwise direction

IN3 = 1;

IN4 = 0;

 

delay(100);

}     

else

{

If( (sw1 == 1)&&(sw2 == 1) )  // both switches are in off state

{

// Both the dc motors remain in the off state

IN1 = 0;

IN2 = 0;

IN3 = 0;

IN4 = 0; 

}

}

}

}

void delay(unsigned int t) // delay subroutine

{

unsigned int i;

for(i=0;i<1275*t;i++);

}

PROGRAM DESCRIPTION:

For rotating dc motors in a clockwise direction, I have provided logic 1 to the first input pin(IN1, IN3) and logic 0 to the second input pin(IN2, IN4) of dc motors.

For rotating dc motors in an anti-clockwise direction, I have provided logic 0 to the first input pin (IN1, IN3) and logic 1 to the second input pin(IN2, IN4) of dc motors.

To make both the dc motors in the off-state logic 0 is provided to all the input pins of dc motors.

VIDEO:



Comments

Popular posts from this blog

Digital Thermometer using 8051 and ADC 0808 Interfacing With 8051

how to display numbers on lcd?

To display custom characters on the lcd using 8051 micro-controller.