Thông báo

Collapse
No announcement yet.

Robot ro duong (ai biet giup em voi )

Collapse
X
 
  • Lọc
  • Giờ
  • Show
Clear All
new posts

  • Robot ro duong (ai biet giup em voi )

    co ai co code va so do nguyen li dung 89s52 ko cho em xin voi .

  • #2
    Đây là code cho con tự động trên sala viết bằng asm, bạn tham khảo thử
    Code:
    org 000h
    		
    	LM 	BIT P2.7
    	LM_LUI 	BIT P2.6	
    	RM 	BIT P2.5
    	RM_LUI 	BIT P2.4
    	
    	RMXT	BIT P0.2
    	RMXP	BIT P0.3
    	
    	RML	BIT P2.1
    	RMX	BIT P2.0
    
    	RMX1	BIT P0.0
    	RML1	BIT P0.1
    	
    	LSN	BIT	P1.1
    	LST	BIT	P1.0
    	RST	BIT	P1.3
    	RSN	BIT	P1.2
    	COI 	BIT 	P1.4
    
    	k1 BIT P3.0
    	K2 BIT P3.1
    	K3 BIT P3.2
    	K4 BIT P3.3
    	k5 BIT P3.4
    	K6 BIT P3.5
    	K7 BIT P3.6
    	K8 BIT P3.7
    
    	mov p0,#0FFH
    	mov p1,#0FFH
    	mov p2,#0FFH
    	mov p3,#0FFH
    	MOV	TMOD,#01010101B
    
    MAIN:
    	JB	P3.3,SD
    	JMP	SANXANH
    SD: 	
    	JB	P3.6,SX
    	JMP	SANDO
    
    SX:
    	JB	P3.0,MAIN
    	JMP	CHINHCOCAU
    SANXANH:
    	JB	P3.0,SX1
    	JMP	BLUE1
    SX1:
    	JB	P3.1,SX2
    	JMP	BLUE2
    SX2:
    	JB	P3.2,SANXANH
    	JMP	BLUE3
    
    
    SANDO:
    	JB	P3.0,SD1
    	JMP	RED1
    	
    SD1:
    	JB	P3.1,SD2
    	JMP	RED2
    SD2:
    	JB	P3.2,SANDO
    	JMP	RED3
    
    BLUE1:
    	
    	CALL	CTXUATPHAT
    	CALL	DELAY03
    	CALL	CTQUEOPHAI
    	CALL	DELAY03	
    	CALL	CHAO
    
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOPHAI
    	CALL	CTGAPQUA
    	CALL	DELAY05
    	MOV	TH1,#HIGH(-450)                  
                    	MOV	TL1,#LOW(-450)
    	CLR	TF1
    	SETB	TR1
    	CLR	RM_LUI
    	CLR	LM_LUI
    DXP17:	CLR	LM
    	CLR	RM
    	JNB	TF1,DXP17
    	SETB	RM
    	SETB	LM
    	SETB	RM_LUI
    	SETB	LM_LUI
    	CALL	DELAY05
    	CALL	DELAY05
    	CALL	CTQUEOPHAICOQUA
    	CALL	DELAY05
    	CALL	CHAO
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	MOV 32H,#4
    	MOV 31H,#200
    	CLR	RM_LUI
    	CLR	RM
    	CLR	LM
    	
    XP56:        
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	DJNZ 31H,XP56
    	DJNZ 32H,XP56
    XP57:  	
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JB RSN,XP57
    	SETB	RM
    	SETB	RM_LUI
    	SETB	LM
    	CALL	DELAY05
    	CALL	CHAO
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOPHAICOQUA
    	CALL	CTBOQUA
    	CLR	RMXT
    	CALL	DELAY05
    	JB	P3.7,$
    	SETB	RMXT
    	CALL	DELAY05
    	CALL	CTQUEOPHAI
    	CALL	DELAY05
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOTRAI
    	CALL	DELAY05
    	CALL	CHAO
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOPHAI
    	CLR	RMXT
    	CLR	RMXP
    	CALL	DELAY05
    	JB	P3.7,$
    	SETB	RMXP
    	CALL	DELAY01
    	SETB	RMXT
    
    
    
    	CALL	DELAY05
    	CALL	CHAO
    	CALL	CHAY
    	MOV	TH1,#HIGH(-50)                  
                    	MOV	TL1,#LOW(-50)
    	CLR	TF1
    	SETB	TR1
    DXP60:	SETB	LM
    	SETB	RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM
    	CLR LM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JNB	TF1,DXP60	
    	SETB	RM
    	SETB	LM
    	CALL	DUNG
    
    	CLR	RML1
    	CLR	RMX1
    	CALL	DELAY05
    	SETB	RML1
    	SETB	RMX1
    	MOV	TH0,#HIGH(-100)                  
                    	MOV	TL0,#LOW(-100)
    	CLR	TF0
    	SETB	TR0
    DXP61:	CLR	RML
    	JNB	TF0,DXP61
    	SETB	RML
    	CLR	RMXT
    	CALL	DELAY05
    	JB	P3.7,$
    	SETB	RMXT
    
    	CALL	DELAY05
    	MOV	TH1,#HIGH(-200)                  
                    	MOV	TL1,#LOW(-200)
    	CLR	TF1
    	SETB	TR1
    	CLR	RM_LUI
    	CLR	LM_LUI
    DXP62:	CLR	LM
    	CLR	RM
    	JNB	TF1,DXP62
    	SETB	RM
    	SETB	LM
    	SETB	RM_LUI
    	SETB	LM_LUI
    	CALL	DELAY05
    	CALL	DELAY05
    	CALL	CTQUEOPHAICOQUA
    	CALL	DELAY05
    	CALL	CHAO
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOPHAICOQUA
    	CALL	DELAY05
    	CALL	CHAO
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOPHAICOQUA
    	CALL	CTBOQUA
    	JMP	$
    BLUE2:
    	CALL	CTDAU
    	CALL	CHAO
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOPHAICOQUA
    	CALL	CTBOQUA
    	JMP	$
    BLUE3:
    	CALL	CTDAU
    	CALL	CHAO
    	CALL	CHAY	
    	CALL	QUALINE
    	CALL	CHAY	
    	CALL	QUALINE
    	CALL	CHAY	
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY	
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOPHAICOQUA
    	CALL	CTBOQUA
    	JMP	$
    RED1:
    	CALL	CTXUATPHAT
    	CALL	DELAY03
    	CALL	CTQUEOTRAI
    	CALL	DELAY03
    	CALL	CHAO
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOTRAI
    
    	CALL	CTGAPQUADO
    	
    
    	CALL	DELAY05
    	MOV	TH1,#HIGH(-450)                  
                    	MOV	TL1,#LOW(-450)
    	CLR	TF1
    	SETB	TR1
    	CLR	RM_LUI
    	CLR	LM_LUI
    XP17:	CLR	LM
    	CLR	RM
    	JNB	TF1,XP17
    	SETB	RM
    	SETB	LM
    	SETB	RM_LUI
    	SETB	LM_LUI
    
    	CALL	DELAY05
    	CALL	DELAY05
    	
    	
    
    	CALL	CTQUEOTRAICOQUA
    	CALL	CHAO
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEO1LINETRAI
    	CALL	CHAO
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOTRAICOQUA
    	CALL	CTBOQUA
    	CLR	RMXT
    	CALL	DELAY05
    	JB	P3.7,$
    	SETB	RMXT
    	CALL	CTQUEOTRAI
    	CALL	CHAO
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    
    	CALL	CTQUEOPHAI
    	CALL	CHAO
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOTRAI
    	CLR	RMXP
    	CLR	RMXT
    	CALL	DELAY05
    	JB	P3.7,$
    	SETB	RMXP
    	CALL	DELAY01
    	SETB	RMXT
    	CALL	DELAY05
    	CALL	CHAY
    	MOV	TH1,#HIGH(-50)                  
                    	MOV	TL1,#LOW(-50)
    	CLR	TF1
    	SETB	TR1
    XP45:	SETB	LM
    	SETB	RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM
    	CLR LM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JNB	TF1,XP45	
    	SETB	RM
    	SETB	LM
    	CALL	DUNG
    	CLR	RML1
    	CLR	RMX1
    	CALL	DELAY05
    	SETB	RML1
    	SETB	RMX1
    
    	MOV	TH0,#HIGH(-100)                  
                    	MOV	TL0,#LOW(-100)
    	CLR	TF0
    	SETB	TR0
    XP46:	CLR	RML
    	JNB	TF0,XP46
    	SETB	RML
    	CLR	RMXT
    	CALL	DELAY05
    	JB	P3.7,$
    	SETB	RMXT
    	CALL	CTRED2
    	CALL	CHAO
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOTRAICOQUA
    	CALL	CTBOQUA
    	JMP	$
    RED2:
    	
    	CALL	CTXUATPHAT
    	CALL	DELAY03
    	CALL	CTQUEOTRAI
    	CALL	DELAY03
    	CALL	CHAO
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOTRAI
    	CALL	CTGAPQUADO
    	CALL	CTRED2
    	CALL	CHAO
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOTRAICOQUA
    	CALL	CTBOQUA
    	JMP	$
    RED3:
    	
    	CALL	CTXUATPHAT
    	CALL	DELAY03
    	CALL	CTQUEOTRAI
    	CALL	DELAY03
    	CALL	CHAO
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOTRAI
    	CALL	CTGAPQUADO
    	CALL	CTRED2
    	CALL	CHAO
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOTRAICOQUA
    	CALL	CTBOQUA
    	JMP	$	
    
    
    
    	
    CHINHCOCAU:
    		JB	P3.3,COCAU1
    COCAU1T:	CLR	RML
    		JNB	P3.3,COCAU1T
    		SETB	RML
    		JMP	CHINHCOCAU
    COCAU1:	
    		JB	P3.2,COCAU2
    COCAU2T:	
    		SETB	RMX
    		CALL	DELAY01
    		CLR	RMX
    		CALL	DELAY01		
    		JNB	P3.2,COCAU2T
    		SETB	RMX
    		JMP	CHINHCOCAU
    COCAU2:
    		JB	P3.0,COCAU3
    COCAU3T:	CLR	RMX1
    		JNB	P3.0,COCAU3T
    		SETB	RMX1
    		JMP	CHINHCOCAU
    COCAU3:
    		JB	P3.1,COCAU4
    		CLR	RML1
    COCAU4T:	CLR	RMX1
    		JNB	P3.1,COCAU4T
    		SETB	RMX1
    		SETB	RML1
    		JMP	CHINHCOCAU
    COCAU4:
    		JB	P3.6,COCAU5
    COCAU5T:	CLR	RMXT
    		JNB	P3.6,COCAU5T
    		SETB	RMXT
    		JMP	CHINHCOCAU
    COCAU5:
    		JB	P3.7,CHINHCOCAU
    		CLR	RMXP
    COCAU7T:	CLR	RMXT
    		JNB	P3.7,COCAU7T
    		SETB	RMXT
    		SETB	RMXP
    		JMP	CHINHCOCAU
    ;-------------------------
    CHAY:	
    
    	CLR	RM
    	CLR	LM
    BD1X:        MOV A,P1
    	ANL A,#00001111B
    	CJNE A,#00001011B,TTX
    	CALL	CHAY1
    	JMP BD1X
    	
    TTX:	CJNE A,#00000011B,TT1X
    	CALL	CHAY2
    	JMP BD1X
    
    TT1X:	CJNE A,#00000111B,TT2X	
    	SETB	RM	
    	CLR	LM
    	JMP BD1X
    
    TT2X:	CJNE A,#00001101B,TT3X	
    	CALL	CHAY3
    	JMP BD1X
    TT3X:	CJNE A,#00001100B,TT4X
    	CALL	CHAY4
    	JMP BD1X
    TT4X:	CJNE A,#00001110B,TT5X
    	SETB	LM
    	CLR	RM
    	JMP BD1X
    TT5X:	CJNE A,#00001111B,TT7X	
    	CLR	LM
    	CLR	RM
    BD1X1:	JMP BD1X
    TT7X:        CJNE A,#00000000B,TT8X
                 	 JMP THOATX
    TT8X:        CJNE A,#00001000B,TT9X
                       JMP THOATX
    TT9X:        CJNE A,#00000001B,BD1X1
                      JMP THOATX                              
    THOATX:   
    	 
    	SETB LM
    	SETB RM	
    	 RET
    
    ;-------------------------
    CHAY1:     
    	
    	SETB  	LM	
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$	
    	CLR	LM
    	MOV 30H,#100
    	DJNZ 30H,$	
    	CLR	RM
    	MOV 30H,#150
    	DJNZ 30H,$
                     RET
    ;----------------------
    CHAY2:
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR	LM
    	MOV 30H,#150
    	DJNZ 30H,$				
    	CLR	RM
    	MOV 30H,#100
    	DJNZ 30H,$
    	RET
    
    ;----------------------
    CHAY3:
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR	RM
    	MOV 30H,#100
    	DJNZ 30H,$	
    	CLR	LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	RET
    ;----------------------
    CHAY4:
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR	RM
    	MOV 30H,#150
    	DJNZ 30H,$	
    	CLR	LM
    	MOV 30H,#100
    	DJNZ 30H,$
    	RET
    
    ;-------------------------
    CHAYT1:	
    
    	CLR	RM
    	CLR	LM
    BD1:        MOV A,P1
    	ANL A,#00001111B
    	CJNE A,#00001011B,TT
    	CALL	CHAY1T
    	JMP BD1
    	
    TT:	CJNE A,#00000011B,TT1
    	CALL	CHAY2T
    	JMP BD1
    
    TT1:	CJNE A,#00000111B,TT2	
    	SETB	RM	
    	CLR	LM
    	JMP BD1
    
    TT2:	CJNE A,#00001101B,TT3	
    	CALL	CHAY3T
    	JMP BD1
    TT3:	CJNE A,#00001100B,TT4
    	CALL	CHAY4T
    	JMP BD1
    TT4:	CJNE A,#00001110B,TT5
    	SETB	LM
    	CLR	RM
    	JMP BD1
    TT5:	CJNE A,#00001111B,TT7	
    	CALL	CHAY5T	
    	JMP BD1
    TT7:        CJNE A,#00000000B,TT8
                      JMP THOAT
    TT8:        CJNE A,#00001000B,TT9  
                      JMP THOAT
    TT9:        CJNE A,#00000001B,BD1
                      JMP THOAT                            
    THOAT:   
    	
    	SETB LM
    	SETB RM	
    	SETB	RM_LUI
    	SETB	LM_LUI
    	 RET
    
    QUALINE:		
    		MOV 31H,#10
    QL:		CALL	DOENCORDER
    		DJNZ 31H,QL
    		SETB	RM
    		SETB	LM
    		RET
    THANG:
    	CLR	RM_LUI
    	CLR	LM_LUI
    	CLR	RM
    	CLR	LM
    	MOV 31H,#250
    	MOV 30H,#250
    THT:	DJNZ 30H,THT
    	DJNZ 31H,THT
    	SETB	LM
    	SETB	RM
    	SETB	RM_LUI
    	SETB	LM_LUI
    	RET
    ;-------------------------
    CHAY1T:     
    	
    	SETB  	LM	
    	SETB	RM
    	MOV 30H,#50
    	DJNZ 30H,$	
    	CLR	LM
    	MOV 30H,#100
    	DJNZ 30H,$	
    	CLR	RM
    	MOV 30H,#150
    	DJNZ 30H,$
                     RET
    ;----------------------
    CHAY2T:
    	SETB	LM
    	SETB	RM
    	MOV 30H,#50
    	DJNZ 30H,$
    	CLR	LM
    	MOV 30H,#150
    	DJNZ 30H,$				
    	CLR	RM
    	MOV 30H,#100
    	DJNZ 30H,$
    	RET
    
    ;----------------------
    CHAY3T:
    	SETB	LM
    	SETB	RM
    	MOV 30H,#50
    	DJNZ 30H,$
    	CLR	RM
    	MOV 30H,#100
    	DJNZ 30H,$	
    	CLR	LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	RET
    ;----------------------
    CHAY4T:
    	SETB	LM
    	SETB	RM
    	MOV 30H,#50
    	DJNZ 30H,$
    	CLR	RM
    	MOV 30H,#150
    	DJNZ 30H,$	
    	CLR	LM
    	MOV 30H,#100
    	DJNZ 30H,$
    	RET
    ;----------------------
    CHAY5T:
    	SETB	LM
    	SETB	RM
    	MOV 30H,#50
    	DJNZ 30H,$
    	CLR	RM
    	CLR	LM
    	MOV 30H,#100
    	DJNZ 30H,$
    	RET
    ;-------------------------
    DOENCORDER:	
    	MOV	TH1,#HIGH(-10)                  
                    	MOV	TL1,#LOW(-10)
    	CLR	TF1
    	SETB	TR1
    	CLR	RM
    	CLR	LM
    BD:        	MOV A,P1
    	ANL A,#00001111B
    	CJNE A,#00001011B,T
    	CALL	CHAY1
    	JB	TF1,ZZ1
    	JMP BD
    ZZ1:	JMP HET
    	
    T:	CJNE A,#00000011B,T1X
    	CALL	CHAY2
    	JB	TF1,ZZ2
    	JMP BD
    ZZ2:	JMP HET
    
    T1X:	CJNE A,#00000111B,T2	
    	CLR	LM
    	SETB	RM
    	JB	TF1,ZZ3
    	JMP BD
    ZZ3:	JMP HET
    
    T2:	CJNE A,#00001101B,T3	
    	CALL	CHAY3
    	JB	TF1,ZZ4
    	JMP BD
    ZZ4:	JMP HET
    T3:	CJNE A,#00001100B,T4
    	CALL	CHAY4
    	JB	TF1,ZZ5
    	JMP BD
    ZZ5:	JMP HET
    T4:	CJNE A,#00001110B,T5
    	CLR	RM
    	SETB	LM
    	JB	TF1,ZZ6
    	JMP BD
    ZZ6:	JMP HET
    T5:	CJNE A,#00001111B,T6	
    	CLR	RM
    	CLR	LM
    	JB	TF1,ZZ7
    	JMP BD
    ZZ7:	JMP HET
    T6:        	CJNE A,#00001001B,T7
                     CLR	RM
    	CLR	LM
    	JB	TF1,ZZ8
    	JMP BD
    ZZ8:	JMP HET
    T7:        	CJNE A,#00000000B,T8
                      CLR	RM
    	CLR	LM
    	JB	TF1,ZZ9
    	JMP BD
    ZZ9:	JMP HET
    T8:        	CJNE A,#00001000B,T9  
                      CLR	RM
    	CLR	LM
    	JB	TF1,ZZ10
    	JMP BD
    ZZ10:	JMP HET
    T9:        	CJNE A,#00000001B,T10
                      CLR	RM
    	CLR	LM
    	JB	TF1,ZZ11
    	JMP BD
    ZZ11:	JMP HET
    T10:        	CJNE A,#00000110B,T11
                      CLR	RM
    	CLR	LM
    	JB	TF1,ZZ12
    	JMP BD
    ZZ12:	JMP HET
    T11:        	CJNE A,#00001010B,T12
                      CLR	RM
    	CLR	LM
    	JB	TF1,ZZ13
    BDC:	JMP BD
    ZZ13:	JMP HET
    T12:        	CJNE A,#00000101B,BDC
                      CLR	RM
    	CLR	LM
    	JB	TF1,ZZ14
    	JMP BD
    ZZ14:	JMP HET
    
    HET:
    	SETB RM 
    	SETB LM
    	RET
    ;********************
    
    DOENCORDER0:	
    	
    	CLR	RM
    	CLR	LM
    T0BD:        MOV A,P1
    	ANL A,#00001111B
    	CJNE A,#00001011B,T0T
    	CALL	CHAYT01
    	JNB	P3.6,T0ZZ1
    	JMP T0BD
    T0ZZ1:	JMP T0HET
    	
    T0T:	CJNE A,#00000011B,T0T1X
    	CALL	CHAYT02
    	JNB	P3.6,T0ZZ2
    	JMP T0BD
    T0ZZ2:	JMP T0HET
    
    T0T1X:	CJNE A,#00000111B,T0T2	
    	CLR	LM
    	SETB	RM
    	JNB	P3.6,T0ZZ3
    	JMP T0BD
    T0ZZ3:	JMP T0HET
    
    T0T2:	CJNE A,#00001101B,T0T3	
    	CALL	CHAYT03
    	JNB	P3.6,T0ZZ4
    	JMP T0BD
    T0ZZ4:	JMP T0HET
    T0T3:	CJNE A,#00001100B,T0T4
    	CALL	CHAYT04
    	JNB	P3.6,T0ZZ5
    	JMP T0BD
    T0ZZ5:	JMP T0HET
    T0T4:	CJNE A,#00001110B,T0T5
    	CLR	RM
    	SETB	LM
    	JNB	P3.6,T0ZZ6
    	JMP T0BD
    T0ZZ6:	JMP T0HET
    T0T5:	CJNE A,#00001111B,T0T6	
    	CALL	CHAYT05
    	JNB	P3.6,T0ZZ7
    	JMP T0BD
    T0ZZ7:	JMP T0HET
    T0T6:        CJNE A,#00001001B,T0T7
                      CALL	CHAYT05
    	JNB	P3.6,T0ZZ8
    	JMP T0BD
    T0ZZ8:	JMP T0HET
    T0T7:        CJNE A,#00000000B,T0T8
                    CALL	CHAYT05
    	JNB	P3.6,T0ZZ9
    	JMP T0BD
    T0ZZ9:	JMP T0HET
    T0T8:        CJNE A,#00001000B,T0T9  
                      CALL	CHAYT05
    	JNB	P3.6,T0ZZ10
    	JMP T0BD
    T0ZZ10:	JMP T0HET
    T0T9:        CJNE A,#00000001B,T0T10
                    CALL	CHAYT05
    	JNB	P3.6,T0ZZ11
    	JMP T0BD
    T0ZZ11:	JMP T0HET
    T0T10:        CJNE A,#00000110B,T0T11
                 CALL	CHAYT05
    	JNB	P3.6,T0ZZ12
    	JMP T0BD
    T0ZZ12:	JMP T0HET
    T0T11:        CJNE A,#00001010B,T0T12
                      CALL	CHAYT05
    	JNB	P3.6,T0ZZ13
    T0BDC:	JMP T0BD
    T0ZZ13:	JMP T0HET
    T0T12:        CJNE A,#00000101B,T0BDC
                    CALL	CHAYT05
    	JNB	P3.6,T0ZZ14
    	JMP T0BD
    T0ZZ14:	JMP T0HET
    
    T0HET:
    	SETB RM 
    	SETB LM
    	RET
    ;-------------------------
    CHAYT01:     
    	
    	SETB  	LM	
    	SETB	RM
    	MOV 30H,#70
    	DJNZ 30H,$	
    	CLR	LM
    	MOV 30H,#20
    	DJNZ 30H,$	
    	CLR	RM
    	MOV 30H,#40
    	DJNZ 30H,$
                     RET
    ;----------------------
    CHAYT02:
    	SETB	LM
    	SETB	RM
    	MOV 30H,#70
    	DJNZ 30H,$
    	CLR	LM
    	MOV 30H,#40
    	DJNZ 30H,$				
    	CLR	RM
    	MOV 30H,#40
    	DJNZ 30H,$
    	RET
    
    ;----------------------
    CHAYT03:
    	SETB	LM
    	SETB	RM
    	MOV 30H,#70
    	DJNZ 30H,$
    	CLR	RM
    	MOV 30H,#20
    	DJNZ 30H,$	
    	CLR	LM
    	MOV 30H,#40
    	DJNZ 30H,$
    	RET
    ;----------------------
    CHAYT04:
    	SETB	LM
    	SETB	RM
    	MOV 30H,#70
    	DJNZ 30H,$
    	CLR	RM
    	MOV 30H,#40
    	DJNZ 30H,$	
    	CLR	LM
    	MOV 30H,#40
    	DJNZ 30H,$
    	RET    
    ;----------------------
    CHAYT05:
    	SETB	LM
    	SETB	RM
    	MOV 30H,#70
    	DJNZ 30H,$
    	CLR	RM
    	MOV 30H,#10
    	DJNZ 30H,$
    	CLR	LM
    	MOV 30H,#40
    	DJNZ 30H,$
    	RET    
    
    
    
    XOAYTRAI:
    XTT:	CLR	RMXT
    	JNB	P3.7,XTT	
    	CLR	RMXT
    	JB	P3.7,XPT1
    	SETB	RMXT
    	RET
    	
    XOAYPHAI:
    	CLR	RMXP
    XPT:	CLR	RMXT
    	JNB	P3.7,XPT
    	SETB	RMXT
    	SETB	RMXP
    XPT1:	CLR	RMXP
    	CLR	RMXT
    	JB	P3.7,XPT1
    	SETB	RMXP
    	SETB	RMXT
    	RET
    
    ;---------------------
    QUEOPHAI:      
    	CLR	RM
    	CLR	RM_LUI
    	CLR	LM          
    	MOV 32H,#2
    MEO1:	MOV 31H,#100
    MEO:        
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#10
    	DJNZ 30H,$
    	DJNZ 31H,MEO
    	DJNZ 32H,MEO1
          	
    QTT:  	
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#10
    	DJNZ 30H,$
    	JB RST,QTT
    QTT1:  	
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#50
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#10
    	DJNZ 30H,$
    	JB RSN,QTT1
    	SETB RM
                      SETB LM	
                      SETB RM_LUI 
    	SETB LM_LUI 
    	RET
    ;---------------------
    QUEOTRAI:       	
    	CLR	LM_LUI
                     	CLR 	RM             
    	CLR	LM
    	MOV 32H,#2
    MAO1:	MOV 31H,#100
    MAO:        
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#10
    	DJNZ 30H,$
    	DJNZ 31H,MAO
    	DJNZ 32H,MAO1
            	
    QPT:  	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#10
    	DJNZ 30H,$
    	JB LST,QPT
    
    QPT1:  	SETB	LM
    	SETB	RM
    	MOV 30H,#50
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#10
    	DJNZ 30H,$
    	JB LSN,QPT1
    	SETB RM
                      SETB LM	
    	SETB LM_LUI 
    	SETB RM_LUI 
    	RET	
    	
    DELAY02:	MOV 32H,#1
    	MOV 33H,#80
    	MOV 34H,#80
    III:	DJNZ 34H,III
    	DJNZ 33H,III
    	DJNZ 32H,III
    	RET
    
    DELAY03:	MOV 32H,#3
    	MOV 33H,#100
    	MOV 34H,#100
    LL:	DJNZ 34H,LL
    	DJNZ 33H,LL
    	DJNZ 32H,LL
    	RET
    
    DELAY04:	MOV 32H,#4
    	MOV 33H,#100
    	MOV 34H,#100
    LLL:	DJNZ 34H,LLL
    	DJNZ 33H,LLL
    	DJNZ 32H,LLL
    	RET
    
    DELAY05:	MOV 32H,#5
    	MOV 33H,#100
    	MOV 34H,#100
    KK:	DJNZ 34H,KK
    	DJNZ 33H,KK
    	DJNZ 32H,KK
    	RET
    
    DELAY01: MOV 32H,#1
    	MOV 33H,#60
    	MOV 34H,#60
    HH1:	DJNZ 34H,HH1
    	DJNZ 33H,HH1
    	DJNZ 32H,HH1
    	RET
    DUNG:
    	CLR	RM_LUI
    	CLR	LM_LUI
    	MOV 31H,#50
    	MOV 30H,#250
    DU:	CLR	RM
    	CLR	LM
    	DJNZ 30H,DU
    	DJNZ 31H,DU
    	SETB	LM
    	SETB	RM
    	SETB	LM_LUI
    	SETB	RM_LUI
    	RET
    CTQUEOTRAI:
    	CLR	LM_LUI
                     	CLR 	RM             
    	CLR	LM
    	MOV 32H,#3
    	MOV 31H,#200
    XP181:  	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#20
    	DJNZ 30H,$
    	DJNZ 31H,XP181
    	DJNZ 32H,XP181
    	CLR	LM_LUI
                     	CLR 	RM             
    	CLR	LM
    XP1:  	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#20
    	DJNZ 30H,$
    	JB LST,XP1
    	CLR	LM_LUI
                     	CLR 	RM             
    	CLR	LM
    XP2:  	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#20
    	DJNZ 30H,$
    	JB LSN,XP2
    	CLR	LM_LUI
                     	CLR 	RM             
    	CLR	LM
    	MOV 32H,#2
    	MOV 31H,#200
    XP3:  	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#20
    	DJNZ 30H,$
    	DJNZ 31H,XP3
    	DJNZ 32H,XP3
    XP4:  	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#20
    	DJNZ 30H,$
    	JB LST,XP4
    XP5:  	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#20
    	DJNZ 30H,$
    	JB LSN,XP5
    	SETB	RM
    	SETB	LM
    	SETB	LM_LUI
    	RET
    CTQUALINE:
    	MOV	TH1,#HIGH(-100)                  
                    	MOV	TL1,#LOW(-100)
    	CLR	TF1
    	SETB	TR1
    XP6:	CLR	RM
    	CLR	LM
    	JNB	TF1,XP6
    	SETB	RM
    	SETB	LM
    	RET
    CTXUATPHAT:
    	MOV	TH1,#HIGH(-100)                  
                    	MOV	TL1,#LOW(-100)
    	CLR	TF1
    	SETB	TR1
    XP:	CLR	RM
    	CLR	LM
    	JNB	TF1,XP	
    	SETB	RM
    	SETB	LM
    	MOV	TH1,#HIGH(-80)                  
                    	MOV	TL1,#LOW(-80)
    	CLR	TF1
    	SETB	TR1
    XP0:	SETB	LM
    	SETB	RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM
    	CLR LM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JNB	TF1,XP0	
    	SETB	RM
    	SETB	LM
    	CALL	DUNG
    	RET
    CTCHUANBIQUEO:
    	MOV	TH1,#HIGH(-100)                  
                    	MOV	TL1,#LOW(-100)
    	CLR	TF1
    	SETB	TR1
    XP9:	SETB	LM
    	SETB	RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM
    	CLR LM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JNB	TF1,XP9	
    	SETB	RM
    	SETB	LM
    	CALL	DUNG
    	RET
    CTQUEOTRAICOQUA:
    	CLR	LM_LUI
                     	CLR 	RM             
    	CLR	LM
    	MOV 32H,#3
    	MOV 31H,#200
    XP18:  	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#30
    	DJNZ 30H,$
    	DJNZ 31H,XP18
    	DJNZ 32H,XP18
    	CLR	LM_LUI
                     	CLR 	RM             
    	CLR	LM
    XP23:  	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#30
    	DJNZ 30H,$
    	JB LST,XP23
    	CLR	LM_LUI
                     	CLR 	RM             
    	CLR	LM
    XP24:  	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#30
    	DJNZ 30H,$
    	JB LSN,XP24
    	CLR	LM_LUI
                     	CLR 	RM             
    	CLR	LM
    	MOV 32H,#2
    	MOV 31H,#200
    XP25:  	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#30
    	DJNZ 30H,$
    	DJNZ 31H,XP25
    	DJNZ 32H,XP25
    XP26:  	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#30
    	DJNZ 30H,$
    	JB LST,XP26
    XP27:  	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#30
    	DJNZ 30H,$
    	JB LSN,XP27
    	SETB	RM
    	SETB	LM
    	SETB	LM_LUI
    	RET
    CHAO:
    	MOV	TH1,#HIGH(-50)                  
                    	MOV	TL1,#LOW(-50)
    	CLR	TF1
    	SETB	TR1
    XP34:	SETB	LM
    	SETB	RM
    	MOV 30H,#50
    	DJNZ 30H,$
    	CLR RM
    	CLR LM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JNB	TF1,XP34
    	SETB	RM
    	SETB	LM
    	SETB	RM_LUI
    	SETB	LM_LUI
    	RET
    CTQUEOPHAI:
    	MOV 32H,#3
    	MOV 31H,#200
    	CLR	RM_LUI
    	CLR	RM
    	CLR	LM
    XP39:        
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	DJNZ 31H,XP39
    	DJNZ 32H,XP39
    XP40:  	
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JB RST,XP40
    XP41:  	
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JB RSN,XP41
    	MOV 32H,#2
    	MOV 31H,#200
    	CLR	RM_LUI
    	CLR	RM
    	CLR	LM
    XP42:        
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	DJNZ 31H,XP42
    	DJNZ 32H,XP42
    XP43:  	
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JB RST,XP43
    XP44:  	
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JB RSN,XP44
    	SETB	RM
    	SETB	RM_LUI
    	SETB	LM
    	RET
    CTQUEOPHAICOQUA:
    	MOV 32H,#3
    	MOV 31H,#200
    	CLR	RM_LUI
    	CLR	RM
    	CLR	LM
    XP50:        
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	DJNZ 31H,XP50
    	DJNZ 32H,XP50
    XP51:  	
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JB RST,XP51
    XP52:  	
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JB RSN,XP52
    	MOV 32H,#2
    	MOV 31H,#200
    	CLR	RM_LUI
    	CLR	RM
    	CLR	LM
    XP53:        
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	DJNZ 31H,XP53
    	DJNZ 32H,XP53
    XP54:  	
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JB RST,XP54
    XP55:  	
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR LM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JB RSN,XP55
    	SETB	RM
    	SETB	RM_LUI
    	SETB	LM
    	RET
    CTBOQUA:
    	CALL	DELAY05
    	CALL	CHAO
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	MOV	TH1,#HIGH(-25)                  
                    	MOV	TL1,#LOW(-25)
    	CLR	TF1
    	SETB	TR1
    XP36:	SETB	LM
    	SETB	RM
    	MOV 30H,#200
    	DJNZ 30H,$
    	CLR RM
    	CLR LM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JNB	TF1,XP36
    	SETB	RM
    	SETB	LM
    	CALL	DUNG
    	CLR	RMXP
    	CLR	RMXT
    	CALL	DELAY05
    	JB	P3.7,$
    	SETB	RMXP
    	SETB	RMXP
    	CALL	DELAY01
    	SETB	RMXT
    	MOV	TH0,#HIGH(-100)                  
                    	MOV	TL0,#LOW(-100)
    	CLR	TF0
    	SETB	TR0
    XP37:	CLR	RMX
    	CALL	DELAY01
    	SETB	RMX
    	CALL	DELAY01
    	JNB	TF0,XP37
    	SETB	RMX
    	CALL	DELAY05
    	CLR	RMX1
    	CALL	DELAY03
    	SETB	RMX1
    	MOV	TH1,#HIGH(-200)                  
                    	MOV	TL1,#LOW(-200)
    	CLR	TF1
    	SETB	TR1
    	CLR	RM_LUI
    	CLR	LM_LUI
    XP38:	CLR	LM
    	CLR	RM
    	JNB	TF1,XP38
    	SETB	RM
    	SETB	LM
    	SETB	RM_LUI
    	SETB	LM_LUI
    	CALL	DELAY05
    	RET
    CTGAPQUA:
    	CLR	RMXT
    	CLR	RMXP
    	CALL	DELAY05
    	JB	P3.7,$
    	SETB	RMXP
    	CALL	DELAY01
    	SETB	RMXT
    	
    	CALL	CHAY
    	MOV	TH1,#HIGH(-50)                  
                    	MOV	TL1,#LOW(-50)
    	CLR	TF1
    	SETB	TR1
    DXP15:	SETB	LM
    	SETB	RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM
    	CLR LM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JNB	TF1,DXP15	
    	SETB	RM
    	SETB	LM
    	CALL	DUNG
    
    	CLR	RML1
    	CLR	RMX1
    	CALL	DELAY05
    	SETB	RML1
    	SETB	RMX1
    	MOV	TH0,#HIGH(-100)                  
                    	MOV	TL0,#LOW(-100)
    	CLR	TF0
    	SETB	TR0
    DXP16:	CLR	RML
    	JNB	TF0,DXP16
    	SETB	RML
    	CLR	RMXT
    	CALL	DELAY05
    	JB	P3.7,$
    	SETB	RMXT
    	RET
    CTDAU:
    	CALL	CTXUATPHAT
    	CALL	DELAY03
    	CALL	CTQUEOPHAI
    	CALL	DELAY03
    	CALL	CHAO
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOPHAI
    	CALL	CTGAPQUA
    	CALL	DELAY05
    	MOV	TH1,#HIGH(-220)                  
                    	MOV	TL1,#LOW(-220)
    	CLR	TF1
    	SETB	TR1
    	CLR	RM_LUI
    	CLR	LM_LUI
    DXP70:	CLR	LM
    	CLR	RM
    	JNB	TF1,DXP70
    	SETB	RM
    	SETB	LM
    	SETB	RM_LUI
    	SETB	LM_LUI
    	CALL	DELAY05
    	CALL	DELAY05
    	CALL	CTQUEOPHAICOQUA
    	CALL	DELAY03
    	CALL	CHAO
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	QUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOPHAICOQUA
    	RET
    CTGAPQUADO:
    	CLR	RMXT
    	CLR	RMXP
    	CALL	DELAY05
    	JB	P3.7,$
    	SETB	RMXP
    	CALL	DELAY01
    	SETB	RMXT
    	CALL	CHAO
    	CALL	CHAY
    	MOV	TH1,#HIGH(-50)                  
                    	MOV	TL1,#LOW(-50)
    	CLR	TF1
    	SETB	TR1
    XP15:	SETB	LM
    	SETB	RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR RM
    	CLR LM	
    	MOV 30H,#50
    	DJNZ 30H,$
    	JNB	TF1,XP15	
    	SETB	RM
    	SETB	LM
    	CALL	DUNG
    
    	CLR	RML1
    	CLR	RMX1
    	CALL	DELAY05
    	SETB	RML1
    	SETB	RMX1
    
    	MOV	TH0,#HIGH(-100)                  
                    	MOV	TL0,#LOW(-100)
    	CLR	TF0
    	SETB	TR0
    XP16:	CLR	RML
    	JNB	TF0,XP16
    	SETB	RML
    	CLR	RMXT
    	CALL	DELAY05
    	JB	P3.7,$
    	CLR	RMXP
    	CALL	DELAY01
    	SETB	RMXP
    	SETB	RMXT
    	RET
    CTQUEO1LINETRAI:
    	MOV 32H,#4
    	MOV 31H,#200
    	CLR	LM_LUI
    	CLR	RM
    	CLR	LM
    	
    DXP56:        
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#30
    	DJNZ 30H,$
    	DJNZ 31H,DXP56
    	DJNZ 32H,DXP56
    DXP57:  	
    	
    	SETB	LM
    	SETB	RM
    	MOV 30H,#1
    	DJNZ 30H,$
    	CLR RM
    	MOV 30H,#150
    	DJNZ 30H,$
    	CLR LM	
    	MOV 30H,#30
    	DJNZ 30H,$
    	JB LSN,DXP57
    	SETB	RM
    	SETB	LM_LUI
    	SETB	LM
    	RET
    CTRED2:
    	CALL	DELAY05
    	MOV	TH1,#HIGH(-220)                  
                    	MOV	TL1,#LOW(-220)
    	CLR	TF1
    	SETB	TR1
    	CLR	RM_LUI
    	CLR	LM_LUI
    XP47:	CLR	LM
    	CLR	RM
    	JNB	TF1,XP47
    	SETB	RM
    	SETB	LM
    	SETB	RM_LUI
    	SETB	LM_LUI
    	CALL	DELAY05
    	CALL	CTQUEOTRAICOQUA
    	CALL	CHAO
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTQUALINE
    	CALL	CHAY
    	CALL	CTCHUANBIQUEO
    	CALL	CTQUEOTRAICOQUA
    RET
    	
    	RET
    
    END

    Comment


    • #3
      trong quyển vi điều khiển của KIều xuân Thực có cả đấy
      Sửa biến tần, Servo, Máy hàn , Máy tính công nghiệp, Nguồn xung 0978666571
      Web :

      Comment


      • #4
        anh co cai code nao don gian hon khong a? cho 4 cam bien vao va 2 dau ra vi em chi can ro theo mot duong vach den ma thoi

        Comment


        • #5
          Nguyên văn bởi phamtinh.dt Xem bài viết
          trong quyển vi điều khiển của KIều xuân Thực có cả đấy
          Hình như bạn đọc chưa kỹ? Phần lập trình cho robot là lập trình với dòng AVR(cụ thể là ATMEGA128) làm j có phải 8051 đâu. Với những người mới chỉ làm quen với 8051 thì khó mà hiểu được.

          Comment


          • #6
            Nguyên văn bởi robocon2011 Xem bài viết
            Hình như bạn đọc chưa kỹ? Phần lập trình cho robot là lập trình với dòng AVR(cụ thể là ATMEGA128) làm j có phải 8051 đâu. Với những người mới chỉ làm quen với 8051 thì khó mà hiểu được.
            đối với dò đường chưa cần đến phải dùng avr.8051 cũng có thể thỏa mãn.còn có điều kiện thì dùng Avr thôi.


            khanh090991 có code nhưng ở trong sách dài lắm ngại gõ
            Sửa biến tần, Servo, Máy hàn , Máy tính công nghiệp, Nguồn xung 0978666571
            Web :

            Comment


            • #7
              Để bữa nào rảnh mình gởi code cho. Mình code bằng asm nhe bạn. Mạch điều khiển bạn định điều khiển bao nhiêu động cơ?

              Comment


              • #8
                Nguyên văn bởi phamtinh.dt Xem bài viết
                đối với dò đường chưa cần đến phải dùng avr.8051 cũng có thể thỏa mãn.còn có điều kiện thì dùng Avr thôi.


                khanh090991 có code nhưng ở trong sách dài lắm ngại gõ
                Tất nhiên rùi. Ngay cả lập trình robocon dùng 8051 vẫn ok(trừ khi dùng xử lý ảnh). Nhưng ý Tôi muốn nói ở đây đó là về cuốn sách mà bạn giớ thiệu, thì phần lập trình cho robot đó là dùng avr chứ k phải 8051.
                The end.

                Comment


                • #9
                  đây là code dò đường cho robot dung 8051, ở đây ngõ ra có 3 động cơ.bạn tham khảo thử nhé
                  ;chuong trinh dieu xung PWM cho 9051
                  ;nguoi viet: phamtrongvn@gmail.com
                  ;ngay viet: 7/05/2011
                  ;MCU 89xx

                  ;=============================
                  count_timer equ 31h
                  ;============PWM===============
                  PWM1 equ 32h
                  PWM2 equ 33h

                  #define PWM_PORT1 P1.4 ;motor RIGHT
                  #define DAO_MOTORR P1.5
                  #define PWM_PORT2 P1.6 ;motor LEFT
                  #define DAO_MOTORL P1.7

                  ;===========define sensor=======
                  #define SENSOR0 P2.7
                  #define SENSOR1 P2.6
                  #define SENSOR2 P2.5
                  #define SENSOR3 P2.4
                  #define SENSOR4 P2.3
                  #define SENSOR5 P2.2
                  #define SENSOR6 P2.1
                  #define SENSOR7 P2.0
                  #define SENSOR P2
                  ;==============================
                  org 0000h
                  ljmp main
                  org 0Bh
                  ljmp EXtimer0
                  org 03h
                  ljmp ngat_ngoai0
                  org 40h

                  main:
                  mov p1,#000
                  lcall khaibaothanhghi
                  start:
                  lcall kiemtracambien
                  sjmp start

                  ;==============================
                  ;chuong trinh phuc vu ngat ngoai0 de xua ly vat can
                  ngat_ngoai0:
                  jb p3.2,thoat_ngat_ngoai0
                  ;xu ly quay dau
                  lcall dungdongco
                  setb PWM_PORT1
                  setb DAO_MOTORL
                  jb SENSOR3,$
                  clr PWM_PORT1
                  clr DAO_MOTORL
                  mov ie,#10000000b
                  setb ex0 ;cho phep ngat ngoai 0 de phat hien vat can
                  setb it0 ;ngat ngoai 0 o canh xung
                  mov IP,#04h ; cho phep ngat ngoai uu tien hon ngat trong
                  mov sp,#5fh
                  MOV TMOD,#00000010b
                  mov th0,#(-100)
                  setb EA
                  setb ET0
                  setb TR0
                  clr c
                  thoat_ngat_ngoai0:
                  reti
                  ;==============================
                  khaibaothanhghi:
                  mov p1,#00h
                  mov ie,#10000000b
                  setb ex0 ;cho phep ngat ngoai 0 de phat hien vat can
                  setb it0 ;ngat ngoai 0 o canh xung
                  mov IP,#04h ; cho phep ngat ngoai uu tien hon ngat trong
                  mov sp,#5fh
                  MOV TMOD,#00000010b
                  mov th0,#(-100)
                  setb EA
                  setb ET0
                  setb TR0
                  ;====
                  mov count_timer,#0
                  mov PWM1,#50
                  mov PWM2,#50
                  ret
                  ;==============================
                  kiemtracambien:
                  jb SENSOR4,nhan1
                  lcall tocdo1
                  nhan1:
                  jb SENSOR3,nhan2
                  lcall tocdo2
                  nhan2:
                  jb SENSOR5,nhan3
                  lcall tocdo3
                  nhan3:
                  jb SENSOR2,nhan4
                  lcall tocdo4
                  nhan4:
                  jb SENSOR6,nhan5
                  lcall tocdo5
                  nhan5:
                  jb SENSOR1,nhan6
                  lcall tocdo6
                  nhan6:
                  jb SENSOR7,nhan7
                  lcall tocdo7
                  nhan7:
                  jb SENSOR0,nhan8
                  lcall tocdo8
                  nhan8:
                  ret
                  ;==============================
                  tocdo1:
                  mov PWM1,#50
                  MOV PWM2,#50
                  ret
                  ;==============================
                  tocdo2:
                  mov PWM1,#50
                  MOV PWM2,#50
                  ret
                  ;==============================
                  tocdo3:
                  mov PWM1,#50
                  MOV PWM2,#40
                  ret
                  ;==============================
                  tocdo4:
                  mov PWM1,#40
                  MOV PWM2,#50
                  ret
                  ;==============================
                  tocdo5:
                  mov PWM1,#50
                  MOV PWM2,#25
                  ret
                  ;==============================
                  tocdo6:
                  mov PWM1,#25
                  MOV PWM2,#50
                  ret
                  ;==============================
                  tocdo7:
                  mov PWM1,#50
                  MOV PWM2,#10
                  ret
                  ;==============================
                  tocdo8:
                  mov PWM1,#10
                  MOV PWM2,#50
                  ret
                  ;=============================
                  dungdongco:
                  mov PWM1,#0
                  MOV PWM2,#0
                  ret
                  ;==============================
                  EXtimer0:
                  PUSH acc
                  inc count_timer
                  mov a,count_timer
                  cjne a,#100,EXt1
                  mov count_timer,#0
                  EXt1:
                  mov a,count_timer
                  ;=====================
                  clr c
                  cjne a,PWM1,EXt11
                  EXt11:
                  jnc EXt111
                  setb PWM_PORT1
                  sjmp EXt2
                  EXt111:
                  clr PWM_PORT1
                  EXt2:
                  clr c
                  cjne a,PWM2,EXt22
                  EXt22:
                  jnc EXt222
                  setb PWM_PORT2
                  sjmp end_EXtimer0
                  EXt222:
                  clr PWM_PORT2
                  end_EXtimer0:
                  POP acc
                  reti
                  ;==============================
                  delay_nhieu:
                  mov r7,#255
                  djnz r7,$
                  ret
                  ;==============================
                  delay500ms:
                  mov r0,#200
                  d2: mov r1,#255
                  d3:
                  djnz r1,d3
                  djnz r0,d2
                  ret

                  end

                  dientu2.tk

                  Comment


                  • #10
                    Nguyên văn bởi robocon2011 Xem bài viết
                    Tất nhiên rùi. Ngay cả lập trình robocon dùng 8051 vẫn ok(trừ khi dùng xử lý ảnh). Nhưng ý Tôi muốn nói ở đây đó là về cuốn sách mà bạn giớ thiệu, thì phần lập trình cho robot đó là dùng avr chứ k phải 8051.
                    The end.
                    uh sorry mình nhầm.
                    Sửa biến tần, Servo, Máy hàn , Máy tính công nghiệp, Nguồn xung 0978666571
                    Web :

                    Comment


                    • #11
                      ok. 8051 viết tốt mà

                      Comment

                      Về tác giả

                      Collapse

                      khanh090991 Tìm hiểu thêm về khanh090991

                      Bài viết mới nhất

                      Collapse

                      Đang tải...
                      X