solution needed
Discussion in "Project Help" started by snehasish Nov 2, 2007.
Fri Nov 02 2007, 02:55 pm
problem statement is: every 2secs the led connected to p2.7 pin is turned on and off 4 times while at the same time 8051 is getting data from p1 and sending it to p0 continiously. make sure each on and off states are 50 ms in duration.....
please provide the solution......
please provide the solution......
Fri Nov 02 2007, 04:44 pm
use timers.. i guess you want 500mS not 50mS
as 500x4 = 2000mS = 2S
I am confused can you confirm the sequence of LED?
first 2 sec cycle
LED on
delay 500mS
LED off
delay 500mS
LED on
delay 500mS
LED off
delay 500mS
Second 2 Sec cycle
LED off
Is the sequence correct? as you wanted? and the above sequence can be done in the background using timer and interrupts.. the 2 sec cycle can be done by running 500mS timer four times.
as 500x4 = 2000mS = 2S
I am confused can you confirm the sequence of LED?
first 2 sec cycle
LED on
delay 500mS
LED off
delay 500mS
LED on
delay 500mS
LED off
delay 500mS
Second 2 Sec cycle
LED off
Is the sequence correct? as you wanted? and the above sequence can be done in the background using timer and interrupts.. the 2 sec cycle can be done by running 500mS timer four times.
Fri Nov 02 2007, 09:39 pm
no......the led should be alternately on for 2ms and off for 2ms and this sequence should be repeated 8 times........i think i have found out the solution.......
ORG 0000
LJMP MAIN
ORG 30H
MAIN: mov p1,#0ffh
mov tmod,#00000001b ;timer 0 in mode 1
setb p2.7
mov TL0,#0FDH
MOV TH0,#4BH
MOV R3,#8 ;led on 4 times and led off 4 times =8 times
MOV R4,#40
MOV IE,#10000010B ;EA=1 & ET0=1
SETB TR0
BACK: MOV A,P1
MOV P0,A
SJMP BACK
ORG 000BH
LJMP INIT
INIT: CLR TR0
DJNZ R4,NEXT
CPL P2.7
DJNZ R3,NEXT2
MOV R3,#08
NEXT2: MOV R4,#40
NEXT: MOV TL0,#0FDH
MOV TH0,#4BH
SETB TR0
RETI
CALCULATIONS: for generating 2ms from 50ms pulse
count for 50ms = 4bfd in hex which is loaded in TL0 & TH0 of timer 0.
for generating 2ms delay we need 50ms X 40 = 2sec
so i have loaded one of the registers with value 40.
ORG 0000
LJMP MAIN
ORG 30H
MAIN: mov p1,#0ffh
mov tmod,#00000001b ;timer 0 in mode 1
setb p2.7
mov TL0,#0FDH
MOV TH0,#4BH
MOV R3,#8 ;led on 4 times and led off 4 times =8 times
MOV R4,#40
MOV IE,#10000010B ;EA=1 & ET0=1
SETB TR0
BACK: MOV A,P1
MOV P0,A
SJMP BACK
ORG 000BH
LJMP INIT
INIT: CLR TR0
DJNZ R4,NEXT
CPL P2.7
DJNZ R3,NEXT2
MOV R3,#08
NEXT2: MOV R4,#40
NEXT: MOV TL0,#0FDH
MOV TH0,#4BH
SETB TR0
RETI
CALCULATIONS: for generating 2ms from 50ms pulse
count for 50ms = 4bfd in hex which is loaded in TL0 & TH0 of timer 0.
for generating 2ms delay we need 50ms X 40 = 2sec
so i have loaded one of the registers with value 40.
Sat Nov 03 2007, 06:01 am
looks like you are confusing yourself with mS and S good that you found the solution.. as i said.. use timers.. did u test it?
Sat Nov 03 2007, 05:16 pm
yeah i tested it today and it worked fine...........
i want to learn VB programming . are there any materials available?
i want to learn VB programming . are there any materials available?
Sat Nov 03 2007, 07:32 pm
just use google.. you will get plenty of stuff there..
what you want to learn about it?
You know something.. i don't know anything about VB and if you doubt how i do my work on VB.. then google is the answer.. you get all kind of sample codes from internet.. just go through simple tutorials of VB and modify the sample codes to make them work as you want
and.. of course.. Rickey's World is always here to help
what you want to learn about it?
You know something.. i don't know anything about VB and if you doubt how i do my work on VB.. then google is the answer.. you get all kind of sample codes from internet.. just go through simple tutorials of VB and modify the sample codes to make them work as you want
and.. of course.. Rickey's World is always here to help
Powered by e107 Forum System