Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Programming of 8051 to control dc motor

Status
Not open for further replies.

jkjut

Newbie level 5
Joined
Mar 4, 2012
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
pakistan
Activity points
1,341
Hy, i am facing problem in controlling dc motor.I wants when i will apply 1 at p1^1 then 2 motor which is connected at p2^0 and p2^1 and at p2^2 and p2^3 moves. otherwise remain off. Plz guide me. how can i do??????????????? my programming. plz check it


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <reg51.h>
sbit rotate = P1^0;
sbit square = P1^1;
sbit mtr_0 = P2^0;
sbit mtr_1 = P2^1;
sbit mtr_2 = P2^2;
sbit mtr_3 = P2^3;
 
void timer(int msec)     
{
int i;
 
for(i=0;i<msec;i++)
 
{
TMOD=0x20;         
TH1=0xFF;
TL1=0xD1;
 
TR1=1;
while(TF1==0);
TF1=0;
TR1=0;
}
}
void main()
{
 
 
mtr_0=0;
mtr_1=0;
mtr_2=0;
mtr_3=0;
 
 
 
 
 
if(square==1)
{
mtr_2=0;
mtr_3=1;
mtr_0=1;
mtr_1=0;
 
 
 
 
}
 
}

 
Last edited:

what do you mean by applying... R u pressing switch/ giving ASCII value to RX port....
B clear about Your Problem....
What do you want to do exactly...
 

Hy, i am facing problem in controlling dc motor.I wants when i will apply 1 at p1^1 then 2 motor which is connected at p2^0 and p2^1 and at p2^2 and p2^3 moves. otherwise remain off. Plz guide me. how can i do??????????????? my programming. plz check it


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <reg51.h>
sbit rotate = P1^0;
sbit square = P1^1;
sbit mtr_0 = P2^0;
sbit mtr_1 = P2^1;
sbit mtr_2 = P2^2;
sbit mtr_3 = P2^3;
 
void timer(int msec)     
{
int i;
 
for(i=0;i<msec;i++)
 
{
TMOD=0x20;         
TH1=0xFF;
TL1=0xD1;
 
TR1=1;
while(TF1==0);
TF1=0;
TR1=0;
}
}
void main()
{
 
 
mtr_0=0;
mtr_1=0;
mtr_2=0;
mtr_3=0;
 
 
 
 
 
if(square==1)
{
mtr_2=0;
mtr_3=1;
mtr_0=1;
mtr_1=0;
 
 
 
 
}
 
}

I want to rotate car in circle, which has two motors. one have to move 4wrd continously, the other have to rotate tyres at one side

---------- Post added at 17:03 ---------- Previous post was at 16:59 ----------

I want to rotate car in circle. there r 2 motors in car. one have to move 4 wrd, the other have to rotate tyre continuosly..

---------- Post added at 17:07 ---------- Previous post was at 17:03 ----------

I wants that if p1^1 =1 then car rotate. plz guide me.........
 

Code:
#include <reg51.h>
sbit input = P1^0;//your input pin
sbit mtr_0 = P2^0;
sbit mtr_1 = P2^1;
sbit mtr_2 = P2^2;
sbit mtr_3 = P2^3;
 

void main()
{
 
 
mtr_0=0;
mtr_1=0;
mtr_2=0;
mtr_3=0;
 
while(1)
{ 
 
 
 
if(input==1)
{
mtr_2=0;
mtr_3=1;
mtr_0=1;
mtr_1=0;
}
else
{
 mtr_2=0;
mtr_3=0;
mtr_0=0;
mtr_1=0;
}
}
}
 

I m facing just same prblm. Both motors rotates without noticing input. If u send me your email address then i will b able to send you project on proteus
 

aameer_syed@yahoo.co.in

---------- Post added at 15:08 ---------- Previous post was at 13:49 ----------

Declare input=0 in the beginning of main function for the above program

Code:
void main()
{
input=0;
mtr_0=0;
mtr_1=0;
mtr_2=0;
mtr_3=0;
while(1)
{
//Repeat the above program
}
 

Thanks for ur guidance. Now it,is working properly.
 

hy, i used ULN2803 ic to derive motor with microcontroler. Bt this ic can't drive motor. Plz tell me about ic which can derive small Dc motor.
 

I used Uln 2803 ic. Bt it is not giving enough voltage to rotate moter.Now i will try with L293D
 

Dc motor control using 8051

I want to derive dc moter of 5 volt from 8051. I have oposite polarity on two pins of controler. I connected these pins with uln2803 and connected motor with output terminals bt motor is not working. I also grounded 8th pin of 2803 and provide supply at 9. Plz guide me.
 

Re: Dc motor control using 8051

The ULN2803 has open-collector outputs. The emitters of the output transistors are connected to ground internally. It is a basic npn transistor switch.

That means that when an output is 'on', the output pin is actually connected to ground through the turned-on output transistor. When the output is 'off', the transistor is turned off, and no current can flow.

So, to connect a device to an output pin, it must be connected between Vcc and the output pin.

It sounds like you are trying to reverse the motor with the opposite polarity. What you need to use is called an H-bridge circuit. A quick google will bring up countless circuits.
 

Re: Dc motor control using 8051

Can i use L293D ic to move motor in reverse polarity?????????
 

Re: Dc motor control using 8051

From a quick look at the datasheet, yes, that's what it's for. Connect as shown in the datasheet.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top