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

Wednesday, April 2, 2014

INTERFACING OF LCD IN 4-BIT MODE USING MICROCONTROLLER


INTERFACING OF LCD IN 4-BIT MODE USING MICRO-CONTROLLER

In this method of Interfacing LCD to Microcontroller using 4-bit mode is to reduce the usage of pin.

Mostly the Circuit having multiple function uses this method.

In this method PORT0 of UC is connected to LCD as Follows:

P0.0 => rs;    Register select Pin
P0.1 => en;  Enable Pin
P0.4 => D4;  data line
P0.5 => D5;         “
P0.6 => D6;         “
P0.7 => D7;         “

In method we use same port for control pin as well as data line. So each data is send by breaking it into two 4bit part.

To initialize LCD in this method a command used is 0x28

Which means 16 x 2 LCD in 4-bit mode.

Before doing that we should send a sequence of 0x30, 0x30, and 0x20.

To send this we use only cmd_hf function which send only 3, 3, and 2 as sequence to LCD to enable in 4-Bit mode.

To send each data we should first clear the higher order bit i.e. from P0.4 – P0.7

And masking the input is properly shown in video.

  • We should mask Higher bit and rest all bit are clear.
  •  We send by latching.
  • We should now mask lower bit and send to UC.




This is how a 4-Bit mode LCD works.
Thank you for reading.
Plz Do share and Subscribe.

Source Code: click for code
For Videos on this Example: Click on the link








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