Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

Pwm for motor speed control using 8051

Status
Not open for further replies.

natasie

Member level 2
Joined
Jul 11, 2011
Messages
49
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,643
hey,
please i need help with PWM asm code for dc motor speed control. i found a code and edited it and it works but there is still a lot of problems. the code that works is this:
ORG 00H
AJMP START


LOW_DONE:
SETB F0 ;F0=1 TO INIDICATE START OF HIGH SECTION
SETB P1.1 ;TURN OFF LED
MOV TH0, R7 ;LOAD HIGH BYTE OF TIMER WITH R7 (OUR PULSE WIDTH CONTROL VALUE)
CLR TF0 ;CLR TO FLAG

TIMER0:
JB F0, HIGH_DONE ;F0 IS SET WHEN THE HIGH SECTION OF THE CYCLE IS DONE SO JUMP TO HIGH_DONE
;
HIGH_DONE: ;
CLR F0 ;F0=0 TO INDICATE THE START OF LOW SECTION
CLR p1.1 ;TURN OFF LED
MOV A, #0FFH ;MOVE 255 TO A
CLR C ;CLR CARRY BIT
SUBB A, R7 ;SUBTRACT R7 FROM A i.e. 255-R7
MOV TH0, A ;SO THE VALUE LOADED INTO TH0+R7=255
CLR TF0 ;CLR THE TIMER 0 FLAG INTR
AJMP LOOP
START:
MOV PSW, #00H
LOOP:
;SET PULSE WIDTH TO DIM
SJMP LOW_DONE

END
but it is clearly not correct even though when i connect the motor to p1.1, there is a decrease in motor speed but the porblem is that the code still has instructions for timer 0 and i do not know how to edit it and remove the codes. please help, i rily do not know anything abt pwm programming.
 

js

Full Member level 5
Joined
Oct 9, 2005
Messages
265
Helped
38
Reputation
76
Reaction score
36
Trophy points
1,308
Activity points
2,662
1st:
Wich type of micro 8051 is this? Please write exact name!

2nd:
What are sour needs? Or you maybe only experimenting?
 

natasie

Member level 2
Joined
Jul 11, 2011
Messages
49
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,643
this is an 89c51 atmel. i want to be able to generate pwm signals from the microcontroller using the timer0. if you can help me with a code very urgently, i will be very greatful.
 

natasie

Member level 2
Joined
Jul 11, 2011
Messages
49
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,643
thankyou for the tutorials, it was very helpful,
but then again, from the codes given, which i already tried, it does not call the T0 ISR so the motor doesnt receive any low or high signal and hence doesnt slow down.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top