| a_red |
bit p0.0 |
| a_amber |
bit p0.1 |
| a_green |
bit p0.2 |
| |
|
| b_red |
bit p0.3 |
| b_amber |
bit p0.4 |
| b_green |
bit p0.5 |
| |
|
| c_red |
bit p0.6 |
| c_amber |
bit p0.7 |
| c_green |
bit p2.7 |
| |
|
| d_red |
bit p2.6 |
| d_amber |
bit p2.5 |
| d_green |
bit p2.4 |
|
//Define RAM Locations
|
| multiplier |
equ 30h |
| current_signal_duration |
equ 31h |
|
//DEFINE BIT ADDRESS
|
| signal_f bit 00h |
;if 1 then switch to next signal |
| |
|
//DEFINE Constants
|
| MULTIPLIER_DEFAULT |
DATA 20 |
| DURATION_GREEN |
DATA 10 |
| DURATION_AMBER |
DATA 2 |
| |
|
//TIMER SUBROUTINES
|
|
| timer:
push acc
push b
push psw
push dph
push dpl
clr TF0
mov th0,#3ch
mov tl0,#0B0h
call check_timer
pop dpl
pop dph
pop psw
pop b
pop acc
reti
|
|
| |
|
|
check_timer:
djnz multiplier,r1_check_timer
|
|
| mov multiplier,#MULTIPLIER_DEFAULT |
;One second ended reload value
|
| djnz current_signal_duration,r1_check_timer |
|
| setb signal_f |
;signal duration ended move to nxt signal |
|
r1_check_timer:
|
|
| ret |
|
| |
|
//MAIN Program
|
|
|
org 0000h
jmp main
|
|
| |
|
|
org 000bh
jmp timer
|
|
| |
|
| org 0030h
main:
mov multiplier,#MULTIPLIER_DEFAULT
|
|
| setb EA |
;Enable Interrupt |
| setb ET0 |
;Enable timer 0 Interrupt |
|
clr signal_f
mov TMOD,#01h
mov th0,#3ch
mov tl0,#0B0h
|
// Timer 0 Mode 1(16 bit mode) |
| setb tcon.4 |
;start timer |
| |
|
| loop: |
|
|
mov current_signal_duration
|
,#DURATION_GREEN
|
|
clr a_green
setb a_amber
setb a_red
setb b_green
setb b_amber
clr b_red
setb c_green
setb c_amber
clr c_red
setb d_green
setb d_amber
clr d_red
|
|
|
|
|
|
jnb signal_f,$
clr signal_f
|
|
|
mov current_signal_duration
|
,#DURATION_AMBER
|
|
setb a_green
clr a_amber
jnb signal_f,$
clr signal_f
|
|
| |
|
| mov current_signal_duration, |
#DURATION_GREEN
|
| setb a_amber
clr a_red
clr b_green
jnb signal_f,$
clr signal_f
|
|
| |
|
|
mov current_signal_duration,
|
#DURATION_AMBER
|
| setb b_green
clr b_amber
jnb signal_f,$
clr signal_f
|
|
| |
|
| mov current_signal_duration, |
#DURATION_GREEN
|
|
setb b_amber
clr b_red
clr c_green
jnb signal_f,$
clr signal_f
|
|
| |
|
|
mov current_signal_duration,
|
#DURATION_AMBER
|
| setb c_green
clr c_amber
jnb signal_f,$
clr signal_f
|
|
| |
|
|
mov current_signal_duration,
|
#DURATION_GREEN
|
| setb c_amber
clr c_red
clr d_green
jnb signal_f,$
clr signal_f
|
|
|
End
|
|
Comments
i just want to know if i can use this code for AT89C51
and what you mean by $include(timer.inc)
Yes the code will work on AT89c51 as well....
$include(timer.inc) not needed in the code...have rectified the error
Thank you sir for the replay
I had change MULTIPLIER_DEFA ULT DATA 20 to
DURATION_Red DATA 20
would that make any difference?
MULTIPLIER_DEFA ULT DATA 20 is used to generate 1 second delay this 1 second is then in turn used to generate 10 second delay for green and 2 second delay for amber light
I entered your code that is above in keil uvision 3 but I can not obtain the hex file that is need to download in AT89C51 and I do not know what is the problem because this the first time that I used this program
do you have that hex file?
Thank you
and then check create Hex file
now I did this steps and I download the hex fiel in at89c51 but also I faced problem
after interfaced at89c51 by the 12 LEDs
I want to make sure if you did the circuit of traffic light contrller after writing this code
and does it work?
please........
i had use the code but the circuit did not work, all the lamps turn ON at the same time
did you connect the led as shown in the following article : dnatechindia.com/.../...
:10000000C0E0C0F0 C0D0C083C082C28D758C3C758A
:100010008AB0111FD082D083D0D0D0F0D0E032D5BA
:0B0020003008753014D53102D20022E8
:02000000802E50
:02000B0080F380
:10003000753014D2AFD2A9C20075 8C3C758AB0D28B
:100040008C75310AC282D281D280D285D284C28 399
:10005000D2A7D287 C286D2A4D2A5C2A 63000FDC242
:1000600000753102D282C2813000FDC20075310AB2
:10007000D281C280C2853000FDC200753102D285B6
:10008000C2843000FDC20075310AD284C283C2A787
:100090003000FDC200753102D2A7C2873000FDC218
:0F00A0000075310AD287C286C2A43000FDC200AB
:00000001FF
I had connect the LEDs as you did and I connect the reset pin to the VCC through capacitore and and other sid to the ground through resistor, I also connect EA pin to VCC, and I connect pin 18 and 19 to the Crystal and then to the ground
Schematic for traffic light control:
sir did you test the code befor?
I have mailed you the complete details along with the working video of it. check and reply
and does this code work with 8051?
and what assembel to use..??
please reply me as soon as possible.
dnatechindia.com/.../...
Other details have been explained above.
the circuit worked but there is Problem with c_red and d_red. when C_green turn on the the c_red keep working untill c_green turn OFF?
sir I am still get the same problem the RED LED turn ON with green?.......
sir as you said the c_green pin is shorted to C-red pin
how can I solve this problem?
I have taken this project so can u please forward the details of coding,hex file,video...
I am waiting
email= rohitkakde92269 @gmail.com
RSS feed for comments to this post