共用電控箱系統(tǒng):以下為源代碼:
;通用電控多套程序(designed by tone.lei at 10:33 11/27/2008)
;(I/O點(diǎn)定義) p0.0 p0.1 p0.2 p0.3 接撥碼開關(guān) R2:撥碼開關(guān)暫存器
S1 EQU P1.0 ;第1個(gè)信號(hào)
S2 EQU P1.1 ;第2個(gè)信號(hào)
S3 EQU P1.2 ;第3個(gè)信號(hào)
S4 EQU P1.3 ;第4個(gè)信號(hào)
S5 EQU P1.4 ;第5個(gè)信號(hào)
S6 EQU P1.5 ;第6個(gè)信號(hào)
S7 EQU P1.6 ;第7個(gè)信號(hào)
S8 EQU P1.7 ;第8個(gè)信號(hào)
S9 EQU P3.4 ;第9個(gè)信號(hào)
S10 EQU P3.5 ;第10個(gè)信號(hào)
S11 EQU P3.6 ;第11個(gè)信號(hào)
S12 EQU P3.7 ;第12個(gè)信號(hào)
START EQU P3.0 ;啟動(dòng)信號(hào)
RESET EQU P3.1 ;復(fù)位信號(hào)
INT0 EQU P3.2 ;中斷0信號(hào)
INT1 EQU P3.3 ;中斷1信號(hào)
ONE0 EQU P2.4 ;撥碼開關(guān)碼1
ONE1 EQU P2.5 ;撥碼開關(guān)碼2
ONE2 EQU P2.6 ;撥碼開關(guān)碼4
ONE3 EQU P2.7 ;撥碼開關(guān)碼8
STEP1 EQU P0.0 ;第1個(gè)輸出點(diǎn)
STEP2 EQU P0.1 ;第2個(gè)輸出點(diǎn)
STEP3 EQU P0.2 ;第3個(gè)輸出點(diǎn)
STEP4 EQU P0.3 ;第4個(gè)輸出點(diǎn)
STEP5 EQU P0.4 ;第5個(gè)輸出點(diǎn)
STEP6 EQU P0.5 ;第6個(gè)輸出點(diǎn)
STEP7 EQU P0.6 ;第7個(gè)輸出點(diǎn)
STEP8 EQU P0.7 ;第8個(gè)輸出點(diǎn)
;(主程序開始)
ORG 0000H
LJMP MAIN
ORG 0003H
LJMP INTER0
ORG 0013H
LJMP INTER1
ORG 0030H
MAIN: JB ONE0, NEXT1
JB ONE1, NEXT2
JB ONE2, NEXT3
MOV R2, #07H
LJMP PRO7
NEXT3: MOV R2, #03H
LJMP PRO3
NEXT2: JB ONE2, NEXT20
MOV R2, #05H
LJMP PRO5
NEXT20: JB ONE3, NEXT21
MOV R2, #09H
LJMP PRO9
NEXT21: MOV R2, #01H
LJMP PRO1
NEXT1: JB ONE1, NEXT10
JB ONE2, NEXT11
MOV R2, #06H
LJMP PRO6
NEXT11: MOV R2, #02H
LJMP PRO2
NEXT10: JB ONE2, NEXT12
MOV R2, #04H
LJMP PRO4
NEXT12: JB ONE3, NEXT13
MOV R2, #08H
LJMP PRO8
NEXT13: MOV R2, #00H
LJMP PRO0
;(程序0執(zhí)行 [電測(cè)機(jī)程序])
PRO0: ACALL UP
CLR STEP1 ;啟動(dòng)壓入氣缸
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
CLR STEP2 ;啟動(dòng)折彎氣缸
ACALL DELAY ;延時(shí)0.1秒
ACALL DELAY ;延時(shí)0.1秒
ACALL DELAY
SETB STEP1 ;斷開探針氣缸
ACALL DELAY
ACALL DELAY
ACALL DELAY
SETB STEP2 ;斷開舌片氣缸
AJMP PRO0 ;返回
;(程序1執(zhí)行 [張強(qiáng)之 連線機(jī)程序])
PRO1: ACALL UP
CLR STEP1 ;啟動(dòng)推料氣缸
ACALL S1DEL ;推料氣缸動(dòng)點(diǎn)延時(shí)
CLR STEP2 ;啟動(dòng)壓料氣缸
ACALL S2DEL ;壓料氣缸動(dòng)點(diǎn)延時(shí)
ACALL S2DEL ;壓料氣缸動(dòng)點(diǎn)延時(shí)
SETB STEP1 ;斷開推料氣缸
SETB STEP2 ;斷開壓料氣缸
ACALL DELAY
ACALL DELAY
ACALL DELAY
LJMP PRO1 ;返回
;(程序2執(zhí)行 [郭金武之PJD電測(cè)機(jī)程序])
PRO2: ACALL UP
CLR STEP2 ;啟動(dòng)壓料氣缸
ACALL DELAY ;壓料氣缸動(dòng)點(diǎn)延時(shí)
ACALL DELAY
ACALL DELAY
JB INT1,LEDNG ;LED1 TEST
JB S10,LEDNG ;LED2 TEST
CLR P2.0
CLR P2.1
CLR P2.2
CLR P2.3
ACALL DELAY
MOV A,P1 ;將P1口的值讀入暫存器ACC
XRL A,#55H
JNZ SHNG ;檢測(cè)有無(wú)短路
SETB P2.0
SETB P2.1
SETB P2.2
SETB P2.3
ACALL DELAY
CLR STEP1
ACALL DELAY
ACALL DELAY
ACALL DELAY
JB S1,OPENNG ;開始檢測(cè)導(dǎo)通
ACALL DEL10
JB S2,OPENNG
ACALL DEL10
JB S3,OPENNG
ACALL DEL10
JB S4,OPENNG
ACALL DEL10
JB S5,OPENNG
ACALL DEL10
JB S6,OPENNG
ACALL DEL10
JB S7,OPENNG
ACALL DEL10
JB S8,OPENNG
AJMP PRO2GO
LEDNG: CLR STEP6
AJMP PRO2NG
SHNG: CLR STEP4
AJMP PRO2NG
OPENNG: CLR STEP3
PRO2NG: JB RESET,PRO2NG
AJMP RRSETQ
PRO2GO: CLR STEP5
RRSETQ: SETB STEP1
SETB STEP3
SETB STEP4
SETB STEP6
SETB P2.0
SETB P2.1
SETB P2.2
SETB P2.3
ACALL DELAY
ACALL DELAY
SETB STEP2
ACALL DELAY
ACALL DELAY
SETB STEP5
AJMP PRO2 ;返回
;(程序3執(zhí)行 [張強(qiáng)之SLS-13SR1B 電測(cè)機(jī)程序])
PRO3: JNB P3.3,PRO3
PRO3K: JB P3.3,PRO3K
ACALL DEL10
JB P3.3,PRO3K
CLR P0.1
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
CLR P2.0 ;開啟短路測(cè)試
CLR P2.1
CLR P2.2
CLR P2.3
ACALL DELAY
MOV A,P1 ;將P1口的值讀入暫存器ACC
XRL A,#55H
JNZ PRO3SH ;檢測(cè)7PIN有無(wú)短路
JB P3.0,PRO3SH
JNB P3.1,PRO3SH
JB P3.4,PRO3SH
JNB P3.5,PRO3SH
JB P3.6,PRO3SH
JNB P3.7,PRO3SH
SETB P2.0
SETB P2.1
SETB P2.2
SETB P2.3
CLR P0.0 ;開始斷路測(cè)試
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
JB P1.0,PRO3SO
JB P1.1,PRO3SO
JB P1.2,PRO3SO
JB P1.3,PRO3SO
JB P1.4,PRO3SO
JB P1.5,PRO3SO
JB P1.7,PRO3SO
JB P3.0,PRO3SO
JB P3.1,PRO3SO
JB P3.4,PRO3SO
JB P3.5,PRO3SO
JB P3.6,PRO3SO
JB P3.7,PRO3SO
AJMP PRO3OK
PRO3SH: CLR P0.2
AJMP PRO3RS
PRO3SO: CLR P0.4
AJMP PRO3RS
PRO3RS: JB P3.2,PRO3RS
SETB P0.2
SETB P0.4
SETB P2.0
SETB P2.1
SETB P2.2
SETB P2.3
AJMP PRO3GO
PRO3OK: CLR P0.3
PRO3GO: SETB P0.0
ACALL DELAY
SETB P0.1
ACALL DELAY
ACALL DELAY
SETB P0.3
AJMP PRO3 ;返回
;(程序4執(zhí)行 [楊道軍之SIM-06HA掃料帶程序])
PRO4: JNB P1.0,PRO4
MOV P0,#0FFH
PRO4OR1:JB P1.2,PRO4OR1
PRO4OR2:JB P1.4,PRO4OR2
PRO4OR3:JB P1.6,PRO4OR3
PRO4S: JB P1.0,PRO4S
ACALL DEL10
JB P1.0,PRO4S
CLR P0.2 ;啟動(dòng)推入氣缸
PRO4TR: JB P1.3,PRO4TR
ACALL DELAY
ACALL DELAY
CLR P0.1 ;啟動(dòng)壓氣缸
ACALL DELAY
CLR P0.0 ;啟動(dòng)掃料支撐氣缸
ACALL DELAY
ACALL DELAY
ACALL DELAY
MOV R0,#00H
PRO4A: CPL P0.3 ;啟動(dòng)掃料氣缸
JB P0.3,PRO4B
PRO4C: jb p1.5,PRO4C
PRO4CC: jb p1.7,PRO4CC
ajmp PRO4D
PRO4B: jb p1.4,PRO4B
PRO4BB: jb p1.6,PRO4BB
inc R0
PRO4D: cjne R0,#7,PRO4A;檢測(cè)掃料次數(shù)如果不夠則繼續(xù)掃料
SETB P0.3 ;復(fù)位掃料氣缸
ACALL DELAY
SETB P0.1 ;復(fù)位壓氣缸
ACALL DELAY
SETB P0.0 ;復(fù)位支撐氣缸
ACALL DELAY
ACALL DELAY
SETB P0.2 ;復(fù)位壓氣缸
AJMP PRO4 ;返回
;(程序5執(zhí)行 [楊道軍之BTP-02SC連線機(jī)程序])
pro5: jnb p1.0,pro5
pro5s: jb p1.0,pro5s ;檢測(cè)啟動(dòng)按鈕是否按下如不是則反復(fù)偵測(cè)狀態(tài)
lcall del10
jb p1.0,pro5s
clr p0.0 ;1 啟動(dòng)推料氣缸
acall delay
acall delay
clr p0.1 ;2 啟動(dòng)壓合氣缸
acall delay
clr p0.3 ;3 啟動(dòng)舌片氣缸/復(fù)位推料.壓合氣缸
setb p0.0
setb p0.1
acall delay
clr p0.2 ;4 啟動(dòng)探針氣缸
acall delay
acall delay
acall delay
jb p1.2,pro5q1
ajmp pro5ng
pro5q1: acall delay
setb p0.3 ;5 復(fù)位舌片氣缸
acall delay
jnb p1.2,pro5q2
ajmp pro5ng
pro5q2: setb p0.2 ;6 復(fù)位探針氣缸
acall delay
ajmp pro5ok
pro5ng: setb p0.2
setb p0.3
acall delay
clr p0.4 ;7 NG 排除氣缸
inc r4
ajmp pro5rs
pro5ok: mov r4,#00h
pro5rs: acall delay
acall delay
acall delay
setb p0.4
cjne r4,#3,pro5fu
pro5uf: jb p1.1,pro5uf
mov r4,#00h
pro5fu: ajmp main ;返回
;(程序6執(zhí)行 [XX之 連線機(jī)程序])
PRO6: ACALL UP
LJMP MAIN ;返回
;(程序7執(zhí)行 [XX之 連線機(jī)程序])
PRO7: ACALL UP
LJMP MAIN ;返回
;(程序8執(zhí)行 [XX之 連線機(jī)程序])
PRO8: ACALL UP
LJMP MAIN ;返回
;(程序9執(zhí)行 [XX之 連線機(jī)程序])
PRO9: ACALL UP
LJMP MAIN ;返回
;(中斷0程序)
INTER0: JNB INT0,INTER0
ACALL DEL10
JNB INT0,INTER0
TEST0: JB RESET,TEST0
RETI
;(中斷1程序)
INTER1: JNB INT1,INTER0
ACALL DEL10
JNB INT1,INTER0
TEST1: JB RESET,TEST1
RETI
;(啟動(dòng)開關(guān)程序)
UP: JNB START,UP
TEST: JB START,TEST
ACALL DEL10
JB START,TEST
RET
;(0.1S延時(shí)程序)
DELAY: MOV R5,#200
DELT1: MOV R6,#250
DJNZ R6,$
DJNZ R5,DELT1
RET
;(0.01S延時(shí)程序)
DEL10: MOV R5,#20
DELT2: MOV R6,#250
DJNZ R6,$
DJNZ R5,DELT2
RET
;(S1信號(hào)延遲輸入)
S1DEL: JB S1,S1DEL
ACALL DELAY
JB S1,S1DEL
RET
;(S2信號(hào)延遲輸入)
S2DEL: JB S2,S2DEL
ACALL DELAY
JB S2,S2DEL
RET
;(S3信號(hào)延遲輸入)
S3DEL: JB S3,S3DEL
ACALL DELAY
JB S3,S3DEL
RET
;(S4信號(hào)延遲輸入)
S4DEL: JB S4,S4DEL
ACALL DELAY
JB S4,S4DEL
RET
;(S5信號(hào)延遲輸入)
S5DEL: JB S5,S5DEL
ACALL DELAY
JB S5,S5DEL
RET
;(S6信號(hào)延遲輸入)
S6DEL: JB S6,S6DEL
ACALL DELAY
JB S6,S6DEL
RET
;(S7信號(hào)延遲輸入)
S7DEL: JB S7,S7DEL
ACALL DELAY
JB S7,S7DEL
RET
;(S8信號(hào)延遲輸入)
S8DEL: JB S8,S8DEL
ACALL DELAY
JB S8,S8DEL
RET
;(S9信號(hào)延遲輸入)
S9DEL: JB S9,S9DEL
ACALL DELAY
JB S9,S9DEL
RET
;(S10信號(hào)延遲輸入)
S10DEL: JB S4,S4DEL
ACALL DELAY
JB S4,S4DEL
RET
;(S11信號(hào)延遲輸入)
S11DEL: JB S11,S11DEL
ACALL DELAY
JB S11,S11DEL
RET
;(S12信號(hào)延遲輸入)
S12DEL: JB S12,S12DEL
ACALL DELAY
JB S12,S12DEL
RET
END
[ 此帖被阿少杰在2009-04-20 20:03重新編輯 ]