⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guangfei.asm

📁 可用`Keil uVision2 软件编译
💻 ASM
📖 第 1 页 / 共 3 页
字号:
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
步进电机)控制程序 time 06.01.12 likc
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  ;晶振 12MHz AT889c52
  ;安钮输入
  ;P0.0-------开机
  ;P0.1-------点动正
  ;P0.2-------急停
  ;P0.3-------  手动冲


  ;P1.0--------定长750
  ;P1.1--------定长1100
  ;P1.2--------定长1233
  ;P1.3--------定长1350
  ;P1.4--------定长1650
  ;P1.5--------定长1935


  ;P1.7--------定长缺口及定长转换
  ;传感器输入
  ;P2.2-------有无菲林信号输入
  ;P2.5-------缺口检测
  ;P3.4------- 菲林孔检测
  ;P2.3------- 菲林接头
  ;P2.0-------挡位(定长-缺口)
  ;P2.4-------出料检测
  ;P1.0-------计数器菲林总长到信号输入
  ;输出
  ;P2.1--------气缸(冲头电磁阀)
  ;P3.2 --------气缸(外气缸)
  ;P0.5--------脉冲
  ;P0.6--------方向
  ;P1.6--------啦叭

  ;箱外
  ;P3.2--------夹菲林轴气缸
  ;p3.1--------步进电机周向定位?
  ;p3.0--------菲林轴槽到位传感器
  ;p2.4--------安装菲林轴到位传感器
  ;p0.4--------外步进电机脉冲

;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
              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       ;定长自动
            JNB  P0.1, D_FUN1_J        ;点动正转
	    JNB  P0.3, D_FUN3_J        ;手动冲
            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

       ;@@@@@@@@@@@@@@@@@@@@@@@
       ; 缺口到后延时停
       ;@@@@@@@@@@@@@@@@@@@@@@@

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      ;气缸动
		setb P0.6      ;计数器输出
                clr P2.0        ;刹车
                lcall Kdelay
                setb P2.1       ;气缸动
	       ; clr P0.6        ;计数器输出
                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
;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;
       ;急停机(缺口到时)
;;;;;;;;;;;;;;;;;;;;;;;;;;;
  FUN012_jmp:
               lCALL DL10MS
               JNB P0.2, L_FSP;无菲林信号输入
               lcall deaddsp
	       SETB P0.5
               lcall Kdelay
	       AJMP zhuhuan
   L_FSP:      JMP fsp
;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;无菲林 (缺口未到时)
;;;;;;;;;;;;;;;;;;;;;;;;;;;
 FUN012:
             ; lCALL DL10MS
             ; JNB P2.2,JMP_FUN01 ;无菲林信号输入
              ; lcall deaddsp
	       SETB P0.5
               lcall Kdelay
	       AJMP zhuhuan
 ;JMP_FUN01:    JMP FUN01
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;手动冲料头(缺口模试)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 S_FUN1:        clr P2.1          ;气缸动
                lcall Kdelay
                setb P2.1       ;气缸动
                lcall  Kdelay
                jmp  START
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;手动冲料头(定长模试)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SD_FUN2:        clr P2.1          ;气缸动
                lcall Kdelay
                setb P2.1       ;气缸动
                lcall  Kdelay
                setb tr0
                mov tl0, #0h
                mov th0, #0h
                jmp  D_START
;第3种功能程序  急停 (缺口未到时)
;;;;;;;;;;;;;;;;;;;;;;;;;;;
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        ;气缸动
                  lcall Kdelay
                  setb P2.1         ;气缸动
                  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种功能程序  点动正
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
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       ;孔的检测,以导正菲林
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -