Assemblerda taymer dasturini tuzish va proteusda echish


Download 278.63 Kb.
bet1/2
Sana20.11.2023
Hajmi278.63 Kb.
#1788742
  1   2
Bog'liq
Laboratoriay ish-3




Laboratoriay ish № 3


ASSEMBLERDA TAYMER DASTURINI TUZISH VA PROTEUSDA ECHISH


Misol. Mikrokontrollerga ob’ektlarni o’lash va boshqarish.
Ikkita lampochkalarni yonib-o'chirish dasturini tuzish. Yonib-o'chirish vaqti 7 sek.
Lampochkalarni rele boshqarishi kerak.
Avtomatlashtirilgan boshqaruv va monitoring tizimlarida ko'pincha vaqtinchalik taymerlardan foydalanish kerak. Ularni qurish tamoyillari bilan tanishish uchun 5 soniya davomida taymer yaratish misolini ko'rib chiqamiz.
5 soniya davomida taymer yaratish uchun bizga oxir-oqibat kerakli vaqtni berishi mumkin bo'lgan ba'zi buyruqlarning tsiklik bajarilishidan foydalanishimiz mumkin. Mikrokontrollerning takt chastotasi 12 MGts bo'lganida, mashina tsiklining davomiyligi 1 ms ni tashkil qiladi, mikrokontroller buyruqlari turli xil tsikllarda bajariladi, masalan, MOV Rn, # ma'lumotlar buyrug'i 1 tsiklda bajariladi, ya'ni 1 mksda, DJNZ Rn buyrug‘i ikki siklda, RET buyrug‘i ikki siklda va h.k.
Yuqoridagilarga asoslanib 1 soniyada etalon yaratamiz:
Исходя из выше изложенного создадим эталон в 1 сек:
SEK: mov R3,#55D
MS: mov R4,#46h
MKS: mov R5,#46h
PUSTO: NOP
DJNZ R5,PUSTO
DJNZ R4,MKS
DJNZ R3,MS
Теперь, например, для создания таймера на 5 сек необходимо этот эталон прокрутить 5 раз. Ниже приводится пример включения мигалки на 5 секунд и её программа:
Endi, masalan, 5 soniya davomida taymer yaratish uchun ushbu etalonni 5 marta aylantirish kerak. Quyida miltillovchini 5 soniya davomida yoqish misoli va uning dasturi keltirilgan:




;====================================================================
; Main.asm file generated by New Project wizard
;
; Created: Вс янв 5 2020
; Processor: 80C31
; Compiler: ASEM-51 (Proteus)
;====================================================================

$NOMOD51
$INCLUDE (8051.MCU)


;====================================================================


; DEFINITIONS
;====================================================================

;====================================================================


; VARIABLES
;====================================================================

;====================================================================


; RESET and INTERRUPT VECTORS
;====================================================================

; Reset Vector


org 0000h
jmp Start

;====================================================================


; CODE SEGMENT
;====================================================================

org 0100h


Start:
mov A,#08h
MOV P2,A
ACALL Taimer;
MOV A,#000h
MOV P2,A
ACALL Taimer
AJMP Start
Taimer:
MOV R6,#07h
SEK:MOV R3,#55D
MS:
MOV R4,#46h
MKS:
MOV R5,#46h
PUSTO: NOP
DJNZ R5,PUSTO
DJNZ R4,MKS
DJNZ R3,MS
DJNZ R6,SEK
RET

; Write your code here
Loop:
jmp Loop

;====================================================================


END



Download 278.63 Kb.

Do'stlaringiz bilan baham:
  1   2




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling