1. Trang chủ
  2. » Luận Văn - Báo Cáo

THIẾT KẾ HỆ THỐNG ĐIỀU KHIỂN KHÔNG DÂY BÁO CHÁY TỪ XA CHO KHO CHỨA NÔNG SẢN

84 164 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

Nội dung

BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC NÔNG LÂM TP HỒ CHÍ MINH KHOA CƠ KHÍ & CƠNG NGHỆ  NGUYỄN THÀNH NHÂN THIẾT KẾ HỆ THỐNG ĐIỀU KHIỂN KHÔNG DÂY BÁO CHÁY TỪ XA CHO KHO CHỨA NƠNG SẢN Tp Hồ Chí Minh Tháng 08 năm 2008 BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC NƠNG LÂM TP HỒ CHÍ MINH KHOA CƠ KHÍ & CÔNG NGHỆ  THIẾT KẾ HỆ THỐNG ĐIỀU KHIỂN KHÔNG DÂY BÁO CHÁY TỪ XA CHO KHO CHỨA NÔNG SẢN Chuyên ngành: Điều Khiển Tự Động Giáo viên hướng dẫn: Sinh viên thực hiện: ThS ĐẶNG PHI VÂN HÀI NGUYỄN THÀNH NHÂN Tp Hồ Chí Minh Tháng 08 năm 2008 i MINISTRY OF EDUCATION AND TRAINING NONG LAM UNIVERSITY FACULTY OF ENGINEERING & TECHNOLOGY  DESIGN WIRELESS FIRE WARNING SYSTEM FOR THE AGRICULTURAL PRODUCT STORAGE Speciality: Automatic Control Supervisor: Student: MsE DANG PHI VAN HAI NGUYEN THANH NHAN Ho Chi Minh City August, 2008 ii MỤC LỤC Trang Trang tựa i Cảm tạ ii Tóm tắt iii Mục lục iv Danh sách chữ viết tắt v Danh sách hình vi Danh sách bảng vii CHƯƠNG MỞ ĐẦU CHƯƠNG TRA CỨU TÀI LIỆU SÁCH BÁO PHỤC VỤ ĐỀ TÀI 2.1 Các hệ thống báo cháy 2.1.1 Hệ thống báo cháy quy ước 2.1.2 Hệ thống báo cháy địa 2.2 Tra cứu hệ thống điều khiển không dây 2.2.1 Điều khiển từ xa 2.2.1.1 Điều khiển từ xa hồng ngoại 2.2.1.2 Điều khiển từ xa sóng vơ tuyến 10 2.2.2 Các khái niệm truyền sóng vơ tuyến 10 2.2.2.1 Biên độ bước sóng 10 2.2.2.2 Bức xạ điện từ 11 2.2.2.3 Pha 12 2.2.2.4 Các phương thức điều chế 13 2.2.2.5 Các phương thức truyền thông 16 iii 2.3 Tìm hiểu phần mềm BASCOM AVR lập trình cho vi điều khiển ATMEGA32 17 2.4 Tìm hiểu phần mềm VISUAL BASIC 6.0 lập trình giao tiếp truyền nhận liệu qua cổng nối tiếp 19 2.4.1 Phần mềm VISUAL BASIC 6.0 19 2.4.2 Các phương pháp giao tiếp máy tính 21 2.4.2.1 Giao tiếp qua Slot 22 2.4.2.2 Giao tiếp qua cổng COM 22 2.4.2.3 Giao tiếp qua cổng máy in (cổng song song) 22 2.4.3 Giao tiếp cổng nối tiếp (COM) 23 CHƯƠNG PHƯƠNG PHÁP VÀ PHƯƠNG TIỆN 26 3.1 Phương pháp thực đề tài 26 3.1.1 Chọn phương pháp truyền nhận cho hệ thống không dây 26 3.1.2 Chọn phương pháp thiết kế hệ thống báo cháy 26 3.1.3 Chọn phương pháp thiết kế mạch 26 3.1.4 Chọn phương pháp thiết kế giao diện viết phần mềm điều khiển 27 3.2 Phương tiện thực đề tài 27 CHƯƠNG THỰC HIỆN ĐỀ TÀI 28 4.1 Chọn thiết bị áp dụng đề tài 29 4.1.1 Chọn loại module RF 29 4.1.1.1 Một số dạng module RF có thị trường 28 4.1.1.2 Chọn Module HM-TR 30 4.1.1.3 Cấu trúc phần cứng module 31 4.1.1.4 Phân loại module 32 4.1.1.5 Các chế độ hoạt động module 31 4.1.1.6 Các ứng dụng module 31 4.1.1.7 Xác lập thông số cho module 32 4.1.2 Chọn số thiết bị cho hệ thống báo cháy 33 4.1.2.1 Cảm biến phát khói 33 iv 4.1.2.2 Cảm biến nhiệt độ 34 4.1.3 Chọn Vi điều khiển cho ứng dụng đề tài 35 4.1.4 Chọn thiết bị hiển thị 39 4.1.5 Mạch nạp vi điều khiển ISP programer 40 4.2 Sơ đồ khối bước thiết kế thực đề tài 42 4.3 Sơ đồ khối hệ thống báo cháy 43 4.4 Thiết kế thi công bo mạch kết nối module với máy tính 43 4.5 Thiết kế thi công bo mạch kết nối module với vi điều khiển 45 4.6 Thiết kế thi cơng bo mạch truyền nhận liệu điều khiển 46 4.7 Viết chương trình điều khiển cho vi điều khiển 48 4.8 Viết chương trình giao diện giám sát, điều khiển máy tính 49 4.9 Một số khó khăn vấn đề phát sinh q trình thực đề tài 53 CHƯƠNG KẾT LUẬN VÀ ĐỀ NGHỊ 54 5.1 Kết luận 54 5.2 Đề nghị 55 TÀI LIỆU THAM KHẢO PHỤ LỤC v LỜI CẢM TẠ Trước tiên em xin bày tỏ lòng biết ơn cha mẹ, đấng sinh thành nuôi dưỡng dạy dỗ em khôn lớn Để thực đề tài em nhận nhiều hỗ trợ quý thầy cô trường Đại học Nông Lâm, đặc biệt thầy thuộc Khoa Cơ Khí Cơng Nghệ Thầy dạy dỗ em bốn năm học tập trường, cung cấp cho em kiến thức dồi vơ bổ ích Em xin gửi lời cảm ơn sâu sắc đến cô ĐẶNG PHI VÂN HÀI, người trực tiếp hướng dẫn em thực đề tài, giúp em giải khắc phục cố để hoàn thành đề tài Xin gửi lời cảm ơn góp ý giúp đỡ bạn học lớp suốt thời gian học trường làm luận văn tốt nghiệp Xin chân thành cảm ơn! Tp.HCM tháng năm 2008 Nguyễn Thành Nhân vi TÓM TẮT Đề tài: THIẾT KẾ HỆ THỐNG ĐIỀU KHIỂN KHÔNG DÂY BÁO CHÁY TỪ XA CHO KHO CHỨA NÔNG SẢN Việt Nam nước có kinh tế chủ yếu dựa vào nơng nghiệp, lượng nơng sản cung ứng hàng năm lớn Vấn đề đặt phải có hệ thống kho chứa đáp ứng đầy đủ cho số lượng lớn nông sản Việc bảo quản loại nông sản không thời gian ngắn mà q trình dài phức tạp Do cần có chế độ bảo quản hợp lý đồng thời cảnh báo trường hợp khẩn cấp, đặc biệt xảy hoả hoạn Đặc tính loại nơng sản trữ kho thường có độ ẩm thấp khơ nên dễ bốc cháy Cần có hệ thống báo cháy thơng minh kịp thời để giảm đến mức thấp thiệt hại trường hợp xảy cố Với mục đích trên, chúng tơi tiến hành thực đề tài hoàn thành yêu cầu đặt ra: - Hệ thống truyền liệu nối tiếp không dây hoạt động tốt - Các cảm biến nhạy đáp ứng yêu cầu hệ thống báo cháy - Phần mềm hoạt động ổn định điều chỉnh cách linh hoạt Bước đầu hệ thống áp dụng vào thực tế nhằm nâng cao tính an tồn việc bảo quản kho nông sản thấy việc áp dụng khoa học kỹ thuật vào sản xuất nông nghiệp thực tế sống nhằm giảm sức lao động mang lại hiệu kinh tế cao GVHD: SVTH: ThS ĐẶNG PHI VÂN HÀI NGUYỄN THÀNH NHÂN vii SUMMARY Thesis: DESIGN WIRELESS FIRE WARNING SYSTEM FOR THE AGRICULTURAL PRODUCT STORAGE Viet Nam is a country which has the economy mainly depends on agriculture Therefore, a big amount of agricultural produce was created every year The essential problem is we must have an enough stored system for those The storing of those agricultural products is not in a short time, but it needs a long time storing with a complex process A suitable storing and an on time alert system in an urgent situation are necessary The stored agricultural produce belongings are low humidity and dry, so they are easy to be fired It’s necessary to design a smart fire alarm system in order to alert on time and reduce to lowest damage when fire burns With the purpose above, I proceeded to this thesis and successfully completed it My thesis’s achievements are : - The serial wireless data transferring system is in good operating - The sensors are sensitive and satisfy to a fire alarm system - The software is stable and flexible As a result, the system is applicable for reality It is not only enhance the safety factor in agricultural storing, but also show the applying of technical science for agriculture to save farmer’s labor and to achieve economic efficiency Lecturer in charge: Student: MsE DANG PHI VAN HAI NGUYEN THANH NHAN DANH SÁCH CÁC CHỮ VIẾT TẮT viii - ADC: Analog to Digital Converter - ASK: Amplitude Shift Keying - ASCII: America Standard Code for Information Interchange - CD: Carrier Detect - CTS: Clear To Send - DTR: Data Terminal Ready - DSR: Data Set Ready - EEPROM: Electrically Erasable Programmable Read Only Memo - FSK: Frequency Shift Keying - HM-TR: Transparent Wireless Data Link Module - LCD: Liquid Crystal Display - PSK: Phase Shift Keying - OOP: Object-Oriented Programming - PWM: Pulse Width Modulation - RAD: Rapid Application Development - RI: Ring Indicator - RxD: Receive Data - RTS: Request To Send - SG: Signal Ground - SRAM: Static Random Access Memory - TTL: Transistor Transistor Logic - TxD: Transmit Data - UART: Universal Asynchronous Receiver Transmitter DANH SÁCH CÁC HÌNH ix - 57 - * Chương trình viết cho vi điều khiển Atmega32: ' ' ********** LUAN VAN TOT NGHIEP ************ CHUONG TRINH DIEU KHIEN BAO CHAY TU DONG KHO BAO QUAN NONG SAN ' $regfile = "m32def.dat" $crystal = 1000000 $baud = 4800 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Khai bao cac chuong trinh Declare Sub Do_nhietdo Declare Sub Truyen_data Declare Sub Nhan_data 'Bao_dong1: Nhiet tang cao qua muc cho phep Declare Sub Nhiet_do_cao 'Bao_dong chay: Khi phat hien khoi Declare Sub Phat_hien_khoi Declare Sub Bao_dong_chay 'May tinh dieu khien tu xa Declare Sub May_tinh_dk_tu_xa '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Cac bien cho chuong trinh nhiet Dim Kenhnhietdo As Word Dim Kenhnhietdo2 As Word Dim Giatri As Word Dim Giatri2 As Word Dim Lap As Byte Dim Lap2 As Byte Dim Total As Long Dim Total2 As Long Dim Phan_nguyen As Word Dim Phan_nguyen2 As Word Dim Phan_du As Word Dim Phan_du2 As Word '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Cac bien cho chuong trinh Nhan data Dim Data_in As String * Dim Data_in_val As Byte '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Cac bien cho bao_dong_chay: Dim Khoi As Byte - 58 - Dim Coi_bao_dong As Bit Dim Tt_khoi As String * 'Khong phat hien khoi luc khoi dong chuong trinh: Khoi = 111 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Cac bien cho chuong trinh may tinh dieu khien tu xa: Dim Den As Bit Dim Quat As Bit Dim Dien_nguon As Bit Dim Tt_den As String * Dim Tt_quat As String * Dim Tt_dien_nguon As String * '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Su dung ngat ngoai cua vdk de nhan tin hieu bao khoi tu dau phat hien khoi Enable Interrupts Enable Int0 Enable Int1 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On Int0 Phat_hien_khoi On Int1 Phat_hien_khoi '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Khoi dong bo chuyen doi AD Config Adc = Single , Prescaler = Auto Config Portc = Output '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Den Alias Portc.1 'Pin C.1: Dieu khien he thong den Quat Alias Portc.2 'Pin C.2: Dieu khien he thong quat Dien_nguon Alias Portc.3 'Pin C.3: Dieu khien dong mo dien nguon Coi_bao_dong Alias Portc.4 'Pin C.4: Dieu khien coi bao dong '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Start Adc Kenhnhietdo = Kenhnhietdo2 = Deflcdchar , , , , , 32 , 32 , 32 , 32 Deflcdchar , , 17 , 14 , 17 , 17 , 17 , 17 , 14 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Chuong trinh Khoi dong Main0: Cursor Off Cls Locate , Lcd "Khoa CoKhi CN-BMDKTD" Lowerline Locate , Lcd " DE TAI TOT NGHIEP " - 59 - Thirdline Locate , Lcd " He Thong Bao Chay" Fourthline Locate , Lcd " Tai Kho Bao Quan" Wait Cls Locate , Lcd "GVHD:" Lowerline Locate , Lcd "Ths Dang Phi Van Hai" Thirdline Locate , Lcd "SVTH:" Fourthline Locate , Lcd "Nguyen Thanh Nhan" Wait '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Chuong trinh chinh Main: Cls Do Gosub Do_nhietdo If Data_in_val = Then Gosub May_tinh_dk_tu_xa If Phan_nguyen > 35 Then Gosub Nhiet_do_cao If Phan_nguyen2 > 35 Then Gosub Nhiet_do_cao If Phan_nguyen > 60 Then Gosub Bao_dong_chay If Phan_nguyen2 > 60 Then Gosub Bao_dong_chay If Khoi = 222 Then Tt_khoi = "Co" If Khoi = 111 Then Tt_khoi = "Khong" Locate , Lcd " CHUONG TRINH CHINH" Lowerline Locate , Lcd " +Nhiet 1: " ; Phan_nguyen ; "." ; Phan_du ; Chr(0) ; "c" Thirdline Locate , Lcd " +Nhiet 2: " ; Phan_nguyen2 ; "." ; Phan_du2 ; Chr(0) ; "c" Fourthline Locate , Lcd " +Bao khoi: " ; Tt_khoi Waitms 500 Gosub Nhan_data - 60 - Gosub Truyen_data Loop '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Chuong trinh nhiet Do_nhietdo: 'Cam bien Giatri = Getadc(kenhnhietdo) Total = For Lap = To 100 Giatri = Getadc(kenhnhietdo) Total = Total + Giatri Waitms Next Lap Giatri = Total / 100 Phan_du = Giatri Mod 10 Phan_nguyen = Giatri - Phan_du Phan_nguyen = Phan_nguyen / 10 'Cam bien Giatri2 = Getadc(kenhnhietdo2) Total2 = For Lap2 = To 100 Giatri2 = Getadc(kenhnhietdo2) Total2 = Total2 + Giatri2 Waitms Next Lap2 Giatri2 = Total2 / 100 Phan_du2 = Giatri2 Mod 10 Phan_nguyen2 = Giatri2 - Phan_du2 Phan_nguyen2 = Phan_nguyen2 / 10 Return '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Chuong tirnh nhan du lieu Nhan_data: Data_in = Inkey() Data_in_val = Val(data_in) Return '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Chuong trinh truyen du lieu Truyen_data: Print "x" ; Giatri Waitms 200 Print "y" ; Giatri2 Waitms 200 Print "z" ; Khoi Waitms 200 Return - 61 - '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Mode dieu khien 1: Tuoi nuoc, khong bon phan, quat gio Nhiet_do_cao: Cls Do Gosub Nhan_data Gosub Do_nhietdo Gosub Truyen_data If Data_in_val = Then Gosub May_tinh_dk_tu_xa If Phan_nguyen < 35 Then Gosub Main If Phan_nguyen2 < 35 Then Gosub Main If Khoi = 222 Then Tt_khoi = "Co" If Khoi = 111 Then Tt_khoi = "Khong" Locate , Lcd " NHIET DO CAO " Lowerline Locate , Lcd " +Nhiet 1: " ; Phan_nguyen ; "." ; Phan_du ; Chr(0) ; "c" Thirdline Locate , Lcd " +Nhiet 2: " ; Phan_nguyen2 ; "." ; Phan_du2 ; Chr(0) ; "c" Fourthline Locate , Lcd " +Bao khoi: " ; Tt_khoi Waitms 500 Loop '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Khi phat hien khoi: Phat_hien_khoi: Khoi = 222 Gosub Truyen_data Gosub Bao_dong_chay Return '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Bao dong chay: Bao_dong_chay: Cls Set Portc.7 Do Gosub Nhan_data Locate , Lcd " - BAO DONG - " Lowerline Locate , Lcd " Co chay xay " Thirdline - 62 - Locate , Lcd " ->Da Ngat " Fourthline Locate , Lcd " Nguon Dien" Waitms 500 'bat coi bao dong va tat dien nguon Coi_bao_dong = Dien_nguon = If Data_in_val = Then Gosub May_tinh_dk_tu_xa If Data_in_val = Then Reset Portc.7 Loop Return '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'May tinh dieu khien tu xa: May_tinh_dk_tu_xa: Cls Do Gosub Nhan_data Gosub Do_nhietdo Gosub Truyen_data If Data_in_val = Then Den = If Data_in_val = Then Quat = If Data_in_val = Then Dien_nguon = If Data_in_val = Then Den = If Data_in_val = Then Quat = If Data_in_val = Then Dien_nguon = If Data_in_val = Then Gosub Main If Khoi = Then Tt_khoi = "Co" If Khoi = Then Tt_khoi = "Khong" If Den = Then Tt_den = " Tat" If Quat = Then Tt_quat = " Tat" If Dien_nguon = Then Tt_dien_nguon = " Tat" Tt_den = " Tat" Tt_quat = " Tat" End If If Den = Then Tt_den = " Mo" If Quat = Then Tt_quat = " Mo" If Dien_nguon = Then Tt_dien_nguon = " Mo" Locate , Lcd "MAY TINH DIEU KHIEN" Lowerline Locate , Lcd " +Dien nguon: " ; Tt_dien_nguon - 63 - Thirdline Locate , Lcd " +Quat: " ; Tt_quat Fourthline Locate , Lcd " +Den:" ; Tt_den Waitms 500 Loop '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * CHƯƠNG TRÌNH VIẾT CHO GIAO DIỆN ĐIỀU KHIỂN BẰNG VISUAL BASIC 6.0: *Form chính: Private Sub Command1_Click() Help.Visible = True Unload Me End Sub Private Sub Command2_Click() Unload Me mophong.Show End Sub Private Sub Command3_Click() Unload Me DK_tuxa.Show End Sub Private Sub Command4_Click() Dim X Me.FontName = "VNI-Times" X = MsgBox("Ban dang giam sat he thong Ban muon thoat chuong trinh?", vbOKCancel + vbExclamation, "Chu y!") If X = vbOK Then End End If End Sub Private Sub Form_Load() 'On Error GoTo loi Unload Baodong bang1.Enabled = False Flash.Timer1.Enabled = False Flash.Timer2.Enabled = False Flash.Timer3.Enabled = False Flash.Timer4.Enabled = False Me.Left = (Screen.Width - Me.ScaleWidth) / Me.Top = (Screen.Height - Me.ScaleHeight) / - 200 '***o dau tien ****************** - 64 - bang1.Row = bang1.Col = bang1.ColWidth(0) = 800 bang1.RowHeight(0) = 500 bang1.CellFontName = "VNI-Times" bang1.CellFontBold = True bang1.CellFontSize = 12 bang1.CellBackColor = RGB(255, 255, 0) bang1.CellForeColor = RGB(0, 0, 0) bang1.Text = "Soá TT" '***o thu 2****************** bang1.Col = bang1.ColWidth(1) = 1500 bang1.CellFontName = "VNI-Times" bang1.CellFontSize = 12 bang1.CellFontBold = True bang1.CellForeColor = RGB(0, 0, 255) bang1.CellBackColor = RGB(255, 255, 0) bang1.CellAlignment = bang1.Text = "Nhiệt Độ 1" '***o thu 3****************** bang1.Col = bang1.ColWidth(2) = 1500 bang1.CellFontName = "VNI-Times" bang1.CellFontSize = 12 bang1.CellFontBold = True bang1.CellForeColor = RGB(0, 0, 255) bang1.CellBackColor = RGB(255, 255, 0) bang1.CellAlignment = bang1.Text = "Nhiệt Độ 2" '***o thu 4****************** bang1.Col = bang1.ColWidth(3) = 2000 bang1.CellFontName = "VNI-Times" bang1.CellFontSize = 12 bang1.CellFontBold = True bang1.CellForeColor = RGB(0, 0, 255) bang1.CellBackColor = RGB(255, 255, 0) bang1.CellAlignment = bang1.Text = "Phát Hiện Khói" '***o thu 5****************** bang1.Col = bang1.ColWidth(4) = 1500 bang1.CellFontName = "VNI-Times" bang1.CellFontSize = 12 bang1.CellFontBold = True - 65 - bang1.CellForeColor = RGB(0, 0, 255) bang1.CellBackColor = RGB(255, 255, 0) bang1.CellAlignment = bang1.Text = "Ngaøy" '***o thu 6****************** bang1.Col = bang1.ColWidth(5) = 1500 bang1.CellFontName = "VNI-Times" bang1.CellFontSize = 12 bang1.CellFontBold = True bang1.CellForeColor = RGB(0, 0, 255) bang1.CellBackColor = RGB(255, 255, 0) bang1.CellAlignment = bang1.Text = "Giờ" '***o thu 7****************** bang1.Col = bang1.ColWidth(6) = 1500 bang1.CellFontName = "VNI-Times" bang1.CellFontSize = 12 bang1.CellFontBold = True bang1.CellForeColor = RGB(0, 0, 255) bang1.CellBackColor = RGB(255, 255, 0) bang1.CellAlignment = bang1.Text = "Đòa điểm" '****************************************** MSComm1.CommPort = MSComm1.Settings = "9600,n,8,1" If Not Me.MSComm1.PortOpen Then MSComm1.PortOpen = True 'PortOpen = True MSComm1.RThreshold = 'loi: 'MsgBox "Chu y! Chua nhan duoc tin hieu ", vbOKOnly, "Thong bao!" End Sub Private Sub Form_Unload(Cancel As Integer) If Me.MSComm1.PortOpen Then MSComm1.PortOpen = False 'CLOSECOM End Sub Private Sub MainMenu_Click() Main_menu.MSComm1.Output = "3" Unload Me Main_menu.Show End Sub Private Sub Mode1_Click() Unload Me Mode_1.Show End Sub - 66 - Private Sub Mode2_Click(Index As Integer) Unload Me Mode_2.Show End Sub Private Sub Image1_Click() Dim X Me.FontName = "VNI-Times" X = MsgBox("Ban dang giam sat he thong Ban muon thoat chuong trinh?", vbOKCancel + vbExclamation, "Chu y!") If X = vbOK Then End End If End Sub Private Sub Label5_Click() Unload Me Help.Show End Sub Private Sub Label7_Click() Unload Me DK_tuxa.Show End Sub Private Sub Label8_Click() Unload Me mophong.Show End Sub Private Sub MSComm1_OnComm() Dim a As Integer MSComm1.InputLen = X = Me.MSComm1.Input Text2.Text = X End Sub Private Sub SysInitial_Click() Unload Me Khoi_dong.Show End Sub Private Sub Option1_Click() Text3.Text = Option2.Value Text1.Text = Option1.Value End Sub Private Sub Option2_Click() Text3.Text = Option2.Value Text1.Text = Option1.Value End Sub Private Sub Text2_Change() Do DoEvents - 67 - '********************************************************* If Left(Text2.Text, 1) = "x" Then Dim val_nhiet1 Dim giatri As String Dim phan_du As String Dim phan_nguyen As String giatri = Mid(Text2.Text, 2, 3) val_nhiet1 = Val(giatri) phan_du = Right(giatri, 1) phan_nguyen = Left(giatri, 2) Text3_Nhiet1.Text = phan_nguyen + "." + phan_du If val_nhiet1 > 400 Then Unload Me Nhietdocao.Show End If If val_nhiet1 > 600 Then Unload Me Baodong.Show End If End If '********************************************************** If Left(Text2.Text, 1) = "y" Then Dim val_nhiet2 Dim giatri2 As String Dim phan_du2 As String Dim phan_nguyen2 As String giatri2 = Mid(Text2.Text, 2, 3) val_nhiet2 = Val(giatri2) phan_du2 = Right(giatri2, 1) phan_nguyen2 = Left(giatri2, 2) Text1_nhiet2.Text = phan_nguyen2 + "." + phan_du2 If val_nhiet2 > 400 Then Unload Me Nhietdocao.Show End If If val_nhiet2 > 600 Then Unload Me Baodong.Show End If End If '********************************************************** If Left(Text2.Text, 1) = "z" Then ' Text1_khoi.Text = Mid(Text2.Text, 2, 3) If Mid(Text2.Text, 2, 3) = "222" Then Text1_khoi.Text = "Coù" Unload Me - 68 - Baodong.Show End If If Mid(Text2.Text, 2, 3) = "111" Then Text1_khoi.Text = "Không" Else Text1_khoi.Text = "chưa nhận" End If End If '********************************************************** Loop 'Dim giatri As String 'Dim phan_du As String 'Dim phan_nguyen As String' 'giatri = Left(Text2.Text, 3) 'phan_du = Right(giatri, 1) 'phan_nguyen = Left(giatri, 2) 'Text3_Nhiet1.Text = phan_nguyen + "." + phan_du End Sub Private Sub Timer1_Timer() Label9.ForeColor = RGB(0, 0, 255) Timer1.Enabled = False Timer2.Enabled = True End Sub Private Sub Timer2_Timer() Label9.ForeColor = RGB(255, 0, 0) Timer2.Enabled = False Timer1.Enabled = True End SubPrivate Sub Timer3_Timer() Timer2.Enabled = False Timer1.Enabled = False Me.Picture1.Visible = False Timer4.Enabled = True End Sub Private Sub Timer4_Timer() bang1.Enabled = True '*********************************************** Dim stt As Byte For stt = To 19 bang1.Col = bang1.Row = stt bang1.RowHeight(stt) = 400 bang1.CellFontName = "VNI-Times" bang1.CellFontSize = 12 bang1.CellFontBold = True bang1.CellForeColor = RGB(0, 0, 255) bang1.CellBackColor = RGB(255, 255, 0) - 69 - bang1.CellAlignment = bang1.Text = stt Next stt '************************************************ Dim ndo As Byte For ndo = To 19 bang1.Col = bang1.Row = ndo bang1.RowHeight(ndo) = 400 bang1.CellFontName = "VNI-Times" bang1.CellFontSize = 12 bang1.CellFontBold = True bang1.CellForeColor = RGB(0, 0, 255) 'bang1.CellBackColor = RGB(255, 255, 0) bang1.CellAlignment = bang1.Text = Text3_Nhiet1.Text + " độ C" Next ndo '************************************************ Dim ndo2 As Byte For ndo2 = To 19 bang1.Col = bang1.Row = ndo2 bang1.RowHeight(ndo2) = 400 bang1.CellFontName = "VNI-Times" bang1.CellFontSize = 12 bang1.CellFontBold = True bang1.CellForeColor = RGB(0, 0, 255) 'bang1.CellBackColor = RGB(255, 255, 0) bang1.CellAlignment = bang1.Text = Text1_nhiet2.Text + " độ C" Next ndo2 '************************************************ Dim khoi As Byte Dim phat_hien_khoi As Boolean For khoi = To 19 bang1.Col = bang1.Row = khoi bang1.RowHeight(khoi) = 400 bang1.CellFontName = "VNI-Times" bang1.CellFontSize = 12 bang1.CellFontBold = True bang1.CellForeColor = RGB(0, 0, 255) 'bang1.CellBackColor = RGB(255, 255, 0) bang1.CellAlignment = bang1.Text = Text1_khoi.Text Next khoi - 70 - '************************************************ Dim As Byte For = To 19 bang1.Col = bang1.Row = bang1.RowHeight(ngay) = 400 bang1.CellFontName = "VNI-Times" bang1.CellFontSize = 12 bang1.CellFontBold = True bang1.CellForeColor = RGB(0, 0, 255) 'bang1.CellBackColor = RGB(255, 255, 0) bang1.CellAlignment = If phat_hien_khoi = Then bang1.Text = "Phát khói!" Else bang1.Text = Date End If Next '************************************************ Dim gio As Byte For gio = To 19 bang1.Col = bang1.Row = gio bang1.RowHeight(gio) = 400 bang1.CellFontName = "VNI-Times" bang1.CellFontSize = 12 bang1.CellFontBold = True bang1.CellForeColor = RGB(0, 0, 255) 'bang1.CellBackColor = RGB(255, 255, 0) bang1.CellAlignment = If phat_hien_khoi = Then bang1.Text = "Phát khói!" Else bang1.Text = Time End If Next gio '************************************************ Dim dd As Byte For dd = To 19 bang1.Col = bang1.Row = dd bang1.RowHeight(dd) = 400 bang1.CellFontName = "VNI-Times" bang1.CellFontSize = 12 bang1.CellFontBold = True bang1.CellForeColor = RGB(0, 0, 255) - 71 - 'bang1.CellBackColor = RGB(255, 255, 0) bang1.CellAlignment = bang1.Text = "Kho chứa 1" Next dd End Sub ... hệ thống điều khiển không dây báo cháy từ xa cho kho chứa nông sản Chương -3- TRA CỨU TÀI LIỆU 2.1 Các hệ thống báo cháy: 2.1.1 Hệ thống báo cháy quy ước: - Hệ thống báo cháy qui ước, nhiều... SÁCH BÁO PHỤC VỤ ĐỀ TÀI 2.1 Các hệ thống báo cháy 2.1.1 Hệ thống báo cháy quy ước 2.1.2 Hệ thống báo cháy địa 2.2 Tra cứu hệ thống điều khiển không dây 2.2.1 Điều khiển từ. .. ĐÀO TẠO TRƯỜNG ĐẠI HỌC NÔNG LÂM TP HỒ CHÍ MINH KHOA CƠ KHÍ & CƠNG NGHỆ  THIẾT KẾ HỆ THỐNG ĐIỀU KHIỂN KHÔNG DÂY BÁO CHÁY TỪ XA CHO KHO CHỨA NÔNG SẢN Chuyên ngành: Điều Khiển Tự Động Giáo viên

Ngày đăng: 15/06/2018, 12:43

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w