1. Trang chủ
  2. » Giáo Dục - Đào Tạo

MÃ NGUỒN CHƯƠNG TRÌNH TRÊN LIT AT89C51 PC

113 207 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 113
Dung lượng 388,5 KB

Nội dung

;Chuong trinh tren kit nhan vien ; R3, R5, R6, R7 Dung cho quet phim ; R4 Dung cho dong ho ; R2 Dung tam ; R1 Kiem tra phim C, D, E, F ORG 0000H %*DEFINE ( PUSH_DPTR) ( PUSH DPH PUSH DPL) %*DEFINE ( POP_DPTR) ( POP DPL POP DPH) COLLED DATALED EQU 4000H EQU 2000H ; Address CHECKDATAIN EQU RCADDR EQU TADDR EQU TTURNTIME EQU TCHANGEADDR TDATA1 EQU TDATA2 EQU TDATA3 EQU TDATA4 EQU 40H 41H 0100H 0101H EQU 0102H 0103H 0104H 0105H 0106H ; Enter KEYENTER EQU 42H ; Dong Ho LTIME4 LTIME5 EQU 30H EQU 31H SVTH: Nhan Minh Tiến LTIME6 LTIME7 LTIMEC EQU 32H EQU 33H EQU 3DH ; ID SO ROM LEDT0 EQU LEDT1 EQU LEDT2 EQU LEDT3 EQU LEDT4 EQU LEDT5 EQU LEDT6 EQU LEDT7 EQU LEDTC EQU 34H 35H 36H 37H 38H 39H 3AH 3BH 3CH ; ID RAM KADDR KID1 KID2 KID3 KID4 KID5 KID6 KID7 KID8 KIDE COUNT EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU POSLED KEYNUM EQU 3EH EQU 3FH JMP ORG JMP ORG JMP ORG 0107H 0108H 0109H 010AH 010BH 010CH 010DH 010EH 010FH 0110H 3000 MAIN 000BH ISRT0 0023H ISRSP 0030H ;~~~~~~~~~~~~ ; INIT BAUDRATE ;~~~~~~~~~~~~~~~ MAIN: MOV SCON, #50H SVTH: Nhan Minh Tiến MOV TMOD, #21H MOV TH1, #0FDH SETB TR1 ;Khoi Led MOV MOV MOV MOV MOV MOV MOV MOV LEDT0, #11H LEDT1, #10H LEDT2, #10H LEDT3, #10H LEDT4, #10H LEDT5, #10H LEDT6, #10H LEDT7, #10H ;AddrRC MOV RCADDR, #69H MOV DPTR, #0107H MOV A, #69H MOVX @DPTR, A ;Chu i ;KADDR ;Port MOV CHECKDATAIN, #0 MOV DPTR, #0100H ;Khoi dong ho MOV R4, #0 MOV LTIMEC, #201 MOV LTIME4, #0 MOV LTIME5, #0 MOV LTIME6, #0 MOV LTIME7, #0 ; ini vi tri led MOV POSLED, #0 MOV KEYNUM, #0 SETB TF0 MOV IE, #10010010B SETB PT0 ;Priority for timer0 interrupt MAIN1: ; xac dinh da bam phim may lan SVTH: Nhan Minh Tiến CALL MOV MOV INC IN_HEX B, A R1, A KEYNUM MOV A, KEYNUM ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ ; Save vao LEDT0 CJNE A, #1, SAVELEDT1 CJNE R1, #0AH, CKFOR1 MOV KEYNUM, #0 JMP MAIN1 CKFOR1: CJNE R1, #0BH, CKXOA1 MOV KEYNUM, #0 JMP MAIN1 CKXOA1: CJNE R1, #0CH, CKCLEAR1 MOV KEYNUM, #0 JMP MAIN1 CKCLEAR1: CJNE R1, #0DH, CKIN1 JMP QSWA CKIN1: CJNE R1,#0EH, CKENTER1 MOV KEYNUM, #0 JMP MAIN1 CKENTER1: CJNE R1, #0FH, NONECK1 MOV KEYNUM, #0 JMP MAIN1 NONECK1: MOV LEDT0, B MOV DPTR, #KID1 ; Luu vao RAM MOV A, B MOVX @DPTR, A JMP MAIN1 SVTH: Nhan Minh Tiến ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ ; Save vao LEDT1 SAVELEDT1: CJNE A, #2, SAVELEDT2 CJNE R1, #0AH, CKFOR2 MOV R1, KEYNUM CJNE R1, #1, INCKEY2A MOV KEYNUM, #0 INCKEY2A: MOV KEYNUM, #1 JMP MAIN1 CKFOR2: CJNE R1, #0BH, CKXOA2 MOV R1, KEYNUM CJNE R1, #1, INCKEY2B MOV KEYNUM, #0 INCKEY2B: MOV KEYNUM, #1 JMP MAIN1 CKXOA2: CJNE R1, #0CH, CKCLEAR2 MOV KEYNUM, #0 MOV LEDT0, #11H JMP MAIN1 CKCLEAR2: CJNE R1, #0DH, CKIN2 JMP QSWA CKIN2: CJNE R1,#0EH, CKENTER2 MOV R1, KEYNUM CJNE R1, #1, INCKEY2E MOV KEYNUM, #0 INCKEY2E: MOV KEYNUM, #1 JMP MAIN1 CKENTER2: CJNE R1, #0FH, NONECK2 MOV R1, KEYNUM CJNE R1, #1, INCKEY2F MOV KEYNUM, #0 INCKEY2F: SVTH: Nhan Minh Tiến MOV KEYNUM, #1 JMP MAIN1 NONECK2: MOV LEDT1, LEDT0 MOV LEDT0, B MOV DPTR, #KID2 ; Luu vao RAM MOV A, B MOVX @DPTR, A JMP MAIN1 ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ ; Save vao LEDT2 SAVELEDT2: CJNE A, #3, SAVELEDT3 CJNE R1, #0AH, CKFOR3 MOV R1, KEYNUM CJNE R1, #2, INCKEY3A MOV KEYNUM, #1 INCKEY3A: MOV KEYNUM, #2 JMP MAIN1 CKFOR3: CJNE R1, #0BH, CKXOA3 MOV R1, KEYNUM CJNE R1, #2, INCKEY3B MOV KEYNUM, #1 INCKEY3B: MOV KEYNUM, #2 JMP MAIN1 CKXOA3: CJNE R1, #0CH, CKCLEAR3 MOV KEYNUM, #1 JMP QXOA CKCLEAR3: CJNE R1, #0DH, CKIN3 JMP QSWA CKIN3: CJNE R1,#0EH, CKENTER3 MOV R1, KEYNUM SVTH: Nhan Minh Tiến CJNE R1, #2, INCKEY3E MOV KEYNUM, #1 INCKEY3E: MOV KEYNUM, #2 JMP MAIN1 CKENTER3: CJNE R1, #0FH, NONECK3 MOV R1, KEYNUM CJNE R1, #2, INCKEY3F MOV KEYNUM, #1 INCKEY3F: MOV KEYNUM, #2 JMP MAIN1 NONECK3: MOV LEDT2, LEDT1 MOV LEDT1, LEDT0 MOV LEDT0, B MOV DPTR, #KID3 ; Luu vao RAM MOV A, B MOVX @DPTR, A JMP MAIN1 ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ ; Save vao LEDT3 SAVELEDT3: CJNE A, #4, SAVELEDT4 CJNE R1, #0AH, CKFOR4 MOV R1, KEYNUM CJNE R1, #3, INCKEY4A MOV KEYNUM, #2 INCKEY4A: MOV KEYNUM, #3 JMP MAIN1 CKFOR4: CJNE R1, #0BH, CKXOA4 MOV R1, KEYNUM CJNE R1, #3, INCKEY4B MOV KEYNUM, #2 SVTH: Nhan Minh Tiến INCKEY4B: MOV KEYNUM, #3 JMP MAIN1 CKXOA4: CJNE R1, #0CH, CKCLEAR4 MOV KEYNUM, #2 JMP QXOA CKCLEAR4: CJNE R1, #0DH, CKIN4 JMP QSWA CKIN4: CJNE R1,#0EH, CKENTER4 MOV R1, KEYNUM CJNE R1, #3, INCKEY4E MOV KEYNUM, #2 INCKEY4E: MOV KEYNUM, #3 JMP MAIN1 CKENTER4: CJNE R1, #0FH, NONECK4 MOV R1, KEYNUM CJNE R1, #3, INCKEY4F MOV KEYNUM, #2 INCKEY4F: MOV KEYNUM, #3 JMP MAIN1 NONECK4: MOV MOV MOV MOV LEDT3, LEDT2 LEDT2, LEDT1 LEDT1, LEDT0 LEDT0, B MOV DPTR, #KID4 ; Luu vao RAM MOV A, B MOVX @DPTR, A JMP MAIN1 ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ SAVELEDT4: SVTH: Nhan Minh Tiến CJNE A, #5, SAVELEDT5 CJNE R1, #0AH, CKFOR5 MOV R1, KEYNUM CJNE R1, #4, INCKEY5A MOV KEYNUM, #3 INCKEY5A: MOV KEYNUM, #4 JMP MAIN1 CKFOR5: CJNE R1, #0BH, CKXOA5 MOV R1, KEYNUM CJNE R1, #4, INCKEY5B MOV KEYNUM, #3 INCKEY5B: MOV KEYNUM, #4 JMP MAIN1 CKXOA5: CJNE R1, #0CH, CKCLEAR5 MOV KEYNUM, #3 JMP QXOA CKCLEAR5: CJNE R1, #0DH, CKIN5 JMP QSWA CKIN5: CJNE R1,#0EH, CKENTER5 MOV R1, KEYNUM CJNE R1, #4, INCKEY5E MOV KEYNUM, #3 INCKEY5E: MOV KEYNUM, #4 JMP MAIN1 CKENTER5: CJNE R1, #0FH, NONECK5 MOV R1, KEYNUM CJNE R1, #4, INCKEY5F MOV KEYNUM, #3 INCKEY5F: MOV KEYNUM, #4 JMP MAIN1 NONECK5: MOV LEDT4, LEDT3 MOV LEDT3, LEDT2 MOV LEDT2, LEDT1 SVTH: Nhan Minh Tiến MOV LEDT1, LEDT0 MOV LEDT0, B MOV DPTR, #KID5 ; Luu vao RAM MOV A, B MOVX @DPTR, A JMP MAIN1 ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ SAVELEDT5: CJNE A, #6, SAVELEDT6 CJNE R1, #0AH, CKFOR6 MOV R1, KEYNUM CJNE R1, #5, INCKEY6A MOV KEYNUM, #4 INCKEY6A: MOV KEYNUM, #5 JMP QBACK CKFOR6: CJNE R1, #0BH, CKXOA6 MOV R1, KEYNUM CJNE R1, #5, INCKEY6B MOV KEYNUM, #4 INCKEY6B: MOV KEYNUM, #5 JMP SHIFTTO CKXOA6: CJNE R1, #0CH, CKCLEAR6 MOV KEYNUM, #4 JMP QXOA CKCLEAR6: CJNE R1, #0DH, CKIN6 JMP QSWA CKIN6: CJNE R1,#0EH, CKENTER6 MOV R1, KEYNUM CJNE R1, #5, INCKEY6E MOV KEYNUM, #4 INCKEY6E: MOV KEYNUM, #5 JMP MAIN1 SVTH: Nhan Minh Tiến 10 Option Explicit Private Type typID ID(1 To numID) As Double NameNV(1 To numID) As String End Type Dim NhanVien As typID Private Sub Command1_Click() txtQLGio.Visible = False rtxGioTrongNgay.Visible = True End Sub Private Sub Form_Resize() With Me.MSHFlexGrid1 '.Top = 1000 '.Left = 500 '.Width = ColWidth(0) = Width * 0.2 ColWidth(1) = Width * 0.4 SVTH: Nhan Minh Tiến 99 .ColWidth(2) = Width * 0.39 End With End Sub Private Sub Form_Load() tmrQLGioTrongNgay.Enabled = False txtQLGio.Visible = False With MSHFlexGrid1 TextMatrix(0, 0) = " Mã Số" TextMatrix(0, 1) = " Họ Tên" TextMatrix(0, 2) = " Giờ Làm" End With rtxGioTrongNgay.SelText = "Mã Số" & Chr(vbKeyTab) & "Họ Tên" _ & Chr(vbKeyTab) & Chr(vbKeyTab) & "Giờ Làm" & vbCrLf rtxGioTrongNgay.Text = rtxGioTrongNgay.SelText & QLNhanVien.rtxGio.Text QLGioTrongNgay.Move (Screen.Width - Width) / 2, (Screen.Height - Height) / End Sub Private Sub Form_Unload(Cancel As Integer) On Error GoTo None Write #3, QLNhanVien.rtxGio.Text QLNhanVien.Show None: End Sub Private Sub mnuQLGLed_Click() Led.Show QLGioTrongNgay.Hide End Sub Private Sub mnuQLGMain_Click() QLGioTrongNgay.Hide QLNhanVien.Hide Main.Show End Sub Private Sub mnuQLGNhanVien_Click() QLNhanVien.Show QLGioTrongNgay.Hide End Sub Private Sub mnuQLGNhiet_Click() Nhiet.Show QLGioTrongNgay.Hide End Sub SVTH: Nhan Minh Tiến 100 Private Sub mnuQLGOpen_Click() On Error GoTo ErOpen rtxGioTrongNgay.Visible = False txtQLGio.Visible = True With Main.cdl Filter = "Text Files (*.TXT)|*.TXT|" FilterIndex = ShowOpen 'Hay cdl.Action = Set txtfile = tsv.GetFile(.FileName) Set ts = txtfile.OpenAsTextStream(ForReading) txtQLGio.Text = ts.ReadAll ts.Close End With ErOpen: Exit Sub End Sub Private Sub mnuQLGThoat_Click() Unload Me 'Write #3, rtxGioTrongNgay.Text QLNhanVien.Show End Sub Private Sub tmrQLGioTrongNgay_Timer() With rtxGioTrongNgay '.SelStart = Len(.Text) SelText = QLNhanVien.MSNVTime.TextMatrix(0, 0) & Chr(vbKeyTab) _ & QLNhanVien.MSNVTime.TextMatrix(0, 1) & Chr(vbKeyTab) _ & QLNhanVien.MSNVTime.TextMatrix(0, 2) & Chr(vbKeyTab) & Chr(vbKeyTab) & vbCrLf For j = To 'For i = To numID Step SelStart = Len(.Text) SelText = QLNhanVien.MSNVTime.TextMatrix(j, 0) & Chr(vbKeyTab) _ & QLNhanVien.MSNVTime.TextMatrix(j, 1) & Chr(vbKeyTab) _ & QLNhanVien.MSNVTime.TextMatrix(j, 2) & Chr(vbKeyTab) & Chr(vbKeyTab) & vbCrLf 'Next i Next j End With End Sub SVTH: Nhan Minh Tiến 101 ‘****************************************************** ‘ Chinh gio Dim TDATA1, TDATA2, TDATA3, TDATA4 As String Dim n As Integer Private Sub ebChinhGio_Click() If txtGio.Text = "" Or txtPhut.Text = "" Then M = MsgBox("Mời Bạn Nhập Đầy Đủ", vbOKOnly, "Chỉnh Giờ") Else ChinhGio.Hide QLNhanVien.Show QLNhanVien.tmrNhanID.Enabled = True End If End Sub Private Sub Form_Load() Main.MSC.Output = "i" delay (200) Main.MSC.Output = "T" delay (200) Main.MSC.Output = "O" delay (200) ChinhGio.Move (Screen.Width - Width) / 2, (Screen.Height - Height) / End Sub Private Sub sbReset_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Main.MSC.Output = "i" delay (500) Main.MSC.Output = "T" delay (500) Main.MSC.Output = "O" SVTH: Nhan Minh Tiến 102 delay (500) 'txtGio.Text = "" 'txtPhut.Text = "" End Sub Private Sub txtGio_Change() Text1.Text = "" n = Len(txtGio.Text) Text1.Text = Mid(UCase(txtGio.Text), n, 1) Main.MSC.Output = Text1.Text TDATA1 = Mid(txtGio.Text, 1, 1) TDATA2 = Mid(txtGio.Text, 2, 1) End Sub Private Sub txtPhut_Change() Text1.Text = "" n = Len(txtPhut.Text) Text1.Text = Mid(UCase(txtPhut.Text), n, 1) Main.MSC.Output = Text1.Text End Sub ‘*********************************************************** ‘ Form Nhiet SVTH: Nhan Minh Tiến 103 Private Sub Form_Load() Nhiet.Move _ (Screen.Width - Width) / 2, (Screen.Height - Height) / End Sub Private Sub mnuNCont_Click() frmHelp.Show End Sub Private Sub mnuNHthang_Click() HinhThang.Show Nhiet.Hide End Sub Private Sub mnuNLed_Click() Nhiet.Hide Led.Show End Sub Private Sub mnuNMain_Click() Nhiet.Hide Main.Show End Sub Private Sub mnuNNhanVien_Click() Nhiet.Hide QLNhanVien.Show End Sub Private Sub mnuNOpen_Click() On Error GoTo ErOpen With Main.cdl Filter = "Text Files (*.*)|*.*|" FilterIndex = ShowOpen 'Hay cdl.Action = Set txtfile = tsv.GetFile(.FileName) Set ts = txtfile.OpenAsTextStream(ForReading) 'TC.Repaint = ts.ReadAll ts.Close End With ErOpen: SVTH: Nhan Minh Tiến 104 Exit Sub End Sub Private Sub mnuNPrint_Click() M = MsgBox("Mời Bạn Lắp Đặt Máy In Vào ", vbOKOnly, "Thu Thập Nhiệt Độ") End Sub Private Sub mnuNSave_Click() Dim n As Integer On Error GoTo ErSave If TC.Canvas = "" Then M = MsgBox("Bạn Không Có Gì Để Save !", vbOKOnly, "Save Empty") Else lap: Main.cdl.Filter = "Text files (*.*)|*.*" Main.cdl.FileName = "" Main.cdl.Action = 'Hay cdl.ShowSave If Main.cdl.FileName "" Then Source = Main.cdl.FileName If Dir(Main.cdl.FileName) "" Then n = MsgBox("Do you want to replace the existing " + _ Main.cdl.FileName + " ?", vbYesNoCancel + vbQuestion, "Save") Select Case n Case 6: Save ts.Write (LText1.Text) 'Write #2, LText1.Text ts.Close Case 7: GoTo lap End Select Else Save ts.Write (LText1.Text) 'Write #2, LText1.Text ts.Close End If End If End If ErSave: Exit Sub End Sub SVTH: Nhan Minh Tiến 105 Private Sub mnuNTgiac_Click() ThongSoFz.Show Nhiet.Hide End Sub Private Sub mnuNThoat_Click() Nhiet.Hide Main.Show End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "n1" mnuNOpen_Click Case "n2" mnuNSave_Click Case "n3" mnuNPrint_Click Case "n4" mnuNMain_Click Case "n5" mnuNLed_Click Case "n6" mnuNNhanVien_Click Case "n7" mnuNTgiac_Click Case "n8" mnuNHthang_Click Case "n9" mnuNCont_Click End Select End Sub ‘********************************************************* ‘ Chon ham lien thuoc dang tam giac SVTH: Nhan Minh Tiến 106 Option Explicit 'Hang so Const max_input = Const max_output = Const max_mf_in = Const max_mf_out = Const max_rule = 625 'Cau truc du lieu Private Type mfType Name As String Shape As Byte Par(1 To 4) As Double End Type Dim InType(1 To max_input) As Double Dim inVar(1 To max_input) As Double 'Dim outVar(1 To max_output) As Double SVTH: Nhan Minh Tiến 107 Dim RuleType(1 To max_input + max_output) As Byte Dim r(1 To max_input + max_output) As Byte 'Dim Weight As Double 'Cac bien Dim n_in As Byte Dim n_out As Byte Dim n_mf_in(1 To max_input) As Byte Dim n_mf_out(1 To max_output) As Byte Dim n_rule As Integer Dim mf_in(1 To max_input, To max_mf_in) As mfType Dim mf_out(1 To max_output, To max_mf_out) As mfType Dim Rule(1 To max_rule, To max_input + max_output) As Byte 'Khoi dong cac bien 'Nhap tu giao dien 'n_in=2 'n_out=1 'n_mf_in(1)=3 so tap mo o ngo vao 'n_mf_in(2)=3 so tap mo o ngo vao 'n_mf_out(1)=5 so tap mo o ngo la 'n_rule=9 Private Sub KD3() n_in = txtnIn n_out = txtnOut n_mf_in(1) = n_mf_in(2) = n_mf_out(1) = 'For i = To max_input 'n_mf_in(i) = txtmfin 'Next i 'For j = To max_output 'n_mf_out(j) = txtmfout 'Next j n_rule = 'n_mf_in(1) ^ n_in 'Khoi dong gia tri ban dau cho cac tap mo o ngo vao mf_in(1, 1).Name = "NE" mf_in(1, 1).Shape = mf_in(1, 1).Par(1) = -2 mf_in(1, 1).Par(2) = -1 mf_in(1, 1).Par(3) = SVTH: Nhan Minh Tiến 108 mf_in(1, 2).Name = "ZE" mf_in(1, 2).Shape = mf_in(1, 2).Par(1) = -1 mf_in(1, 2).Par(2) = mf_in(1, 2).Par(3) = mf_in(1, 3).Name = "PO" mf_in(1, 3).Shape = mf_in(1, 3).Par(1) = mf_in(1, 3).Par(2) = mf_in(1, 3).Par(3) = 'Khoi dong gia tri ban dau cho cac tap mo o ngo vao mf_in(2, 1).Name = "NE" mf_in(2, 1).Shape = mf_in(2, 1).Par(1) = -2 mf_in(2, 1).Par(2) = -1 mf_in(2, 1).Par(3) = mf_in(2, 2).Name = "ZE" mf_in(2, 2).Shape = mf_in(2, 2).Par(1) = -1 mf_in(2, 2).Par(2) = mf_in(2, 2).Par(3) = mf_in(2, 3).Name = "PO" mf_in(2, 3).Shape = mf_in(2, 3).Par(1) = mf_in(2, 3).Par(2) = mf_in(2, 3).Par(3) = 'Khoi dong gia tri ban dau cho cac tap mo o ngo vao mf_out(1, 1).Name = "NB" mf_out(1, 1).Shape = mf_out(1, 1).Par(1) = -1 mf_out(1, 1).Name = "NS" mf_out(1, 1).Shape = mf_out(1, 1).Par(1) = -0.5 mf_out(1, 1).Name = "ZE" mf_out(1, 1).Shape = mf_out(1, 1).Par(1) = mf_out(1, 1).Name = "PS" SVTH: Nhan Minh Tiến 109 mf_out(1, 1).Shape = mf_out(1, 1).Par(1) = 0.5 mf_out(1, 1).Name = "PB" mf_out(1, 1).Shape = mf_out(1, 1).Par(1) = 'He qui tac mo 'Neu nhiet la ZE va Nhietdot la ZE thi voltage la ZE Rule(1, 1) = Rule(1, 2) = Rule(1, 3) = 'Neu nhiet la ZE va Nhietdot la NE thi voltage la NS Rule(2, 1) = Rule(2, 2) = Rule(2, 3) = 'Neu nhiet la ZE va Nhietdot la PO thi voltage la PS Rule(1, 1) = Rule(1, 2) = Rule(1, 3) = 'Neu nhiet la NE va Nhietdot la ZE thi voltage la NS Rule(1, 1) = Rule(1, 2) = Rule(1, 3) = End Sub 'Ham mo hoa doi voi ham lien thuoc dang tam giac Private Function mftri(xx As Double, ll As Double, cc As Double, rr As Double) As Double If ((xx = rr)) Then mftri = End If If ((xx > ll) And (xx cc) And (xx < rr)) Then mftri = (rr - xx) / (rr - cc) End If End Function 'Ket qua suy dien cua quy tac mo SVTH: Nhan Minh Tiến 110 '(dung toan tu PROD de thuc hien toan tu AND) 'Private Sub one_rule_inference(r, inVar) Private Sub rWeight(r, inVar) 'Dim outVar(1 To max_output) As Double Dim riWeight As Double Dim x, y As Byte 'Dim r(1 To max_input + max_output) As Byte riWeight = For x = To n_in If mf_in(i, r(i)).Shape = Then riWeight = riWeight * mftri(inVar(i), mf_in(i, r(i)).Par(1), mf_in(i, r(i)).Par(2), mf_in(i, r(i).Par(3))) End If Next x rWeight = riWeight End Sub Private Sub routVar(r, inVar) Dim Weight As Double Weight = rWeight(r, inVar) For y = To n_out If mf_out(i, r(n_in + i)).Shape = Then OutVar = mf_out(i, r(n_in + i)).Par(1) * Weight End If Next y 'Ngoai cac dang ham lien thuoc khac routVar = OutVar End Sub 'Ket qua suy dien cua he qui tac mo Private Sub all_rule_inference(inVar) Dim wtsum, Weight As Double Dim tempOut(1 To max_output) As Double Dim OutVar(1 To max_output) As Double Dim x, y As Byte For x = To n_out OutVar(x) = wtsum = For x = To n_rule Weight = rWeight(Rule(i), inVar) tempOut = routVar(Rule(i), inVar) wtsum = wtsum + Weight For y = To n_out OutVar(y) = OutVar(y) + tempOut(y) SVTH: Nhan Minh Tiến 111 Next y Next x For x = To n_out OutVar(x) = OutVar(x) / Weight Next x all_rule_inference = OutVar End Sub Private Sub chkBangLuat_Click() On Error GoTo ErOpen With Main.cdl Filter = "Text Files (*.TXT)|*.TXT|" FilterIndex = ShowOpen 'Hay cdl.Action = Set txtfile = tsv.GetFile(.FileName) Set ts = txtfile.OpenAsTextStream(ForReading) Text1.Text = ts.ReadAll ts.Close End With ErOpen: Exit Sub 'With Main.cdl '.FileName = "c:\as.txt" 'Set txtfile = tsv.GetFile(Main.cdl.FileName) 'Set ts = txtfile.OpenAsTextStream(ForReading) 'Text1.Text = ts.ReadAll 'End With chkBangLuat.Value = End Sub Private Sub Command1_Click() KD3 End Sub Private Sub ebBangLuatOK_Click() ThongSoFz.Hide Nhiet.Show End Sub Private Sub Form_Load() With MSBangDK SVTH: Nhan Minh Tiến 112 .ColWidth(0) = 1300 ColWidth(1) = 1300 ColWidth(2) = 1500 TextMatrix(0, 0) = "ET" TextMatrix(0, 1) = "DET" TextMatrix(0, 2) = "OUT" End With ThongSoFz.Move _ (Screen.Width - Width) / 2, (Screen.Height - Height) / End Sub Phần source chương trình có đóa CD, xem dễ dàng đầy đủ SVTH: Nhan Minh Tiến 113 [...]... ;~~~~~~~~~~~~~~~~~~~~~~~~~~ ; PC luon goi tin hieu bao nhan ID, tin hieu la !(21h) ; VXL khi nhan duoc phim enter thi goi ID ve ; PC so sanh, neu dung goi tin hieu bao dung ISRSP: JNB RI, $ CLR RI MOV A, SBUF INC CHECKDATAIN MOV R2, CHECKDATAIN CJNE MOV MOV CJNE CALL MOV MOV CTT12: CJNE MOV MOV MOV MOV MOV MOV MOV A, #21H, CTT12 ; ! PC muon nhan ID CHECKDATAIN, #0 R2, KEYENTER R2, #0FH, CTT12 ; Enter thi goi ID ve PC SENDDATA... phim enter, luu vao o nho LEDTC CKCLEAR9: MOV A, B CJNE A, #0FH, WHATK ;Neu la phim Enter thi ngat SP ;MOV DPTR, #KIDE; Luu vao RAM ;MOV A, B ;MOVX @DPTR, A MOV KEYENTER, B ;CALL SENDDATA ; Goi ID ve PC MOV KEYNUM, #0 JMP main1 WHATK: MOV KEYNUM, #8 CJNE R1, #0AH, CKFOR JMP QBACK CKFOR: CJNE R1, #0BH, CKXOA JMP SHIFTTO CKXOA: CJNE R1, #0CH, CKCLEAR JMP QXOA CKCLEAR: CJNE R1, #0DH, CKIN JMP QSWA CKIN:... A, #7, QSCAN CALL DISL7 QSCAN: INC POSLED MOV A, POSLED SVTH: Nhan Minh Tieán 19 CJNE A, #8, QISCAN MOV POSLED, #0 ;86 MICRO SEC QISCAN: ;POP ACC RETI ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Goi ID den PC ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SENDDATA: MOV CALL CALL MOV CALL CALL MOV CALL CALL MOV CALL CALL MOV CALL CALL MOV CALL CALL MOV CALL CALL MOV CALL CALL A, LEDT7 HTOA OUTCHAR A, LEDT6 HTOA OUTCHAR... 8 RET SVTH: Nhan Minh Tieán 20 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SENDADDR: MOV A, #69H CALL HTOA MOV SBUF, A JNB TI, $ CLR TI RET ;~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Goi data ve PC ;~~~~~~~~~~~~~~~~~~~~~~~~~~ OUTCHAR: MOV SBUF, A JNB TI,$ CLR TI RET ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Thay doi dia chi ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ THAYADDR: MOV DPTR, #TCHANGEADDR ; Tro toi o nho ... Ngat Port noi tiep ;~~~~~~~~~~~~~~~~~~~~~~~~~~ ; PC luon goi tin hieu bao nhan ID, tin hieu la !(21h) ; VXL nhan duoc phim enter thi goi ID ve ; PC so sanh, neu dung goi tin hieu bao dung ISRSP:... CTT12: CJNE MOV MOV MOV MOV MOV MOV MOV A, #21H, CTT12 ; ! PC muon nhan ID CHECKDATAIN, #0 R2, KEYENTER R2, #0FH, CTT12 ; Enter thi goi ID ve PC SENDDATA KEYENTER, #0 CHECKDATAIN, #0 A, #23H, CTT0... ;MOV DPTR, #KIDE; Luu vao RAM ;MOV A, B ;MOVX @DPTR, A MOV KEYENTER, B ;CALL SENDDATA ; Goi ID ve PC MOV KEYNUM, #0 JMP main1 WHATK: MOV KEYNUM, #8 CJNE R1, #0AH, CKFOR JMP QBACK CKFOR: CJNE R1,

Ngày đăng: 20/11/2015, 00:16

TỪ KHÓA LIÊN QUAN

w