You are on page 1of 10

20/10/2013

Interfacing DC motor to 8051 microcontroller using AT89S51

Home Forums Datasheets Lab Manual Testing Components Buy Project Kits

Electronic Circuits and Diagram-Electronics Projects and Design


Search
Custom Search

DC Motor

Microcontroller

Circuit Projects

Circuit Diagram

Interfacing DC motor to 8051


admin July - 4 - 2012 13 Comments

Pwm Dc Motor Control


www.Analog.com/Power-App-Bulletin

Save Your System From Overvoltage Faults. Get ADI Power Guide Here.
This article shows how to interface a DC motor to an 8051 microcontroller. Interfacing DC motor to 8051 forms an essential part in designing embedded robotic projects. A well designed 8051-DC motor system has essentially two parts. Firstly an 8051 with the required software to control the motor and secondly a suitable driver circuit. Most of the DC motors have power requirements well out of the reach of a microcontroller and more over the voltage spikes produced while reversing the direction of rotation could easily damage the microcontroller. So it is not wise to connect a DC motor directly to the microcontroller. The perfect solution is to use a motor driver circuit in between the microcontroller and the DC motor.

L293 motor driver.


L293 is a dedicated quadruple half H bridge motor driver IC available in 16 pin package. To know more about H bridge, check this link. H bridge motor driver circuit. L293 has a current capacity of 600mA/channel and has supply voltage range from 4.5 to 36V DC. They are fitted with internal high speed clamp diodes for inductive spike protection. Other good features of L293 are high noise immunity, internal ESD protection, thermal shutdown, separate input supply for each channel etc. The pinout and truth table of an L293 motor driver is shown in the figure below.

L293 pinout and function diagram

Bi directional DC motor using 8051.


This project describes a bidirectional DC motor that changes its direction automatically after a preset amount of time (around 1S).
www.circuitstoday.com/interfacing-dc-motor-to-8051 1/10

20/10/2013

Interfacing DC motor to 8051 microcontroller using AT89S51

AT89S51 is the microcontroller used here and L293 forms the motor driver. Circuit diagram is shown below.

Bi directional DC motor using 8051 In the circuit components R1, S1 and C3 forms a debouncing reset circuitry. C1, C2 and X1 are related to the oscillator. Port pins P1.0 and P1.1 are connected to the corresponding input pins of the L293 motor driver. The motor is connected across output pins 3 and 6 of the L293. The software is so written that the logic combinations of P1.0 and P1.1 controls the direction of the motor. Initially when power is switched ON, P1.0 will be high and P1.1 will be low. This condition is maintained for a preset amount of time (around 1S) and for this time the motor will be running in the clockwise direction (refer the function table of L293). Then the logic of P1.0 and P1.1 are swapped and this condition is also maintained for the same duration . This makes the motor to run in the anti clockwise direction for the same duration and the entire cycle is repeated. Program.
O R G0 0 H/ /i n i t i a ls t a r t i n ga d d r e s s M A I N :M O VP 1 , # 0 0 0 0 0 0 0 1 B/ /m o t o rr u n sc l o c k w i s e A C A L LD E L A Y/ /c a l l st h e1 SD E L A Y M O VP 1 , # 0 0 0 0 0 0 1 0 B/ /m o t o rr u n sa n t ic l o c k w i s e A C A L LD E L A Y/ /c a l l st h e1 SD E L A Y S J M PM A I N/ /j u m p st ol a b e lM A I Nf o rr e p a e t i n gt h ec y c l e D E L A Y :M O VR 4 , # 0 F H W A I T 1 :M O VR 3 , # 0 0 H W A I T 2 :M O VR 2 , # 0 0 H W A I T 3 :D J N ZR 2 , W A I T 3 D J N ZR 3 , W A I T 2 D J N ZR 4 , W A I T 1 R E T E N D

Bidirectional motor with pushbutton control.


The circuit shown below is of an 8051 based bi directional motor whose direction can be controlled using 2 push button switches. The circuit is very similar to the previous one except for the two push button switches . These pushbutton switches are interfaced to P0rt 3 of the microcontroller. Resistors R2 and R3 are the pull down resistors for P3.0 and 3.1 respectively.

www.circuitstoday.com/interfacing-dc-motor-to-8051

2/10

20/10/2013

Interfacing DC motor to 8051 microcontroller using AT89S51

Push button controlled bi-directional DC motor The code for the above project is so written that initially when power is switched ON, the motor remains OFF. When push button switch S2 is pressed P1.0 goes high and P1.1 remains low. The motor runs in the clockwise direction and this condition is maintained until S3 is pressed. When push button switch S3 is pressed the logic of P1.0 and P1.1 toggles making the motor to run in the opposite direction and this condition is maintained until the next press of S2. Program.
O R G0 0 H/ /i n i t i a l ls t a r t i n ga d d r e s s M O VP 3 , # 0 0 0 0 0 0 0 0 B/ /i n i t i a t e sP 3a st h ep u s h b u t t o ni n t e r f a c e M O VP 1 , # 0 0 0 0 0 0 0 0 B/ /c l e a r sP 1f o rk e e p i n gt h em o t o rO F Fi n i t i a l l y M A I N : M O VA , P 3/ /m o v e st h ec u r r e n ts t a t eo fP 3t oA c c u m u l a t o r C J N EA , # 0 0 0 0 0 0 0 1 B , L A B E L 1/ /c h e c k sw h e t h e rS 2i sp r e s s e d M O VP 1 , # 0 0 0 0 0 0 0 1 B/ /m a k e st h em o t o rr u nc l o c k w i s e L A B E L 1 : C J N EA , # 0 0 0 0 0 0 1 0 B , L A B E L 2/ /c h e c k sw h e t h e rS 3i sp r e s s e d M O VP 1 , # 0 0 0 0 0 0 1 0 B/ /m a k e st h em o t o rt or u na n t ic l o c k w i s e L A B E L 2 : S J M PM A I N/ /j u m p sb a c kt ot h eM A I Nl o o p E N D

About the program. Checking whether a particular push button is pressed is done using the CJNE (compare and jump if not equal) instruction. In simple words the CJNE instuction compares two operands and jump to a predefined LABEL if the operands are not equal. If the two operands are equal nothing happens and the next instruction is executed. Whenever push button S2 is pressed the status of P3 will be 00000001B .This status is moved to accumulator A and compared with 00000001B using the CJNE instruction. Both operands are equal means S2 is pressed and the next instruction (MOV P1,#00000001B) which makes the motor run clockwise is executed. If the operands are not equal that means the S2 is not pressed and the controller jumps to LABEL1 which is to check the S3. To check S3, status of P3 is moved to A again and it is compared with 00000010B using the CJNE instruction. Both operands are equal means the S3 is pressed and the next instruction (MOV P1,#00000010B) which makes the motor run anti clockwise is executed. Both operands are not equal means S3 is not pressed and the controller goes to check S2 again and this cycle is repeated.

Notes.
The maximum current capacity of L293 is 600mA/channel. So do not use a motor that consumes more than that.
www.circuitstoday.com/interfacing-dc-motor-to-8051 3/10

20/10/2013

Interfacing DC motor to 8051 microcontroller using AT89S51

The supply voltage range of L293 is between 4.5 and 36V DC. So you can use a motor falling in that range.

You may also like:


Interfacing hex keypad to 8051 Delay using 8051 timer Software delay routine in 8051 microcontroller Random number generator using 8051 Voltmeter using 8051

We recommend:
1KHz IR transmitter circuit. Voltmeter circuit using LED Digital compass circuit 20W audio amplifier using LM1875 4 X 15 Watt power amplifier
Search
Custom Search

Posted in 8051 Tags: interfacing DC motor to 8051

Leave a Reply
Name (required) Mail (will not be published) (required) Website

Submit Comment

13 Responses to Interfacing DC motor to 8051


www.circuitstoday.com/interfacing-dc-motor-to-8051 4/10

20/10/2013

Interfacing DC motor to 8051 microcontroller using AT89S51

archana says: September 19, 2013 at 1:00 am thanks for such a nice explanation.. Reply Khan says: April 28, 2013 at 8:39 am Hello sir, how we can send the above program to Micro controller and in what format? for example run the program on MASM and then send .exe , .obj , or .asm file or just copy and paste the program and send to Micro controller. pleas reply me quickly as possible. Reply Hareem Ashraf says: May 3, 2013 at 4:45 am You have to create a .hex file of your code. You can use Keil for this purpose. In proteus you have to add that .hex file in your micro controllers program file. Reply Nora says: April 22, 2013 at 11:07 am Nice work. I enjoyed reading it Reply dd_student says: February 22, 2013 at 1:21 am Im using stepper motor instead of DC motor, i hope you can help me.\ what is the interfacing of Stepper motor to 8051?IM BUILDING A MATURE OF THREE STOREYs elevator Reply Manu. says: July 5, 2012 at 11:57 pm Dear Sir, for one year onwards im working to design one auto programmable dental furmace with 555 timer ic & h bridge using p& n channel mos: , and i made it working, but some missfiring is occuring , from the time being im searching for a microcontroller circuit for controlling each & every action and now im very happy to get 8051 circuits.once more im thanking you Reply jojo says: July 9, 2012 at 7:07 am Thank you Manu. Hope your new attempt would work well Reply Elex Wood says: July 5, 2012 at 1:47 am Thanks Jojo. Every time I read your article..It Let me Know lot of Knowledgeable stuffs ..Great Article Reply jojo says: July 9, 2012 at 7:06 am Thank you Elex for the nice words
www.circuitstoday.com/interfacing-dc-motor-to-8051 5/10

20/10/2013

Interfacing DC motor to 8051 microcontroller using AT89S51

Reply jojo says: July 4, 2012 at 7:46 pm @MROHM Thanks for the nice words Reply MROHM says: July 4, 2012 at 4:28 pm VERY GOOD ARTICLE,,I learned a lot,,Thanks!!! Reply dennis says: July 9, 2012 at 1:31 am very good article.but which programming language have you used Reply jojo says: July 9, 2012 at 7:05 am The codes are written in assembly language. Read more here:- http://en.wikipedia.org/wiki/Assembly_language Reply

Get Daily Updates via Email


Enter your email Subscribe

Latest Articles
Object counter using 8051 Zener Diode Invention History & Story Behind the Development Shockley Diode Invention History Digital Count Down Timer using PIC Microcontroller Digital Voltmeter using Micro Controller PIC16F73A DatasheetLib A new Datasheet Database Website to revolutionize Datasheet Discovery Solar Cell Invention History & Story From Selenium to Silicon Vacuum Tube Invention History and Story behind Invention Integrated Circuit Invention History and Story Behind the Scenes Introduction to MATLAB Tutorial

www.circuitstoday.com/interfacing-dc-motor-to-8051

6/10

20/10/2013

Interfacing DC motor to 8051 microcontroller using AT89S51

Categories
101-Announcements 555 Timer IC 8051 8051 projects Amplifier Circuits Arduino Audio Circuits Automotive Circuits AVR Basic Electricity Basic Electronics Battery Circuits C plus plus C Programming Cable TV Circuits Camera Technology Clipping and Clamping Circuits Clocking & Timer Circuits Conversion Circuits Counter Circuits Counters Digital Electronics Education & Training Electronic Components Electronic Keys & Locks Electronics Books Electronics Jobs Embedded Systems Equipment Reviews Events Fan Circuits Filter Circuits Fire Alarm Fun & Game Circuits Gadget Reviews Ham Radio Circuits High Voltage Circuits History Home Circuits Industrial Circuits Instruments Integrated Circuits Inverters Lab Manuals
www.circuitstoday.com/interfacing-dc-motor-to-8051 7/10

20/10/2013

Interfacing DC motor to 8051 microcontroller using AT89S51

LED related Light Related Lighting Circuits MATLAB Microcontrollers Mobile Phone Related Motor Related Nanotechnology Oscillators Peripheral Interface Controller (PIC) Power Controller Circuits Power Electronics Power Supplies Project Ideas Projects Proximity Detectors Radio Circuits Radio Transmitters Raspberry Pi Relays Remote Circuits Reviews Robotics RTOS Security & Saftey Sensor Circuits Signal Conditioners Signal Generators Speed Controller Circuits State space analysis Switching Circuits Tech News Telephone Related Television Related Temperature Related Test & Measurement Circuits Testing Components Three phase circuits Timer Circuits Tone generator circuits Tools and Softwares Transmitters Tutorials UPS USB Circuits Videos VLSI Voltage Regulators

Like Us on Facebook

www.circuitstoday.com/interfacing-dc-motor-to-8051

8/10

20/10/2013

Interfacing DC motor to 8051 microcontroller using AT89S51

Circuitstoday.com
Like 17,720 people like Circuitstoday.com.

Facebook social plugin

Recent Comments
Seetharaman on Passive tone control circuit Seetharaman on Passive tone control circuit Rex on Passive tone control circuit shegzzyy on Object counter using 8051 safoor on Object counter using 8051 Sudheer on Electronics circuit drawing softwares yao on Contactless telephone ringer circuit Seetharaman on Water level alarm circuit Sudheer on Water level alarm circuit Seetharaman on Motional feed back amplifier Seetharaman on Motional feed back amplifier sandeep on Motional feed back amplifier Seetharaman on Battery operated heater Seetharaman on Power megaphone circuit Seetharaman on Simple 100W inverter circuit

Pages
About Advertise With Us Authors Buy Project Kits Datasheets Electronic Circuit Symbols Lab Manuals Electronic Circuits Lab Microcontroller lab Microprocessor Lab Privacy Policy Project Contests Sitemap Testing Components

Popular Tags
circuits circuit design circuit diagram Electronic Circuits Electronic Components Electronic Instruments Filter Circuits hobby circuits hobby projects Home Circuits IC
555 IC

555 timer Audio Amplifier Circuits Audio

NE555 timer Oscillators PIC Power Amplifiers Power Supplies Radio Circuits SCR Simple Electronics Projects Tech News Thyristors Tutorials VLSI Voltage Regulators
Integrated Circuits Most Popular Circuits Nanotechnology

Most Discussed
www.circuitstoday.com/interfacing-dc-motor-to-8051 9/10

20/10/2013

Interfacing DC motor to 8051 microcontroller using AT89S51

150 Watt amplifier circuit 100 Watt sub woofer amplifier. Automatic LED Emergency Light-Modified Version Mains Operated LED Circuit 2 km FM transmitter Suggest a Topic to Publish & Win a 8GB Pen Drive Automatic LED Emergency Light Copyright 2007 - 2011 Circuitstoday.com Designed by Web Design Cochin

www.circuitstoday.com/interfacing-dc-motor-to-8051

10/10

You might also like