?? guangfei.asm
字號(hào):
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
步進(jìn)電機(jī))控制程序 time 06.01.12 likc
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;晶振 12MHz AT889c52
;安鈕輸入
;P0.0-------開機(jī)
;P0.1-------點(diǎn)動(dòng)正
;P0.2-------急停
;P0.3------- 手動(dòng)沖
;P1.0--------定長750
;P1.1--------定長1100
;P1.2--------定長1233
;P1.3--------定長1350
;P1.4--------定長1650
;P1.5--------定長1935
;P1.7--------定長缺口及定長轉(zhuǎn)換
;傳感器輸入
;P2.2-------有無菲林信號(hào)輸入
;P2.5-------缺口檢測(cè)
;P3.4------- 菲林孔檢測(cè)
;P2.3------- 菲林接頭
;P2.0-------擋位(定長-缺口)
;P2.4-------出料檢測(cè)
;P1.0-------計(jì)數(shù)器菲林總長到信號(hào)輸入
;輸出
;P2.1--------氣缸(沖頭電磁閥)
;P3.2 --------氣缸(外氣缸)
;P0.5--------脈沖
;P0.6--------方向
;P1.6--------啦叭
;箱外
;P3.2--------夾菲林軸氣缸
;p3.1--------步進(jìn)電機(jī)周向定位?
;p3.0--------菲林軸槽到位傳感器
;p2.4--------安裝菲林軸到位傳感器
;p0.4--------外步進(jìn)電機(jī)脈沖
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
org 00h
jmp start1
org 30h
;#######################################
START1: mov sp,#058h
mov tmod,#0101b
mov th0,#0h
mov tl0,#0h
mov ie,#82h
clr tr0
setb P3.2 ;外氣缸
setb P2.1
clr P1.6
clr 21h.2
mov r6,#00h
;************;
; 主 程 序 ;
;************;
zhuhuan: jnb P1.7,START
jmp D_START
START: LCALL CLEAR
call L1_delay
call L1_delay
NEXT:
JNB P0.0, FUN0
JNB P0.1, FUN1_J
JNB P0.3, FUN3_J
AJMP NEXT
FUN1_J: LJMP FUN1
FUN3_J: LJMP S_FUN1
;定長程序入口
D_START: LCALL CLEAR
call L1_delay
call L1_delay
D_NEXT:
JNB P0.0, dingchang ;定長自動(dòng)
JNB P0.1, D_FUN1_J ;點(diǎn)動(dòng)正轉(zhuǎn)
JNB P0.3, D_FUN3_J ;手動(dòng)沖
AJMP D_NEXT
D_FUN1_J: LJMP FUN1
D_FUN3_J: JMP SD_FUN2
dingchang:
JNB P1.0, FLONG1
JNB P1.1, FLONG2
JNB P1.2, FLONG3
JNB P1.3, FLONG4
JNB P1.4, FLONG5
JNB P1.5, FLONG6
FLONG1: LJMP LONG11
FLONG2: LJMP LONG12
FLONG3: LJMP LONG13
FLONG4: LJMP LONG14
FLONG5: LJMP LONG15
FLONG6: LJMP LONG16
;
;************;
; 功能程序 ;
;************;
;第1種功能程序
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;waite
FUN0:
lcall DL10MS
jb P0.0,start
fu0_waitwei: jnb P2.4,fu0_weizhi
call delay
jmp fu0_waitwei
;^^^^^^^^^^^^^^^^^^^^^^^
;waiqigang----go out
fu0_weizhi:
call Kdelay
clr P3.2
call Kdelay
;^^^^^^^^^^^^^^^^^^^^^^^^^
;slowp
fu0_btest: ; setb tr0
fu0_btest1: cpl P0.4
call delays
jb P3.0,fu0_slow_delay
jmp fu0_btest1
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
fu0_slow_delay:
mov 30h,#014h
fu0_slow_delay0: mov 31h,#02fh
fu0_slow_delay1: cpl P0.4
call delays
djnz 31h,fu0_slow_delay1
djnz 30h,fu0_slow_delay0
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;fast
call intadd_p04
fu0_xiaodiji:
cpl P0.4
call delayf
cpl P0.4
call delayf
jb P2.5, FUN011 ;缺口到
jb P2.2, FUN012_J ;無菲林
jnb P0.2,FUN2_J ;急停
jnb P2.3, speaker_jmp ;接頭
jmp fu0_xiaodiji
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;small-motor houzhuan
fu0_smallfn:
mov 30h,#0c8h
fu0_houzhuan: mov 31h,#0d2h
fu0_houzhuan1: cpl P0.4
call delayf
cpl P0.4
call delayf
djnz 31h,fu0_houzhuan1
djnz 30h,fu0_houzhuan
lcall Kdelay
setb P3.2 ;qigang--go back
lcall Kdelay
lcall Kdelay
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;small-motor run 周向定向
;;fu0_z_run: cpl P0.4
;; call delays
;; jb P3.1,fu0_runstop
;; jmp fu0_z_run
;;fu0_runstop: lcall Kdelay
;; lcall Kdelay
;; lcall Kdelay
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;dig-motor to post
; setb tr0
mov 30h,#0ceh
fu0_dadaji: mov 31h,#012h
fu0_dadaji1: cpl P0.5
call delay
djnz 31h,fu0_dadaji1
djnz 30h,fu0_dadaji
lcall Kdelay
jmp fu0_waitwei
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FUN2_J: LJMP FUN2
speaker_jmp: ljmp speaker
FUN012_J: LJMP FUN012
;@@@@@@@@@@@@@@@@@@@@@@@
; 缺口到后延時(shí)停
;@@@@@@@@@@@@@@@@@@@@@@@
FUN011: ;lCALL DL10MS
; lCALL DL10MS
; jnb P2.5,FUN01
setb tr0
mov tl0, #0h
mov th0, #0h
;; mov 30h,#099h ;e1 (原值)
;; fasp: mov 31h, #064h ;02 (原值)
fsp:
;jb P2.2,guo1
setb P0.4
lcall delay_1
mov r2,th0
mov r3,tl0
jb P2.2,guo1 ;無菲林
jnb P0.2, guo1 ;急停
jnb P2.3, speaker_jmp ;接頭
clr P0.4
lcall delay_1
cjne r2,#0h, fsp
cjne r3,#011h, fsp
clr tr0
mov tl0, #0h
mov th0, #0h
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^
kongjian: mov 40h,#05ah
ggkongjian: cpl P0.5
lcall delay
; jb P3.4,kongstop01
; jb P2.2,guo1 ;無菲林
; jnb P0.2, guo1 ;急停
; jnb P2.3, speaker_jmp ;接頭
djnz 40h, ggkongjian
jmp zd
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
guo1:
jmp zhuhuan
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
zd: ; lcall Kdelay
clr P2.1 ;氣缸動(dòng)
setb P0.6 ;計(jì)數(shù)器輸出
clr P2.0 ;剎車
lcall Kdelay
setb P2.1 ;氣缸動(dòng)
; clr P0.6 ;計(jì)數(shù)器輸出
lcall Kdelay ;;; 外加另一氣缸P2.0
lcall Kdelay
;;;jb 21h.2, sensor_re_zd
jmp fu0_smallfn
;sensor_re_zd: jmp sensor_re
;***************************
que_jmp: jmp zhuhuan
;guo1_jmp: ljmp guo1
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;急停機(jī)(缺口到時(shí))
;;;;;;;;;;;;;;;;;;;;;;;;;;;
FUN012_jmp:
lCALL DL10MS
JNB P0.2, L_FSP;無菲林信號(hào)輸入
lcall deaddsp
SETB P0.5
lcall Kdelay
AJMP zhuhuan
L_FSP: JMP fsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;無菲林 (缺口未到時(shí))
;;;;;;;;;;;;;;;;;;;;;;;;;;;
FUN012:
; lCALL DL10MS
; JNB P2.2,JMP_FUN01 ;無菲林信號(hào)輸入
; lcall deaddsp
SETB P0.5
lcall Kdelay
AJMP zhuhuan
;JMP_FUN01: JMP FUN01
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;手動(dòng)沖料頭(缺口模試)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
S_FUN1: clr P2.1 ;氣缸動(dòng)
lcall Kdelay
setb P2.1 ;氣缸動(dòng)
lcall Kdelay
jmp START
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;手動(dòng)沖料頭(定長模試)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SD_FUN2: clr P2.1 ;氣缸動(dòng)
lcall Kdelay
setb P2.1 ;氣缸動(dòng)
lcall Kdelay
setb tr0
mov tl0, #0h
mov th0, #0h
jmp D_START
;第3種功能程序 急停 (缺口未到時(shí))
;;;;;;;;;;;;;;;;;;;;;;;;;;;
FUN2: ; LCALL DL10MS
FUN21: ; JB P0.2,JMP_FUN2
setb P0.5
lcall Kdelay
START2_J: LJMP zhuhuan
;JMP_FUN2: JMP FUN01
;^^^^^^^^^^^^^^^
;喇叭處理(處理接頭)
;^^^^^^^^^^^^^^^^
speaker:
; lCALL DL10MS
; lCALL DL10MS
; jnb P2.3, speak1
ding_speaker: mov 30h,#035h
k_fasp: mov 31h, #032h
k_fsp: lcall delay
; jb P2.2,guo1
clr P0.5
lcall delay
; jb P2.2,FUN012 ;無菲林
jnb P0.2, k_j2 ;急停
setb P0.5
djnz 31h, k_fsp
djnz 30h, k_fasp
;lcall deaddsp
clr P2.1 ;氣缸動(dòng)
lcall Kdelay
setb P2.1 ;氣缸動(dòng)
lcall Kdelay
; lJMP CYC1
;#########
setb P1.6
lcall Kdelay
clr P1.6
lcall Kdelay
setb P1.6
lcall Kdelay
clr P1.6
lcall Kdelay
setb P1.6
lcall Kdelay
clr P1.6
setb P0.5
lcall Kdelay
k_j2: ljmp zhuhuan
;speak1: jmp FUN01
;************;
cuokong: setb P1.6
lcall Kdelay
clr P1.6
lcall Kdelay
jnb P0.2,hui
jmp cuokong
hui: jmp zhuhuan
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;第2種功能程序 點(diǎn)動(dòng)正
FUN1: LCALL DL10MS
FUN11: JB p0.1,START1_J
setb P2.4
FUN12: cpl P0.5
lcall delay
JNB P0.1, FUN12
START1_J: LJMP zhuhuan
;*****************************************
;定長模式中無菲林及急停和用程序
;*****************************************
ding_wj: ; lcall deaddsp
; lcall CLEAR
jmp zhuhuan
;_______________________________________________________________________________
;+++++++++++++++++++++++++++++++++++++++++++++++++++++
;mm/p=0.1747695852534562 lengh=750mm
;+++++++++++++++++++++++++++++++++++++++++++++++++++++
LONG11:
fu11_waitwei: jnb P2.4,fu11_weizhi
call delay
jmp fu11_waitwei
;^^^^^^^^^^^^^^^^^^^^^^^
;waiqigang----go out
fu11_weizhi:
call Kdelay
clr P3.2
setb tr0
call Kdelay
;^^^^^^^^^^^^^^^^^^^^^^^^^
;slowp
fu11_btest:
fu11_btest1: cpl P0.4
call delays
jb P3.0,fu11_slow_delay
jmp fu11_btest1
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
fu11_slow_delay:
mov 30h,#032h
fu11_slow_delay0: mov 31h,#02fh
fu11_slow_delay1: cpl P0.4
call delays
djnz 31h,fu11_slow_delay1
djnz 30h,fu11_slow_delay0
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;fast
call intadd_p04
fu11_xiaodiji:
cpl P0.4
mov r2,th0
mov r3,tl0
call delayf
cpl P0.4
call delayf
jb P2.2, jmp_guo1
jnb P0.2,jmp_guo1
jnb P2.3, jmp_ding_speaker1
cjne r3,#00h,panerr11
jmp hui11
panerr11: cjne r2,#0h,fu11_xiaodiji
cjne r3,#094h,fu11_xiaodiji
lcall Kdelay
jmp kongjian_lo11
; jmp chong1
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jmp_guo1: jmp ding_wj
jmp_ding_speaker1: jmp ding_speaker
hui11: jmp cuokong
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;孔的檢測(cè),以導(dǎo)正菲林
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^
kongjian_lo11: ; mov 40h,#1eh
kongjian_lo11_er: cpl P0.4
mov r2,th0
mov r3,tl0
lcall delay_1
; jb P3.4,kongstop01_lo11
jb P2.2, jmp_guo1
jnb P0.2,jmp_guo1
jnb P2.3, jmp_ding_speaker1
cjne r2,#0h,kongjian_lo11_er
cjne r3,#09dh,kongjian_lo11_er
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
kongstop_lo11: lcall Kdelay
mov 30h,#05ah
kongstop2_lo11: cpl P0.5
lcall delay
djnz 30H,kongstop2_lo11
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
chong1: lcall Kdelay
mov th0,#0h
mov tl0,#0h
clr tr0
clr P2.1
setb P0.6
clr P2.0
lcall Kdelay
setb P2.1
clr P0.6
setb P0.5
lcall Kdelay
lcall Kdelay
; setb P2.0
; jb 21h.2, sensor_re_jmp2
; setb tr0
; mov th0,#0h
; mov tl0,#0h
jmp fu11_smallfn
;sensor_re_jmp1: jmp sensor_re
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;small-motor houzhuan
fu11_smallfn:
mov 30h,#0c8h
fu11_houzhuan: mov 31h,#0dch
fu11_houzhuan1: cpl P0.4
call delayf
cpl P0.4
call delayf
djnz 31h,fu11_houzhuan1
djnz 30h,fu11_houzhuan
lcall Kdelay
setb P3.2 ;qigang--go back
lcall Kdelay
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -