dolphinlabs
...
Doplhin labs
News

DC Motor Interface


·         Problem Statement: Interfacing of DC motor with 89C51 microcontroller.

Connections: PORT P2.0=IN1, PORT P2.1=IN2 PORT P2.3=EN12.

                                PORT P3.0= push button 1, PORT P3.1 = push button 2

 

 

 

Hardware Connections for 8051 Board:-

1.      Give supply to 8051 board with the help of adapter

2.       Connect +5V pin of 8051 microcontroller to +5V supply and GND pin of 8051 microcontroller to GND pin of supply.

3.      Connect +5V pin of RS232 interface to +5V supply and GND pin of RS232 interface to GND pin of supply.

4.      Connect R2OUT pin of RS232 interface to RXD pin of 8051 and T2IN pin of RS232 interface to TXD pin of 8051.

5.      Connect 12V pin of DC motor interface to +12V supply pin. And GND to GND pin of supply.

6.      Connect EN12 pin to P2.3 of microcontroller and IN1 and IN2 pins to P3.0 and P3.1 respectively.

7.      Connect OUT1 and OUT2 pins of DC motor interface to DC motor.

 

 

 

 

 

 

 

 

 

 

 

 

Circuit Diagram:

 

 

Program Code:

 

 

#include<reg51.h>

sbit IN1=P2^0;                     //define P2.0 as IN1

sbit IN2=P2^1;                     //define P2.1 as IN2

sbit EN12=P2^3;                 //define P2.3 as EN12

sbit sw1=P3^0;                     //define P3.0 as sw1

sbit sw2=P3^1;                     //define P3.1 as sw2

void delay(int);

 

void main()

{

                while(1)

                {

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

                                {

                                //move motor clockwise

                                EN12=1;                                //make EN12 high

                                IN1=0;                                 //make IN1 low

                                IN2=1;                                 //make IN2 as high

                                delay(100);                       //call delay

                                 }

                                else if(sw2==0)

                                 {

                                 //move motor anticlockwise

                                 EN12=1;

                                 IN1=1;

                                 IN2=0;

                                 delay(100);

                                 }

                                 else

                                 EN12=0;                  //motor off

                }

                               

}

void delay(int x)

{

int i,j;

for(i=0;i<255;i++)

for(j=0;j<x;j++);

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Get SOCIAL







SAFE & SECURE SHOPPING

visa card master card maestro card
Maverick IT Industries Pvt. Ltd.