Saturday, May 9, 2009

Blaze LED for 1 second

Following will be [submitted/sent] example of microcontroller application to control blaze LED for 1 second. LED consist of 8 units LED that attributed to Port 1 (active low) at AT89S51. following its programming example:


RATUSAN EQU 100
CACAH EQU -10000
ORG 0H
MOV TMOD,#01H
MULAI:
MOV P1,#00H
CALL TUNDA
MOV P1,#0FFH
CALL TUNDA
SJMP MULAI
TUNDA:
MOV R1,#RATUSAN
LAGI:
MOV TH0,#HIGH CACAH
MOV TL0,#LOW CACAH
SETB TR0
TUNGGU:
JNB TF0,TUNGGU
CLR TF0
CLR TR0
DJNZ R1,LAGI
RET
END
At program above use timer 0 modes 16 beets. This Timer are hung from clock at microcontroller referred [as], where at this application use crystal 12 Mhzes and capacitor 33 pFs at pin 18 (XTAL 1) and pin19 (XTAL 2). Oscillator that used [by] is oscillator network that already existed on microcontroller, and only enhance crystal and capacitor as [the] frequency determinant clock that used [by].
Crystal that used [by] is 12 Mhzes,
Because = Crystal Frequency = 12 MHzes
T = 1 / f
T = 1 / 12 MHzes
= 8,333333333-8
T = 8,333333333-8 x 1000000
= 0,083333333 usecond
until one period of box wave is :
one period = 0,083333333 / 2
= 0,04166 usecond



Picture Prioda square wave
one machine cycle is divided become 6 groups with every one group require two period of box waves, then one machine cycle is:
one machine cycle = 0,083333333 x 2 x 6
= 0,9 ~ 1 usecond
One machine cycle will run one microcontroller command, not close possibility one command requires two machine cycles. If used crystal 12 MHzes, then networked time every one machine cycle is 1 usecond.
At this application, we content timer with calculation 100x10000 = 1000000 udetiks = 1 second.

No comments:

Post a Comment