@ thanh_chuoi : Anh ơi cho xem xin phần mạch cân điện tử với, em đang rất cần.
mail của em là: cuongautovtc@gmail.com
mail của em là: cuongautovtc@gmail.com
;----------DONG HO SO CO HEN GIO-------------------- ;P3.1 : NUT CHINH GIO ;P3.2 : NUT HEN GIO ;P3.3 : CHON LED ;P3.4 : TANG GIA TRI CUA LED ;P3.5 : NOI VOI LOA ;---------------------------------------------------- ORG 0 LJMP MAIN ORG 0BH LJMP T0_ISR ORG 30H ;------------------------------------ MAIN: ;*********KHAI BAO BIEN********** GIO EQU 30H PHUT EQU 31H GIAY EQU 32H PTRAM_GIAY EQU 33H GIO_HEN EQU 45H PHUT_HEN EQU 46H GIAY_HEN EQU 47H MODE EQU 48H ;***********KHOI DONG BIEN******** CLR P3.5 MOV R1,#10 MOV TMOD,#01 MOV IE,#82H MOV TH0,#HIGH(-10000) MOV TL0,#LOW(-10000) SETB TR0 MOV GIAY_HEN,#60 CT_CHINH: ACALL DISPLAY ACALL CHINH_GIAY ACALL HEN_GIO_BAO_THUC ACALL SOSANH LJMP CT_CHINH ;------------------------------------ T0_ISR: CLR TR0 MOV TH0,#HIGH(-10000) MOV TL0,#LOW(-10000) SETB TR0 INC PTRAM_GIAY MOV A,PTRAM_GIAY CJNE A,#100,THOAT MOV PTRAM_GIAY,#0 INC GIAY MOV A,GIAY CJNE A,#60,THOAT MOV GIAY,#0 INC PHUT MOV A,PHUT CJNE A,#60,THOAT MOV PHUT,#0 INC GIO MOV A,GIO CJNE A,#24,THOAT MOV GIO,#0 THOAT: RETI ;---------------------------------- ;---------------------------------------- BIN_BCD: ;CHUYEN SANG DANG BCD MOV B,#10 DIV AB MOV 40H,A MOV 41H,B RET ;------------------------------------- DISPLAY: MOV P1,#00H; ACALL GAN1 ACALL LED1 ACALL LED2 ACALL LED3 ACALL LED4 ACALL LED5 ACALL LED6 RET ;---------------------------------- DISPLAY1: MOV P1,#00H; ACALL GAN2 ACALL LED1 ACALL LED2 ACALL LED3 ACALL LED4 ACALL LED5 ACALL LED6 RET ;------------------------------------------- GAN1: MOV DPTR,#BANGSO MOV A,GIAY ACALL BIN_BCD MOV 34H,41H MOV 35H,40H MOV A,PHUT ACALL BIN_BCD MOV 36H,41H MOV 37H,40H MOV A,GIO ACALL BIN_BCD MOV 38H,41H MOV 39H,40H RET ;---------------------------------- GAN2: MOV DPTR,#BANGSO MOV A,GIAY_HEN ACALL BIN_BCD MOV 34H,41H MOV 35H,40H MOV A,PHUT_HEN ACALL BIN_BCD MOV 36H,41H MOV 37H,40H MOV A,GIO_HEN ACALL BIN_BCD MOV 38H,41H MOV 39H,40H RET ;---------------------------------- LED1: MOV A,34H MOVC A,@A+DPTR MOV P1,A SETB P2.0 ACALL DELAY CLR P2.0 RET LED2: MOV A,35H MOVC A,@A+DPTR MOV P1,A SETB P2.1 ACALL DELAY CLR P2.1 RET LED3: MOV A,36H MOVC A,@A+DPTR MOV P1,A SETB P2.2 ACALL DELAY CLR P2.2 RET LED4: MOV A,37H MOVC A,@A+DPTR MOV P1,A SETB P2.3 ACALL DELAY CLR P2.3 RET LED5: MOV A,38H MOVC A,@A+DPTR MOV P1,A SETB P2.4 ACALL DELAY CLR P2.4 RET LED6: MOV A,39H MOVC A,@A+DPTR MOV P1,A SETB P2.5 ACALL DELAY CLR P2.5 RET ;------------------------------------------------ TAT_LED: MOV P1,#0FFH ACALL DELAY ACALL DELAY RET ;---------------------------------- NN1: DJNZ R1,TAT_LED ACALL LED1 ACALL LED2 MOV R1,#10 RET NN2: DJNZ R1,TAT_LED ACALL LED3 ACALL LED4 MOV R1,#10 RET NN3: DJNZ R1,TAT_LED ACALL LED5 ACALL LED6 MOV R1,#10 RET ;--------------------------------------------------- CHINH_GIAY: JB P3.1,THOAT1 A_GIAY: ADJ_GIAY: MOV R7,#0 ACALL GAN1 ACALL NN1 ACALL LED3 ACALL LED4 ACALL LED5 ACALL LED6 JNB P3.3,A_PHUT ;neu nhan chon led thi chuyen toi chinh phut JNB P3.1,THOAT1 ;neu nhan lai chinh gio dong ho thi thoat khoi ham chinh JB P3.4,ADJ_GIAY ; neu nhan tang gia tri thi chuyen toi chinh giay ADJ_GIAY1: MOV B,#70 ; yeu cau phai nhan va giu mot khoang thoi gian thi moi tang gia tri INC R7 MOV A,R7 DIV AB MOV A,B CJNE A,#0,ADJ_GIAY2 ; khi r7 tang toi 70 thi mot tang giay INC GIAY MOV A,GIAY CJNE A,#60,ADJ_GIAY2 MOV GIAY,#0 ADJ_GIAY2: ACALL DISPLAY JNB P3.4,ADJ_GIAY1 ACALL ADJ_GIAY RET ;---------------------------------------------- THOAT1: RET ;---------------------------------------------- A_PHUT: ACALL DELAY_NUT ADJ_PHUT: MOV R7,#0 ACALL GAN1 ACALL LED1 ACALL LED2 ACALL NN2 ACALL LED5 ACALL LED6 JNB P3.3,A_GIO ; neu an chon led thi nhay toi chinh h JNB P3.1,THOAT2 ; neu nhan chinh gio thi thoat khoi chuong trinh chinh JB P3.4,ADJ_PHUT ; neu ko nhan tang gia tri phut thi quay tro lai de cho ADJ_PHUT1: MOV B,#100 INC R7 MOV A,R7 DIV AB MOV A,B CJNE A,#0,ADJ_PHUT2 INC PHUT MOV A,PHUT CJNE A,#60,ADJ_PHUT2 MOV PHUT,#0 ADJ_PHUT2: ACALL DISPLAY JNB P3.4,ADJ_PHUT1 ACALL ADJ_PHUT RET ;-------------------------------------------------- A_GIO: ACALL DELAY_NUT ADJ_GIO: MOV R7,#0 ACALL GAN1 ACALL LED1 ACALL LED2 ACALL LED3 ACALL LED4 ACALL NN3 JNB P3.3,A_GIAY JNB P3.1,THOAT2 JB P3.4,ADJ_GIO ADJ_GIO1: MOV B,#150 INC R7 MOV A,R7 DIV AB MOV A,B CJNE A,#0,ADJ_GIO2 INC GIO MOV A,GIO CJNE A,#24,ADJ_GIO2 MOV GIO,#0 ADJ_GIO2: ACALL DISPLAY JNB P3.4,ADJ_GIO1 ACALL ADJ_GIO RET ;----------------------- THOAT2: RET ;------------------------------------------------- HEN_GIO_BAO_THUC: JB P3.2,THOAT2 MOV GIAY_HEN,#0 HEN_GIAY: MOV R7,#0 ACALL GAN2 ACALL NN1 ACALL LED3 ACALL LED4 ACALL LED5 ACALL LED6 JNB P3.3,B_PHUT ; neu an chon led thi nhay toi chinh phut hen JNB P3.2,THOAT4 ;neu nhan tiep hen h thi thoat khoi chuong trinh hen gio JB P3.4,HEN_GIAY HEN_GIAY1: MOV B,#50 INC R7 MOV A,R7 DIV AB MOV A,B CJNE A,#0,HEN_GIAY2 INC GIAY_HEN MOV A,GIAY_HEN CJNE A,#60,HEN_GIAY2 MOV GIAY_HEN,#0 HEN_GIAY2: ACALL DISPLAY1 JNB P3.4,HEN_GIAY1 ACALL HEN_GIAY RET ;---------------------------------------------- THOAT4: RET ;--------------------------------------------- B_PHUT: ACALL DELAY_NUT HEN_PHUT: MOV R7,#0 ACALL GAN2 ACALL LED1 ACALL LED2 ACALL NN2 ACALL LED5 ACALL LED6 JNB P3.3,B_GIO JNB P3.2,THOAT3 JB P3.4,HEN_PHUT HEN_PHUT1: MOV B,#100 INC R7 MOV A,R7 DIV AB MOV A,B CJNE A,#0,HEN_PHUT2 INC PHUT_HEN MOV A,PHUT_HEN CJNE A,#60,HEN_PHUT2 MOV PHUT_HEN,#0 HEN_PHUT2: ACALL DISPLAY1 JNB P3.4,HEN_PHUT1 ACALL HEN_PHUT RET ;---------------------------------------------------- B_GIO: ACALL DELAY_NUT HEN_GIO: MOV R7,#0 ACALL GAN2 ACALL LED1 ACALL LED2 ACALL LED3 ACALL LED4 ACALL NN3 JNB P3.3,HEN_GIAY JNB P3.2,THOAT3 JB P3.4,HEN_GIO HEN_GIO1: MOV B,#150 INC R7 MOV A,R7 DIV AB MOV A,B CJNE A,#0,HEN_GIO2 INC GIO_HEN MOV A,GIO_HEN CJNE A,#24,HEN_GIO2 MOV GIO_HEN,#0 HEN_GIO2: ACALL DISPLAY1 JNB P3.4,HEN_GIO1 ACALL HEN_GIO RET ;---------------------------------------------------- SOSANH: MOV A,GIO CJNE A,GIO_HEN,THOAT3 MOV A,PHUT_HEN CJNE A,PHUT,THOAT3 MOV A,GIAY_HEN CJNE A,GIAY,THOAT3 SETB P3.5 ACALL BAO_THUC RET ;--------------------------------------------------------- THOAT3: RET ;------------------------------------------------------ BAO_THUC: JNB P3.3,TAT_BAO_THUC JNB P3.4,TAT_BAO_THUC JNB P3.1,TAT_BAO_THUC JNB P3.2,TAT_BAO_THUC ACALL DISPLAY1 LJMP BAO_THUC RET ;----------------------------------------------------------- TAT_BAO_THUC: CLR P3.5 ACALL DELAY_NUT RET ;------------------------------------------------------------- BANGSO: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H RET ;---------------------------------- DELAY: MOV R6,#250 DJNZ R6,$ RET ;---------------------------------- DELAY_NUT: MOV R5,#200 MOV R6,#4 AGAIN1: MOV R4,#200 DJNZ R4,$ DJNZ R5,AGAIN1 DJNZ R6,AGAIN1 RET ; thoi gian delay (200 +3)*200+ (200+3)*4
Comment