8051 li rastgele sayı üretici devre 0 ile 99 arasında rastgele ayı üretiyor. Devre farklı uygulamalarda kullanılıyor.  Devrenin beyni AT89S51 mikrodenetleyici. 2 adet 7 segment display,  2 transistör ve 5 pasif malzeme kullanılıyor.

8051 li rastgele sayı üretici devre şeması:

2 adet 7 segment display birlikte bağlanmış be data hatları Port0 ile ilişkilendirilmiştir. Q1 ve Q2 transistörleri displayleri sürer. Transistörlerin tetiklenmeleri P1.1 ve P1.2 den gelir.  Devreye güç uygulandığında displaylerde bir şey görünmez ama S2 butonuna basılınca rastgele 0-99 arası sayılar gösterilmeye başlar. Tek displayli devre isterseniz (0-9 arası rastgele sayı üreten devre) , displaylerden ve ona bağlı malzemelerden bir tanesini iptal edebililirsiniz. Başka birşey değiştirmeniz gerekmez.

Program:

ORG 000H
SJMP MAIN
ORG 003H // sets the starting address for the ISR
ACALL ISR // calls the ISR subroutine when S2 is pressed
RETI // return from interrrupt
 
MAIN:SETB IP.0 // this part sets the initial conditions
SETB TCON.0
SETB IE.0
SETB IE.7
MOV P0,#00000000B
MOV P1,#00000000B
MOV DPTR,#LUT // moves the starting address of LUT to DPTR
 
LABEL:MOV R6,#99D // this part generates the random number
LOOP:MOV A,R6
DJNZ R6,LOOP
SJMP LABEL
 
ISR:MOV A,R6 // Subroutine ISR displays the current random number
MOV B,#10D
DIV AB
SETB P1.2
ACALL DISPLAY
MOV P0,A
ACALL DELAY
MOV A,B
CLR P1.2
SETB P1.1
ACALL DISPLAY
MOV P0,A
ACALL DELAY
CLR P1.1
SJMP ISR
RET
 
DELAY: MOV R3,#02H // this subroutine creates 1mS delay for switching the displays
DEL1: MOV R2,#0FAH
DEL2: DJNZ R2,DEL2
DJNZ R3,DEL1
RET
 
DISPLAY: MOVC A,@A+DPTR // produces the digit drive pattern for the current digit in A
RET
 
LUT: DB 3FH // Look up table
DB 06H
DB 5BH
DB 4FH
DB 66H
DB 6DH
DB 7DH
DB 07H
DB 7FH
DB 6FH
END

[learn_more caption=”Kaynak”] http://www.circuitstoday.com/random-number-generator-using-8051[/learn_more]

[wpfp-link]

CEVAP VER

Lütfen yorumunuzu giriniz!
Lütfen isminizi buraya giriniz