目錄
- 一、 課程設計題目及要求
- 二、課程設計任務與目標
- 1、實驗原理
- 2、實驗程序
- 三、設計框圖
- 四、硬體實作原理
- 五、硬體實作和演示結果
- 六、識訓、不足和下一步改進方法
- 七、附錄:實驗代碼
一、 課程設計題目及要求
設計題目:“【課題16】 旋轉圖形設計”
設計要求: 了解旋轉圖形如何呈現的原理;加深了解控制在實際中的應用,
二、課程設計任務與目標
1、實驗原理
一個旋轉中的圖形,當每轉到一定角度時,被照亮一下,不斷重復此程序,就可以看到圖形穩定的影像(雖然該圖形在旋轉中),如果推遲照亮(推遲時間很短),就會出現圖形在慢慢旋轉,
本實驗利用光電開關來判斷轉盤轉到某個固定角度的時刻,給出中斷信號
2、實驗程序
(1)由光電開關結合中斷給出控制信號,通過CPU控制直流電機邊上的小燈閃爍,將直流電機驅動的旋轉轉盤上的圖形呈現出來,并令圖形也在旋轉(緩慢的),
三、設計框圖
連線布局如下(實驗箱中的字母不完全對應)

實物連線如下

四、硬體實作原理

- A3區:CPU總線、片選區
JP45:地址線A0-A7; JP48、JP50:地位地址/資料總線:JP51、JP55:MCS51的P1口;JP59:高位地址線A8-A15; JP61,JP64: MCS51的P3口,P3.7,P3.6作讀寫信號線;JP66:相當于一個MCS51類的cpu座,使用40芯扁線與用戶板相連,可仿真P0,P2口作地址、資料使用的MCS51類CPU,
-
A4區:ES8688控制區
主控部分 -
B3區:8259電路

CS:片選信號,低電平有效;A0:地址信號;INR0-INR7:中斷輸入;INTA:中斷回應
- B4區:8255電路

CS:片選信號,低電平有效;A0,A1:地址信號; JP52:PC口
- E2區:PWM電壓轉換
功率放大電路

IN1:信號輸入; OUT1:信號輸出,
- F1區:直流電機轉速測量,控制使用光電開關測速

CTRL:控制電壓輸入;
REV:光電開關或霍爾器件輸出(用于轉速測量);LIGHT:低電平點亮發光管
- F3區:DAC0832數模轉換

CS:片選,低電平有效;OUT:轉換電壓輸出,
五、硬體實作和演示結果
小燈周期性閃爍

六、識訓、不足和下一步改進方法
七、附錄:實驗代碼
.MODEL SMALL
IO8259_0 equ 0250h
IO8259_1 equ 0251h
IO8255_Con equ 0263h
IO8255_PC EQU 0262H ;light is in PC0
vol equ 42h
dac0832_add equ 0d00h
.stack 100
.data
count dw 0
flashflag db 0
speed2 dw 20
gap dw 0
.code
start:
mov ax,@data
mov ds,ax
mov es,ax
mov count,1
mov flashflag,0
call Init8255
call init8259
nop
nop
set_int_vector:
push ax
push es
push bx
mov ax,0
mov es,ax
mov bx,60
mov ax,offset int_led
mov es:[bx],ax
mov ax,seg int_led
mov es:[bx+2], ax
pop bx
pop es
pop ax
set_int_vector_done:
nop
nop
call dac0832
main:
sti
cmp flashflag,0
cli
jz main
mov flashflag,0
call flashled;BP here
jmp main
nop
nop
int 3h
int_led:
cli
push ax
push dx
mov flashflag,1
mov dx,IO8259_0
mov al,20h
out dx,al
pop dx
pop ax
sti
iret
flashled proc near
;cli
call delayled
mov dx,IO8255_PC
mov al,0
out dx,al; BP here
mov dx,IO8255_Con
mov al,0
out dx,al; BP here
call delaytime
mov dx,IO8255_PC
mov al,0ffh
out dx,al; BP here
mov dx,IO8255_Con
mov al,01h
out dx,al; BP here
;sti
ret
flashled endp
delayled proc near
mov cx,count
seg1@delayled:
call delay
loop seg1@delayled
inc count
mov ax,count
cmp ax,200 ;change it to change speed/sense of rotation
jnz endseg@delayled
mov count,1
endseg@delayled:
ret
delayled endp
delay proc near
push cx
mov cx,2 ;change it to change led flash time or sense of rotation
loop \$
pop cx
ret
delay endp
;time of led flashing
delaytime proc near
push cx
mov cx,speed2
loop \$
mov cx,speed2
cmp cx,120
jb adder@delaytime
jmp notadd@delaytime
adder@delaytime:
add cx,1
mov speed2,cx
mov cx,0
mov gap,cx
notadd@delaytime:
pop cx
ret
delaytime endp
init8259 proc near
mov dx,IO8259_0
mov al,13h ;ICW1
out dx,al
mov dx,IO8259_1
mov al,08h; Should be ICW2
;IR7 should be in 0FH
out dx,al
;No need any ICW3
mov dx,IO8259_1
mov al,09h
out dx,al
;OCW1
mov al,7FH
out dx,al
ret
init8259 endp
dac0832 proc near
mov dx,dac0832_add
mov al,vol
out dx,al
ret
dac0832 endp
Init8255 proc near
push dx
push ax
mov dx,IO8255_Con
mov al,80h
out dx,al
;port test
mov dx,IO8255_Con
mov al, 00h
out dx,al
mov al,01h
out dx,al
;test done
mov al,0ffh
mov dx,IO8255_PC
out dx,al
pop ax
pop dx
ret
Init8255 endp
end start
既來之,則贊之
若有疑問,創所欲言
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/249817.html
標籤:其他
