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.

DC motor control using 89S51

Status
Not open for further replies.

niranjan23

Member level 5
Joined
Jan 22, 2012
Messages
94
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Activity points
2,109
hello
I am doing bi-directional DC motor control circuit using AT89S51 , I used 2 push button switches for Clockwise and Anti-clockwise

the program and circuit for this is given at the end of the Thread

My problem is when I push the button for clock-wise, motor is keep rotating

I want ,when I press the button motor is rotate and when I leave the button motor stop rotating...

tell me what changes i have to do...???

Program
org 0000h
mov p1,#00h/////Intial value
mov p3,#00h//// make P3 as output
main:mov a,p1
cjne a,#01h,go1//////makes the motor run clockwise
mov p3,#01h
go1:cjne a,#02h,go2/////makes the motor to run anti clockwise
mov p3,#02h
go2:sjmp main
end

Circuit diagram
interfacing-dc-motor-8051-push-button.png
 

Just change your code such that when Switch input pin is high or low then run motor or else if input is low or high stop motor. I have mentioned high and low to start motor because it depends how your switch is connected and when do you want to run or stop the motor i.e., you can run or stop the motor if switch input is either high or low.

Lets assume that P3.0 is for Clockwise rotation and P3.1 is for anticlockwise rotation. When p3.0 or P3.1 is high (logic 1) run the motor. If P3.0 or P3.1 is low (logic 0) stop the motor.

P3 is used as input. Why are you assigning values #01h and #02h to P3?

Try this code.

Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
org 0000h
mov p1,#00h             ;Intial value
mov p3,#00h             ;make P3 as output 
main:mov a,p3
cje a,#00h,stop         ;if switches not pressed then stop
cjne a,#01h,go1         ;makes the motor run clockwise
mov p1,#01h
sjmp main
go1:cjne a,#02h,go2     ;makes the motor to run anti clockwise 
mov p1,#02h
go2:sjmp main
stop:mov P1,#00h        
sjmp main
end

 
Last edited:

thankyou for help sir....

but I have one question..... is "cje" instruction exists..becaz i? haven't see in instruction set of 8051...?

And my simulator can't accept cje...it gives error...."Unknown keyword "

there is any more changes...??
 

No. It doesn't exist. Change it using cjne to jump to stop condition.


Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
org 0000h
mov p1,#00h             ;Intial value
mov p3,#00h             ;make P3 as output 
main:mov a,p3
cjne a,#00h,go3        ;if switches not pressed then stop
mov P1,#00h 
sjmp main
go3:cjne a,#01h,go1         ;makes the motor run clockwise
mov p1,#01h
sjmp main
go1:cjne a,#02h,go2     ;makes the motor to run anti clockwise 
mov p1,#02h
go2:sjmp main
end

 
Last edited:
thankyou very much sir ....it is useful for me..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top