Showing posts with label Interfacing of DC motor. Show all posts
Showing posts with label Interfacing of DC motor. Show all posts

Saturday, February 15, 2014

SIMPLE INTERFACING OF DC MOTOR TO 8051

SIMPLE INTERFACING OF DC MOTOR TO 8051
  • In this method we are using a Motor driver IC (L293D). It is Driver which provide supply to motor (up to 12V) and prevent the microcontroller from motor Back EMF problem.
  • In our program we are using 3 pin of L293D that are en1, in1 and in2 for driving a motor. We must give a supply of 6V or 12V to Vss pin and 5V to Vs pin.
  • In1 and in2 are two pin which control the clockwise direction of motor.




















  • En1 pin enable in1 and in2 or enable one side of IC’s Bridge, because it has two bridge which are control by en1 and en2.
  • En1 control in1 and in2, En2 control in3 and in4 pin of IC.
  • So we have assigned the Pin of Port0 i.e. P0.0 = in1, P0.1 = in2,P0.2 = en1.
  • So to enable the circuit en1 must always be 1 or (high).
  • And for Clockwise in1 = 1 and in2 = 0.

  • For Counter-Clockwise in1= 0 and in2 = 1.





















  • So here is program for DC motor.


//--------------------------------------------------------------------------------------------------------//
#include<reg51f.h>

sbit in1 = P0^0;     //----Assigning Pin0 of PORT 0 as input 1 for motor
sbit in2 = P0^1;     //----Assigning Pin1 of PORT 0 as input 2 for motor
sbit en1 = P0^2;    //----Assigning Pin2 of PORT 0 as input 3 for enabling the driver IC
//--------Main Program-----------//
void main()
{
P0 = 0x00;           //----Assigning Port 0 as Output
en1 = 1;               //----Driver IC is enabled
while(1)               //----Creating Super loop
{
//-----To rotate motor in clockwise direction----//
in1 = 1;               //----Input 1 given as high
in2 = 0;               //----Input 2 given as low
}                        //----End of Super loop
}

//---------End of main program--------//
//---------------------------------------------------------------------------------------------------------//
Program:click for code

For video on above example:Click for video