loading
Hey friends this is my 3rd year BE project " Speed control of DC motor"which i could like to share with you .In this you will learn how to interface LCD,hex keypad and motor .The code is written in assembly      
to simplify I have first explained separately LCD interfacing hex keypad interfacing ,motor interfacing with L293D 

so Lets get Started !!!

Step 1: Materials Required

*89S52
*LCD 
*Hex keypad
*DC motor 



I assume u have basic knowledge of 8051 programming in assembly

Step 2: Interfacing DC Motor -L293D

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 we can control speed of each dc motor by giving PWM to enable pin .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 to control speed enable pin is connetcted to the PWM pin of microcontroller . I have connected only one motor and  used the enable pin to contol the speed of dc motor.

Step 3: Interfacing LCD

I will not go in deep with LCD as it is a too vast topic  i have mentioned some sites which are very use full 

    LCD consist of 16 pin 
    Vss-GND
    Vdd-positive voltage
    Vee-contrast setting
    data pin  D0 to D7
    backlight pin LED and LED-

  The LCD requires 3 control lines (RS, R/W & EN) & 8 (or 4) data lines.When RS is low (0), the data is to be treated as a command. When RS is high (1), the data being sent is considered as text data which should be displayed on the screen.
When R/W is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively reading from the LCD. Most of the times there is no need to read from the LCD so this line can directly be connected to Gnd thus saving one controller line.The ENABLE pin is used to latch the data present on the data pins. A HIGH - LOW signal is required to latch the data. The LCD interprets and executes our command at the instant the EN line is brought low. If you never bring EN low, your instruction will never be executed.

 


refrence-
http://www.newbiehack.com/MicrocontrollersABeginnersGuideIntroductionandInterfacinganLCD.aspx
http://www.8051projects.net/lcd-interfacing/
http://www.dnatechindia.com/Tutorial/8051-Tutorial/Interfacing-LCD-to-8051.html

Step 4: Interfacing HEX Keypad

Hex key pad is essentially a collection of 16 keys arranged in the form of a 4×4 matrix. Hex key pad usually have keys representing numerics 0 to 9 and characters A to F.
    The hex keypad has 8 communication lines namely R1, R2, R3, R4, C1, C2, C3 and C4.  R1 to R4 represents the four rows and C1 to C4 represents the four columns. When a particular key is pressed the corresponding row and column to which the terminals of the key are connected gets shorted. For example if key 1 is pressed row R1 and column C1 gets shorted and so on. The program identifies which key is pressed by a method known as column scanning. In this method a particular row is kept low (other rows are kept high) and the columns are checked for low. If a particular column is found low then that means that the key connected between that column and the corresponding row (the row that is kept low) is been pressed. For example if  row R1 is initially kept low and column C1 is found low during scanning, that means key 1 is pressed.

reference
http://www.circuitstoday.com/interfacing-hex-keypad-to-8051

Step 5: Complete Code

Now as we know LCD, hex keypad and L293D interfacing we will now discuss  the flow of program 
    First I have have initialized LCD to display "press E-enter to change PWM " then we enter a loop to generate PWM each time it enters a loop it checks for E-enter ,it remains in this loop until key E is pressed ,once E key is pressed it changes the display to " Enter PWM-" now hex keypad is scanned to get the PWM, a three digit number from 0-255.Now as we now from hex keypad scan  we get three digit ASCII number.first this ASCII number is converted into hex by masking the higher nibble
ANL A,#0FH                     ; MASK HIGHER NIBBLE

now the number we get is converted into three digit number using convert motor
//---------CONVERT MOTOR--------------
CONVERT:
        MOV R3,A      ; SAVE NUMBER IN R3
        MOV A,R1      ;
        MOV    R2,A      ;Put counter in R2
        MOV A,R3      ;PUT THE NUMBER BACK TO A
        

        MUX: MOV B,#10
        MUL AB          ; MULTIPLY 10
        DJNZ R2,MUX       ;depending on position
    
        ADD A,R7
        MOV R7,A
    RET


when first number is entered it is multiplied by 100 then saved in R7 a counter in R1 is used to keep the track of digits place then the second number is multiplied by 10 and added to first number saved in R7 and the number unit place is added to get the PWM

after this execution the program jumps back to LCD to change the display ,and then PWM loop to rotate the motor with new PWM and the cycle continues      
     

 
video
 
finally the complete code,hex file and proteus file is here

 
<p>where is keypad source code?</p>
<p>can i have your report for this project?</p>
<p>here is the proteus simulation of this project.</p><p>Thanx @Sunil93</p>
<p>thanks</p>
<p>when the dc motor will know when they stop ? </p>
<p>I need the keypad Code in C please , I couldn't find it</p><p>can u send it via e-mail ? rukek@shotmail.ru</p>
<p>I tried this project in proteus.But it just glows the lcd &amp; no statement is appearing on lcd.Any help please.<br>assembly k bajay c ka code mil jay ya full code ?</p><p>Reply a little bit quick brothers</p>
<p>I need the keypad Code in C please , I couldn't find it<br>can u send it via e-mail ? aya.elsagheer@gmail.com</p>
<p>1.by desinging the PID controller , can we write a program for Kp,Kv values to 8051.</p><p>2.can we use PID controller in8051 for closed loop speed control of brushless dc motor</p>
<p>you can find the source code here</p><p><a href="http://s4silver.blogspot.in/p/programmers-colony.html" rel="nofollow">http://s4silver.blogspot.in/p/programmers-colony.h...</a></p><p><a href="http://s4silver.blogspot.in/p/8051-interfacing-with-dc-motor.html" rel="nofollow">http://s4silver.blogspot.in/p/8051-interfacing-wit...</a></p>
<p>you can find the source code here</p><p><a href="http://s4silver.blogspot.in/p/programmers-colony.html" rel="nofollow">http://s4silver.blogspot.in/p/programmers-colony.h...</a></p><p><a href="http://s4silver.blogspot.in/p/8051-interfacing-with-dc-motor.html" rel="nofollow">http://s4silver.blogspot.in/p/8051-interfacing-wit...</a></p>
<p>SIR SUGGEST ME</p>
<p>SIR..</p><p>IF THE MOTOR MOTION IS AUTOMATIC, MEANS WHEN CONTROLLER POWER UP, IT KNOWS THE ROUTINE AND IT DOING IT BECAUSE OF FEEDBACK. LIKE IN INDUSTRIES, ROBOT KNOWS ROUTINE AND IT ALWAYS DOING WITHOUT ANY INTERRUPTS.IN SHORT, IT RESERVE FOR ONLY ONE PURPOSE.. SUGGEST ME A GOOD ARTICLE ABOUT THIS AUTOMATIC CODING. </p><p>THANKS....</p>
<p>yes sir.. i have this book. </p><p>thanks for guidence. </p>
<p>THANKS SIR.. THIS IS GOOD ARTICLE.</p><p>SIR MY PROJECT IS THAT A ROBOTIC ARM WHICH ROTATES IN 3 DIRECTION.SIR I WANT THAT I CONNECT LCD WITH 8051 uc &amp; WHEN ROBOTIC ARM GOES ANY DIRECTION, IT SHOWS ON LCD,LIKE IF ARM IS MOVING UP SO THE LINE &quot;ROBOTE MOVING UP&quot; IS DISPLAY ON LCD. IS THIS POSSIBLE??? IS THIS POSSIBLE WITH PROGRAMMING????</p>
<p>Hey buddy its possible ,I recommend you to first learn programming of 8051,better to study C as it is easy then assembly and complex logic can easily be written and debug-ed.</p><p> refer <strong><a href="http://dc302.4shared.com/download/mP3Eg1rm?tsid=20140927-173713-84e205c7&dsid=9sp2f.d7bb195faebaadf7013819252acd1b7f&sbsr=ba0b469cd2f76156a6eb778b582c71c2311bb71ef89f7f3a&forDownloadHelper=true&lgfp=8000&dsid=9sp2f.d7bb195faebaadf7013819252acd1b7f" rel="nofollow">muhammad ali mazide 8051</a> </strong>its a great book you will get LCD code there. </p>
<p>hello sir.....</p><p>this motor has variable speed . if i want to drive in clockwise as well as anticlockwise what the code of this operation????</p><p>also L293d this ic can drive two motors at a time,so if i connect two motors , do both motors rotate at the same time?????</p>
<p>You need only 2 L293D driver IC, actually you can drive 4 motors with two L293D</p>
<p>For changing the direction of the motor you simple need to change the inputs A B of L293D </p><p> yeah you can connect the two motors but to make it rotate you need to connect the AB inputs and Enable2 inputs of second motor. study L293D and all your doubts will be cleared.</p>
<p>HELLO SIR..</p><p>sir if i want to drive 3 motors, can i use 2 l293d to drive 3 ic or we can use 3 ic with one l293d ic??????</p><p>i am making a robotic arm which moves in 3 direction so i have to use 3 motors....</p>
This is an interesting circuit and well made instructable. Note that what you are controlling is the power, not speed, however. For a future development consider adding a feedback loop that measures actually controls the speed.
thanx man........yeah you are right by varying PWM power is controlled

About This Instructable

66,403views

38favorites

License:

More by sunil93:HOME AUTOMATION Interfacing GY 26 with atmega640 Speed control of DC motor with 8051 
Add instructable to: