Mô phỏng và hiển thị mục tiêu radar trên màn hình PC

I)Nội dung: Mô phỏng và hiển thị mục tiêu radar trên màn hình PC. II)Yêu cầu : Chương trình mô phỏng radar sơ cấp xung ,chủ động ,quét không gian vòng tròn dùng cho cảnh giới . Các chỉ tiêu kỹ thuật: +Cự ly làm việc của đài radar :Dmax,Dmin. +Tần số sóng mang. +Công suất bức xạ. +Đặc điểm xung:độ rộng xung,chu kỳ xung. +Độ nhạy máy thu. -Chương trình có các tính năng cụ thể sau: +Hiển thị 6 mục tiêu cùng một lúc,quét mục tiêu nào thì mục tiêu đó mới sáng ,để lại dấu vết quỹ đ

doc35 trang | Chia sẻ: huyen82 | Lượt xem: 1893 | Lượt tải: 3download
Tóm tắt tài liệu Mô phỏng và hiển thị mục tiêu radar trên màn hình PC, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
ạo. +Quét cánh sóng nhanh chậm .Quét cùng chiều ,ngược chiều kim đồng hồ. +Tự động bám sát mục tiêu theo góc phương vị. +Hiển thị bảng cácthông số của các mục tiêu : *)Cự ly mục tiêu. *)Góc phương vị. *)Độ cao của mục tiêu. *)Vận tốc. +Hiển thị các thông số kỹ thuật của Radar +Màn hình khởi động +Màn hình thông số quét + Màn hình dữ liệu của radar +Hiển thị 4màn hình : *)Trang màn hình hiển thị nhìn vòng. *)Trang màn hình hiển thị cự ly D theo cách quét tia điện tử trên màn hình nhìn thẳng. *)Trang màn hình hiển thị cự ly D theo cách quét tia điện tử trên màn hình vòng tròn. *)Trang màn hình hiển thị cự ly D theo cách quét tia điện tử trên màn hình xoắn ốc. +Có chế độ điều khiển bằng tay hay tự động (VD:10s thay đổi trang màn hình 1 lần). +Độ chính xác thay đổi theo trang màn hình. III) Chương trình mô phỏng radar: --Chương trình mô phỏng radar viết bằng ngôn ngữ Visual Basic 6.0. IV/ Code chương trình Dim t As Integer Public i As Integer Public j As Integer Public xoan As Integer Public Lang As Integer Const pi = 3.14 Public huong As Integer Public muctieu As Integer Public ppquet As Integer Public z1 As Double Public z2 As Double Public z3 As Double Public z4 As Double Public z5 As Double Public z6 As Double Public somt1 As Double 'So muc tieu Public somt2 As Double Public somt3 As Double Public somt4 As Double Public somt5 As Double Public somt6 As Double Public Rmax As Double 'Ban kinh radar Public kc1 As Double 'Quan li khoang cach muc tieu va tia quet Public kc2 As Double Public kc3 As Double Public kc4 As Double Public kc5 As Double Public kc6 As Double Public k1 As Integer ' quan li thuoc tho Public k3 As Integer Public k4 As Integer Public k5 As Integer Public k6 As Integer Public k1tinh As Integer 'Quan li thuoc tho Public k2tinh As Integer Public k3tinh As Integer Public k4tinh As Integer Public k5tinh As Integer Public k6tinh As Integer Public delta1 As Integer 'Quan li goc giua muc tieu va thanh quet Public quet1 As Integer ' quan li chieu quet Public quet2 As Integer Public quet3 As Integer Public quet4 As Integer Public quet5 As Integer Public quet6 As Integer 'Quan li goc giua MT va tia quet Public delta2 As Integer Public delta3 As Integer Public delta4 As Integer Public delta5 As Integer Public delta6 As Integer 'Qaun li hien thi muc tieu len thuoc tron Public T1 As Integer Public T2 As Integer Public T3 As Integer Public T4 As Integer Public T5 As Integer Public T6 As Integer Public T1tinh As Integer Public T2tinh As Integer Public T3tinh As Integer Public T4tinh As Integer Public T5tinh As Integer Public T6tinh As Integer 'Quan li MT hien thi tren thuoc nhieu vong tron Public Mu1tinh As Integer Public Mu2tinh As Integer Public Mu3tinh As Integer Public Mu4tinh As Integer Public Mu5tinh As Integer Public Mu6tinh As Integer Private Sub Circl_Click() ppquet = 2 End Sub Private Sub Direct_Click() ppquet = 1 End Sub Private Sub Display_Click() If Lang = 0 Then If Display.Caption = "Tiếp tục" Then Timer1.Enabled = True Display.Caption = "Dừng" Else Display.Caption = "Tiếp tục" Timer1.Enabled = False End If End If If Lang = 1 Then If Display.Caption = "Continue" Then Timer1.Enabled = True Display.Caption = "Pause" Else Display.Caption = "Continue" Timer1.Enabled = False End If End If End Sub Private Sub Exit1_Click() End End Sub Private Sub English_Click() English1 Lang = 1 End Sub Private Sub FileExit_Click() End End Sub Private Sub FileNew_Click() Form2.Show End Sub Private Sub FileOpen_Click() 'On Error GoTo DialogError With CommonDialog1 ' CancelError = True .Filter = "Executables (*.exe)|*.exe|Com Files (*.frm)|*.frm|Batch Files (*.vpb)|*.vpb" .FilterIndex = 1 .DialogTitle = "Select a program to open" .ShowOpen 'MsgBox "You selected " & .FileName End With End Sub Private Sub Form_Load() Thuan.Value = True tatca.Value = True t = 0 i = 0 'Quan li tia quet j = 0 'Quan li goc quet Lang = 0 somt1 = 0 somt2 = 0 somt3 = 0 somt4 = 0 somt5 = 0 somt6 = 0 ' Cac tham so de quan li muc tieu tren cac loai thuoc thangtinh.Visible = False thangtho.Visible = False M2tho.Visible = False M2tinh.Visible = False M3tinh.Visible = False M3tho.Visible = False M4tho.Visible = False M4tinh.Visible = False M5tho.Visible = False M5tinh.Visible = False M6tho.Visible = False M6tinh.Visible = False Mu1.Visible = False Mu2.Visible = False Mu3.Visible = False Mu4.Visible = False Mu5.Visible = False Mu6.Visible = False End Sub Private Sub HelpMe_Click() MsgBox " Nguyem Khac Tinh Lpo DT7-K46 Khoa Dien Tu Vien Thong ", vbOKOnly, "About Me" End Sub Private Sub HelpPro_Click() MsgBox " Bai tap lon mon hoc Dinh Vi Dan Duong ", vbOKOnly, "About Pro" End Sub Private Sub Muctieu1_Click() muctieu = 1 End Sub Private Sub Muctieu2_Click() muctieu = 2 End Sub Private Sub Muctieu3_Click() muctieu = 3 End Sub Private Sub Muctieu4_Click() muctieu = 4 End Sub Private Sub Muctieu5_Click() muctieu = 5 End Sub Private Sub Muctieu6_Click() muctieu = 6 End Sub Private Sub MulCircle_Click() ppquet = 3 End Sub Private Sub Nguoc_Click() huong = 1 End Sub Private Sub Option4_Click() ppquet = 4 End Sub Private Sub Setting_Click() Form2.Show End Sub Private Sub tatca_Click() muctieu = 0 End Sub Private Sub Thuan_Click() huong = 0 End Sub Private Sub Timer1_Timer() '////////////////////////// For xoan = 0 To 1080 Form1.Line (8800 + xoan * Cos(pi * xoan / 180), 2700 + xoan * Sin(pi * xoan / 180))-(8800 + (xoan + 1) * Cos(pi * (xoan + 1) / 180), 2700 + (xoan + 1) * Sin((xoan + 1) * pi / 180)) Next '///////////////////////////////// Label100.Caption = Time Ngay.Caption = Date Rmax = 20 Label19.Caption = Rmax Dthmax.Caption = Rmax Dthmin.Caption = Rmax / 10 'Somuctieu.Caption = somt1 + somt2 + somt3 + somt4 + somt5 + somt6 Dim gocpv1 As Double 'Hien thi MT len man hinh radar MT1 MT2 MT3 MT4 MT5 MT6 'chuong trinh tinh goc lech de quet theo muc tieu delta1 = gocpv(M1.Left, M1.Top) - gocpv(Stic.x2, Stic.y2) delta2 = gocpv(M2.Left, M2.Top) - gocpv(Stic.x2, Stic.y2) delta3 = gocpv(M3.Left, M3.Top) - gocpv(Stic.x2, Stic.y2) delta4 = gocpv(M4.Left, M4.Top) - gocpv(Stic.x2, Stic.y2) delta5 = gocpv(M5.Left, M5.Top) - gocpv(Stic.x2, Stic.y2) delta6 = gocpv(M6.Left, M6.Top) - gocpv(Stic.x2, Stic.y2) If muctieu = 0 Then tiaquet ' Hienthi du lieu len cac Edit Display1 Display2 Display3 Display4 Display5 Display6 'Hien thi MT len thuoc 'Quet thang If ppquet = 1 Then Quetthang TM1 TM2 TM3 TM4 TM5 TM6 End If 'NEU LA QUET TRON If ppquet = 2 Then Quettron TrMT1 TrMT2 TrMT3 TrMT4 TrMT5 TrMT6 End If 'neu la qet nhieu vong If ppquet = 3 Then Quetnhieu MulMT1 MulMT2 MulMT3 MulMT4 MulMT5 MulMT6 End If If ppquet = 4 Then Form1.Frame5.Visible = False End If End If '/////////////////////////////////////////////// If muctieu = 1 Then Display1 UnDisplay2 UnDisplay3 UnDisplay4 UnDisplay5 UnDisplay6 'Chon phuong phap quet If ppquet = 1 Then Quetthang TM1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM3 UnTM4 UnTM5 UnTM6 End If 'NEU LA QUET TRON If ppquet = 2 Then Quettron TrMT1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM3 UnTM4 UnTM5 UnTM6 End If If ppquet = 3 Then Quetnhieu MulMT1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM3 UnTM4 UnTM5 UnTM6 End If If ppquet = 4 Then Form1.Frame5.Visible = False End If 'Chuong trinh bam muc tieu delta1 = gocpv(M1.Left, M1.Top) - gocpv(Stic.x2, Stic.y2) If (delta1 >= 6) Then quetthuan quet1 = 1 End If If (delta1 <= -6) Then quetnguoc quet1 = 2 End If If (-6 < delta1) And (delta1 < 6) Then If quet1 = 1 Then quetthuan quet1 = 1 End If If quet1 = 2 Then quetnguoc quet1 = 2 End If End If If z1 > 1500 Then tatca.Value = True Muctieu1.Value = False End If If t > 360 Then t = 0 End If 'Label16.Caption = delta1 End If '////////////////////////////////////////////////////// If muctieu = 2 Then UnDisplay1 Display2 UnDisplay3 UnDisplay4 UnDisplay5 UnDisplay6 'Chon phuong phap quet If ppquet = 1 Then Quetthang UnTM1 TM2 ' chuong trinh hien thi muc tieu len thuoc UnTM3 UnTM4 UnTM5 UnTM6 End If 'NEU LA QUET TRON If ppquet = 2 Then Quettron TrMT2 UnTM1 ' chuong trinh hien thi muc tieu len thuoc UnTM3 UnTM4 UnTM5 UnTM6 End If If ppquet = 3 Then Quetnhieu MulMT2 UnTM1 UnTM3 UnTM4 UnTM5 UnTM6 End If If ppquet = 4 Then Form1.Frame5.Visible = False End If 'Chuong trinh bam muc tieu delta2 = gocpv(M2.Left, M2.Top) - gocpv(Stic.x2, Stic.y2) If (delta2 >= 6) Then quetthuan quet2 = 1 End If If (delta2 <= -6) Then quetnguoc quet2 = 2 End If If (-6 < delta2) And (delta2 < 6) Then If quet2 = 1 Then quetthuan quet2 = 1 End If If quet2 = 2 Then quetnguoc quet2 = 2 End If End If 'Chuong trinh kiem tra xem con trong radar If z2 > 1500 Then tatca.Value = True Muctieu2.Value = False End If If t > 360 Then t = 0 End If End If If muctieu = 3 Then UnDisplay1 UnDisplay2 Display3 UnDisplay4 UnDisplay5 UnDisplay6 'Chon phuong phap quet If ppquet = 1 Then Quetthang UnTM1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc TM3 UnTM4 UnTM5 UnTM6 End If 'NEU LA QUET TRON If ppquet = 2 Then Quettron TrMT3 UnTM1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM4 UnTM5 UnTM6 End If If ppquet = 3 Then Quetnhieu MulMT3 UnTM1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM4 UnTM5 UnTM6 End If If ppquet = 4 Then Form1.Frame5.Visible = False End If 'Chuong trinh bam muc tieu delta1 = gocpv(M3.Left, M3.Top) - gocpv(Stic.x2, Stic.y2) If (delta3 >= 6) Then quetthuan quet3 = 1 End If If (delta3 <= -6) Then quetnguoc quet3 = 2 End If If (-6 < delta3) And (delta3 < 6) Then If quet3 = 1 Then quetthuan quet3 = 1 End If If quet3 = 2 Then quetnguoc quet3 = 2 End If End If If z3 > 1500 Then tatca.Value = True Muctieu3.Value = False End If If t > 360 Then t = 0 End If End If '////////////////////////////////////////////////// If muctieu = 4 Then UnDisplay1 UnDisplay2 UnDisplay3 Display4 UnDisplay5 UnDisplay6 'Chon phuong phap quet If ppquet = 1 Then Quetthang UnTM1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM3 TM4 UnTM5 UnTM6 End If 'NEU LA QUET TRON If ppquet = 2 Then Quettron TrMT4 UnTM1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM3 UnTM5 UnTM6 End If If ppquet = 3 Then Quetnhieu MulMT4 UnTM1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM3 UnTM5 UnTM6 End If If ppquet = 4 Then Form1.Frame5.Visible = False End If 'Chuong trinh bam muc tieu delta4 = gocpv(M4.Left, M4.Top) - gocpv(Stic.x2, Stic.y2) If (delta4 >= 6) Then quetthuan quet4 = 1 End If If (delta4 <= -6) Then quetnguoc quet4 = 2 End If If (-6 < delta4) And (delta4 < 6) Then If quet4 = 1 Then quetthuan quet4 = 1 End If If quet4 = 2 Then quetnguoc quet4 = 2 End If End If If z4 > 1500 Then tatca.Value = True Muctieu4.Value = False End If If t > 360 Then t = 0 End If End If '/////////////////////////////////// If muctieu = 5 Then UnDisplay1 UnDisplay2 UnDisplay3 UnDisplay4 Display5 UnDisplay6 'Chon phuong phap quet If ppquet = 1 Then Quetthang TM1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM3 UnTM4 TM5 UnTM6 End If 'NEU LA QUET TRON If ppquet = 2 Then Quettron TrMT5 UnTM1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM3 UnTM4 UnTM6 End If If ppquet = 3 Then Quetnhieu UnTM1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM3 UnTM4 UnTM6 MulMT5 End If If ppquet = 4 Then Form1.Frame5.Visible = False End If 'Chuong trinh bam muc tieu delta5 = gocpv(M5.Left, M5.Top) - gocpv(Stic.x2, Stic.y2) If (delta5 >= 6) Then quetthuan quet5 = 1 End If If (delta5 <= -6) Then quetnguoc quet5 = 2 End If If (-6 < delta5) And (delta5 < 6) Then If quet5 = 1 Then quetthuan quet5 = 1 End If If quet5 = 2 Then quetnguoc quet5 = 2 End If End If If z5 > 1500 Then tatca.Value = True Muctieu5.Value = False End If If t > 360 Then t = 0 End If End If '//////////////////////////////////////////////// If muctieu = 6 Then UnDisplay1 UnDisplay2 UnDisplay3 UnDisplay4 UnDisplay5 Display6 'Chon phuong phap quet If ppquet = 1 Then Quetthang TM1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM3 UnTM4 UnTM5 TM6 End If 'NEU LA QUET TRON If ppquet = 2 Then Quettron UnTM1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM3 UnTM4 UnTM5 TrMT6 End If 'neu la quet nhieu vong If ppquet = 3 Then Quetnhieu UnTM1 UnTM2 ' chuong trinh hien thi muc tieu len thuoc UnTM3 UnTM4 UnTM5 MulMT6 End If If ppquet = 4 Then Form1.Frame5.Visible = False End If 'Chuong trinh bam muc tieu delta6 = gocpv(M6.Left, M6.Top) - gocpv(Stic.x2, Stic.y2) If (delta6 >= 6) Then quetthuan quet6 = 1 End If If (delta6 <= -6) Then quetnguoc quet6 = 2 End If If (-6 < delta6) And (delta6 < 6) Then If quet6 = 1 Then quetthuan quet6 = 1 End If If quet6 = 2 Then quetnguoc quet6 = 2 End If End If If z6 > 1500 Then tatca.Value = True Muctieu6.Value = False End If If t > 360 Then t = 0 End If End If i = i + 0.7 If (z1 > 1500) And (z2 > 1500) And (z3 > 1500) And (z4 > 1500) And (z5 > 1500) And (z6 > 1500) Then Stic.x1 = 1700 Stic.y1 = 1600 Stic.y2 = 120 Stic.x2 = 1700 End If End Sub Public Sub Quetthang() Khongquettron Khongquetnhieu Form1.Frame5.Visible = True Ththo.Visible = True Thtinh.Visible = True tinh0.Visible = True tinh1.Visible = True tinh2.Visible = True tinh3.Visible = True tinh4.Visible = True tinh5.Visible = True tinh6.Visible = True tinh7.Visible = True tinh8.Visible = True tinh9.Visible = True tinh10.Visible = True th0.Visible = True th1.Visible = True th2.Visible = True th3.Visible = True th4.Visible = True th5.Visible = True th6.Visible = True th7.Visible = True th8.Visible = True th9.Visible = True th10.Visible = True Dthmax.Visible = True Dthmin.Visible = True End Sub Public Sub Khongquetthang() Ththo.Visible = False Thtinh.Visible = False tinh0.Visible = False tinh1.Visible = False tinh2.Visible = False tinh3.Visible = False tinh4.Visible = False tinh5.Visible = False tinh6.Visible = False tinh7.Visible = False tinh8.Visible = False tinh9.Visible = False tinh10.Visible = False th0.Visible = False th1.Visible = False th2.Visible = False th3.Visible = False th4.Visible = False th5.Visible = False th6.Visible = False th7.Visible = False th8.Visible = False th9.Visible = False th10.Visible = False 'Dthmax.Visible = False Dthmin.Visible = False End Sub Public Sub Khongquettron() trontinh.Visible = False Trontho1.Visible = False Trontho2.Visible = False Trontho3.Visible = False trontho4.Visible = False Nhieutinh1.Visible = False Nhieutinh2.Visible = False Nhieutinh3.Visible = False Nhieutinh4.Visible = False mtrontho.Visible = False mnhieutinh.Visible = False End Sub Public Sub Quettron() Khongquetthang Form1.Frame5.Visible = True Khongquetnhieu Dthmax.Visible = True UnTM trontinh.Visible = True Trontho1.Visible = True Trontho2.Visible = True Trontho3.Visible = True trontho4.Visible = True Nhieutinh1.Visible = True Nhieutinh2.Visible = True Nhieutinh3.Visible = True Nhieutinh4.Visible = True mtrontho.Visible = True mnhieutinh.Visible = True End Sub Public Sub Khongquetnhieu() Multinh.Visible = False Nhieutho1.Visible = False Nhieutho2.Visible = False Nhieutho3.Visible = False Nhieutho4.Visible = False Nhieutinh1.Visible = False Nhieutinh2.Visible = False Nhieutinh3.Visible = False Nhieutinh4.Visible = False mtrontho.Visible = False mnhieutinh.Visible = False mnhieutho.Visible = False End Sub Public Sub Quetnhieu() Khongquetthang Khongquettron Form1.Frame5.Visible = True Dthmax.Visible = True Multinh.Visible = True trontinh.Visible = True Nhieutho1.Visible = True Nhieutho2.Visible = True Nhieutho3.Visible = True Nhieutho4.Visible = True Nhieutinh1.Visible = True Nhieutinh2.Visible = True Nhieutinh3.Visible = True Nhieutinh4.Visible = True Trontho1.Visible = True Trontho2.Visible = True Trontho3.Visible = True trontho4.Visible = True mtrontho.Visible = True mnhieutinh.Visible = True mnhieutho.Visible = True End Sub Public Sub MT1() z1 = Sqr((1700 - M1.Left) * (1700 - M1.Left) + (M1.Top - 1600) * (M1.Top - 1600)) M1.Width = 50 M1.Height = 50 M1.Left = 960 + 2 * i M1.Top = 2640 + 0.5 * i If z1 < 1500 Then M1.Visible = True Else M1.Visible = False End If End Sub Public Sub MT2() z2 = Sqr((1700 - M2.Left) * (1700 - M2.Left) + (M2.Top - 1600) * (M2.Top - 1600)) M2.Width = 50 M2.Height = 50 M2.Left = 240 + i M2.Top = 2640 - 2 * i If z2 < 1500 Then M2.Visible = True Else M2.Visible = False End If End Sub Public Sub MT3() z3 = Sqr((1700 - M3.Left) * (1700 - M3.Left) + (M3.Top - 1600) * (M3.Top - 1600)) M3.Width = 50 M3.Height = 50 M3.Left = 2040 + 0.5 * i M3.Top = 2280 + 0.5 * i If z3 < 1500 Then M3.Visible = True Else M3.Visible = False End If End Sub Public Sub MT4() z4 = Sqr((1700 - M4.Left) * (1700 - M4.Left) + (M4.Top - 1600) * (M4.Top - 1600)) M4.Width = 50 M4.Height = 50 M4.Left = 2880 - 0.1 * i M4.Top = 840 + 2 * i If z4 < 1500 Then M4.Visible = True Else M4.Visible = False End If End Sub Public Sub MT5() z5 = Sqr((1700 - M5.Left) * (1700 - M5.Left) + (M5.Top - 1600) * (M5.Top - 1600)) M5.Width = 50 M5.Height = 50 M5.Left = 1400 - 0.1 * i M5.Top = 960 - i If z5 < 1500 Then M5.Visible = True Else M5.Visible = False End If End Sub Public Sub MT6() z6 = Sqr((1700 - M6.Left) * (1700 - M6.Left) + (M6.Top - 1600) * (M6.Top - 1600)) M6.Width = 50 M6.Height = 50 M6.Left = 2400 - 0.5 * i M6.Top = 360 + 3 * i If z6 < 1500 Then M6.Visible = True Else M6.Visible = False End If End Sub Public Function Distance(xa As Double, ya As Double, xb As Double, yb As Double) As Double Dim kq As Double kq = Sqr((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)) Distance = kq End Function Public Function Check(x1 As Double, y1 As Double, x2 As Double, y2 As Double, x3 As Double, y3 As Double) As Double Dim cs As Double Dim sn As Double Dim a As Double Dim b As Double Dim c As Double Dim h As Double a = Distance(x1, y1, x2, y2) b = Distance(x1, y1, x3, y3) c = Distance(x2, y2, x3, y3) cs = (a * a + b * b - c * c) / (2 * a * b) sn = Sqr(1 - cs * cs) h = b * sn Check = h End Function Public Function gocpv(a1 As Double, a2 As Double) As Double Dim goc As Double If (a1 > 1700) And (a2 < 1600) Then goc = -(180 / pi) * Atn((a1 - 1700) / (a2 - 1600)) End If If (a1 > 1700) And (a2 > 1600) Then goc = 180 - (180 / pi) * Atn((a1 - 1700) / (a2 - 1600)) End If If (a1 < 1700) And (a2 < 1600) Then goc = 360 - (180 / pi) * Atn((a1 - 1700) / (a2 - 1600)) End If If (a1 1600) Then goc = 180 - (180 / pi) * Atn((a1 - 1700) / (a2 - 1600)) End If gocpv = goc End Function Public Sub TM1() If D1.Text > 0 Then k1 = 10 * D1.Text \ Rmax k1tinh = 100 * (D1.Text - Rmax * k1 / 10) \ Rmax thangtho.Visible = True thangtinh.Visible = True thangtho.Left = 200 + k1 * 280 thangtho.Top = 1250 thangtho.Width = 50 thangtho.Height = 100 thangtinh.Left = 200 + k1tinh * 280 thangtinh.Top = 1650 thangtinh.Width = 50 thangtinh.Height = 100 End If End Sub Public Sub TM2() If D2.Text > 0 Then k2 = 10 * D2.Text \ Rmax k2tinh = 100 * (D2.Text - Rmax * k2 / 10) \ Rmax M2tho.Visible = True M2tinh.Visible = True M2tho.Left = 200 + k2 * 280 M2tho.Top = 1350 M2tho.Width = 50 M2tho.Height = 50 M2tinh.Left = 200 + k2tinh * 280 M2tinh.Top = 1750 M2tinh.Width = 50 M2tinh.Height = 50 End If End Sub Public Sub TM3() If D3.Text > 0 Then k3 = 10 * D3.Text \ Rmax k3tinh = 100 * (D3.Text - Rmax * k3 / 10) \ Rmax M3tho.Visible = True M3tinh.Visible = True M3tho.Left = 200 + k3 * 280 M3tho.Top = 1350 M3tho.Width = 100 M3tho.Height = 50 M3tinh.Left = 200 + k3tinh * 280 M3tinh.Top = 1750 M3tinh.Width = 100 M3tinh.Height = 50 End If End Sub Public Sub TM4() If D4.Text > 0 Then k4 = 10 * D4.Text \ Rmax k4tinh = 100 * (D4.Text - Rmax * k4 / 10) \ Rmax M4tho.Visible = True M4tinh.Visible = True M4tho.Left = 200 + k4 * 280 M4tho.Top = 1350 M4tho.Width = 50 M4tho.Height = 50 M4tinh.Left = 200 + k4tinh * 280 M4tinh.Top = 1750 M4tinh.Width = 50 M4tinh.Height = 50 End If End Sub Public Sub TM5() If D5.Text > 0 Then k5 = 10 * D5.Text \ Rmax k5tinh = 100 * (D5.Text - Rmax * k5 / 10) \ Rmax M5tho.Visible = True M5tinh.Visible = True M5tho.Left = 200 + k5 * 280 M5tho.Top = 1350 M5tho.Width = 50 M5tho.Height = 50 M5tinh.Left = 200 + k5tinh * 280 M5tinh.Top = 1750 M5tinh.Width = 50 M5tinh.Height = 50 End If End Sub Public Sub TM6() If D6.Text > 0 Then k6 = 10 * D6.Text \ Rmax k6tinh = 100 * (D6.Text - Rmax * k6 / 10) \ Rmax M6tho.Visible = True M6tinh.Visible = True M6tho.Left = 200 + k6 * 280 M6tho.Top = 1350 M6tho.Width = 50 M6tho.Height = 50 M6tinh.Left = 200 + k6tinh * 280 M6tinh.Top = 1750 M6tinh.Width = 50 M6tinh.Height = 50 End If End Sub Public Sub UnTM1() thangtinh.Visible = False thangtho.Visible = False Mu1.Visible = False End Sub Public Sub UnTM2() M2tho.Visible = False M2tinh.Visible = False Mu2.Visible = False End Sub Public Sub UnTM3() M3tho.Visible = False M3tinh.Visible = False Mu3.Visible = False End Sub Public Sub UnTM4() M4tho.Visible = False M4tinh.Visible = False Mu4.Visible = False End Sub Public Sub UnTM5() M5tho.Visible = False M5tinh.Visible = False Mu5.Visible = False End Sub Public Sub UnTM6() M6tho.Visible = False M6tinh.Visible = False Mu6.Visible = False End Sub Public Sub UnTM() UnTM1 UnTM2 UnTM3 UnTM4 UnTM5 UnTM6 End Sub Public Sub UnDisplay1() D1.Text = 0 PV1.Text = 0 H1.Text = 0 V1.Text = 0 NG1.Text = 0 End Sub Public Sub UnDisplay2() D2.Text = 0 PV2.Text = 0 H2.Text = 0 V2.Text = 0 NG2.Text = 0 End Sub Public Sub UnDisplay3() D3.Text = 0 PV3.Text = 0 H3.Text = 0 V3.Text = 0 NG3.Text = 0 End Sub Public Sub UnDisplay4() D4.Text = 0 PV4.Text = 0 H4.Text = 0 V4.Text = 0 NG4.Text = 0 End Sub Public Sub UnDisplay5() D5.Text = 0 PV5.Text = 0 H5.Text = 0 V5.Text = 0 NG5.Text = 0 End Sub Public Sub UnDisplay6() D6.Text = 0 PV6.Text = 0 H6.Text = 0 V6.Text = 0 NG6.Text = 0 End Sub Public Sub Display1() kc1 = Check(1700, 1600, Stic.x2, Stic.y2, M1.Left, M1.Top) If (kc1 < 50) And (Abs(Stic.y2 - M1.Top) < 1700) And (z1 < 1500) Then D1.Text = z1 * Rmax / 1500 PV1.Text = gocpv(M1.Left, M1.Top) H1.Text = 14.7 + 0.5 * Sin(i) somt1 = 1 V1.Text = 10 * (14.7 + 0.5 * Sin(i)) - 0.3 * kc1 NG1.Text = (180 / pi) * Atn(H1.Text / kc1) End If If z1 > 1500 Then somt1 = 0 UnDisplay1 thangtho.Visible = False thangtinh.Visible = False Mu1.Visible = False End If End Sub Public Sub Display2() kc2 = Check(1700, 1600, Stic.x2, Stic.y2, M2.Left, M2.Top) If (kc2 < 50) And (Abs(Stic.x2 - M2.Left) < 1700) And (z2 < 1500) Then D2.Text = z2 * Rmax / 1500 PV2.Text = gocpv(M2.Left, M2.Top) H2.Text = 14.4 - 0.5 * Sin(i) V2.Text = 10 * (14.4 - 0.5 * Sin(i)) - 0.3 * kc2 somt2 = 1 NG2.Text = (180 / pi) * Atn(H2.Text / kc2) End If If z2 > 1500 Then UnDisplay2 M2tho.Visible = False M2tinh.Visible = False Mu2.Visible = False somt2 = 0 End If End Sub Public Sub Display3() kc3 = Check(1700, 1600, Stic.x2, Stic.y2, M3.Left, M3.Top) If (kc3 < 50) And (Abs(Stic.y2 - M3.Top) < 1700) And (z3 < 1500) Then D3.Text = z3 * Rmax / 1500 PV3.Text = gocpv(M3.Left, M3.Top) H3.Text = 15 + 0.5 * Sin(2 * i) somt3 = 1 V3.Text = 10 * (15 + 0.5 * Sin(2 * i)) + 0.3 * kc3 NG3.Text = (180 / pi) * Atn(H3.Text / kc3) End If If z3 > 1500 Then somt3 = 0 UnDisplay3 M3tho.Visible = False M3tinh.Visible = False Mu3.Visible = False End If End Sub Public Sub Display4() kc4 = Check(1700, 1600, Stic.x2, Stic.y2, M4.Left, M4.Top) If (kc4 < 50) And (Abs(Stic.x2 - M4.Left) < 1700) And (z4 < 1500) Then D4.Text = z4 * Rmax / 1500 PV4.Text = gocpv(M4.Left, M4.Top) H4.Text = 14.7 + 0.5 * Cos(i) somt4 = 1 V4.Text = 10 * (14.7 + 0.5 * Cos(i)) - 0.3 * kc4 NG4.Text = (180 / pi) * Atn(H4.Text / kc4) End If If z4 > 1500 Then somt4 = 0 UnDisplay4 M4tho.Visible = False M4tinh.Visible = False Mu4.Visible = False End If End Sub Public Sub Display5() kc5 = Check(1700, 1600, Stic.x2, Stic.y2, M5.Left, M5.Top) If (kc5 < 50) And (Abs(Stic.y2 - M5.Top) < 1700) And (z5 < 1500) Then D5.Text = z5 * Rmax / 1500 PV5.Text = gocpv(M5.Left, M5.Top) H5.Text = 14.7 - 0.5 * Cos(i) somt5 = 1 V5.Text = 10 * (14.7 - 0.5 * Cos(i)) - 0.3 * kc5 NG5.Text = (180 / pi) * Atn(H5.Text / kc5) End If If z5 > 1500 Then UnDisplay5 somt5 = 0 M5tho.Visible = False M5tinh.Visible = False Mu5.Visible = False End If End Sub Public Sub Display6() kc6 = Check(1700, 1600, Stic.x2, Stic.y2, M6.Left, M6.Top) goc6 = Abs(gocpv(M6.Left, M6.Top) - gocpv(Stic.x2, Stic.y2)) If (kc6 < 50) And (Abs(Stic.x2 - M6.Left) < 1700) And (Abs(Stic.y2 - M6.Top) < 1700) And (z6 < 1500) And (goc6 < 5) Then D6.Text = z6 * Rmax / 1500 'Label16.Caption = kc6 PV6.Text = gocpv(M6.Left, M6.Top) H6.Text = 14 + 0.5 * 0.2 * Sin(i) somt6 = 1 V6.Text = 10 * (14 + 0.5 * 0.2 * Sin(i)) - 0.3 * kc6 NG6.Text = (180 / pi) * Atn(H6.Text / kc6) End If If z6 > 1500 Then UnDisplay6 somt6 = 0 M6tho.Visible = False M6tinh.Visible = False Mu6.Visible = False End If End Sub Public Sub quetMT1(p As Double) Stic.x1 = 1700 Stic.y1 = 1600 Stic.x2 = 1700 + 1500 * Cos(pi * (j - 90) / 180) Stic.y2 = 1600 + 1500 * Sin(pi * (j - 90) / 180) If p > 5 Then j = j - 1 End If If p < -5 Then j = j + 1 End If End Sub Public Sub tiaquet() 'chuong trinh dieu khien thanh quet If (huong = 0) Then quetthuan End If If (huong = 1) Then quetnguoc End If If t > 360 Then t = 0 End If End Sub Public Sub quetthuan() Stic.x1 = 1700 Stic.y1 = 1600 Stic.x2 = 1700 + 1500 * Cos(pi * (t - 90) / 180) Stic.y2 = 1600 + 1500 * Sin(pi * (t - 90) / 180) t = t + 1 End Sub Public Sub quetnguoc() Stic.x1 = 1700 Stic.y1 = 1600 Stic.x2 = 1700 + 1500 * Cos(pi * (t - 90) / 180) Stic.y2 = 1600 + 1500 * Sin(pi * (t - 90) / 180) t = t - 1 End Sub 'Chuong trinh hien thi MT len thuoc tron '///////////////////////////////////////////// Public Sub TrMT1() 'Hien thi len thanh quet tron If D1.Text > 0 Then T1 = 8 * D1.Text \ Rmax T1tinh = 64 * (D1.Text - T1 * Rmax * 0.125) \ Rmax thangtho.Visible = True thangtinh.Visible = True thangtho.Left = 1600 + 1400 * Cos(45 * (T1 - 2) * pi / 180) thangtho.Top = 1600 + 1400 * Sin(45 * (T1 - 2) * pi / 180) thangtho.Width = 50 thangtho.Height = 50 thangtinh.Left = 1600 + 630 * Cos(45 * (T1tinh - 2) * pi / 180) thangtinh.Top = 1600 + 630 * Sin(45 * (T1tinh - 2) * pi / 180) thangtinh.Width = 50 thangtinh.Height = 50 End If End Sub Public Sub TrMT2() 'Hien thi len thanh quet tron If D2.Text > 0 Then T2 = 8 * D2.Text \ Rmax T2tinh = 64 * (D2.Text - T2 * Rmax * 0.125) \ Rmax M2tho.Visible = True M2tinh.Visible = True M2tho.Left = 1600 + 1400 * Cos(45 * (T2 - 2) * pi / 180) M2tho.Top = 1600 + 1400 * Sin(45 * (T2 - 2) * pi / 180) M2tho.Width = 50 M2tho.Height = 50 M2tinh.Left = 1600 + 630 * Cos(45 * (T2tinh - 2) * pi / 180) M2tinh.Top = 1600 + 630 * Sin(45 * (T2tinh - 2) * pi / 180) M2tinh.Width = 50 M2tinh.Height = 50 End If End Sub Public Sub TrMT3() 'Hien thi len thanh quet tron If D3.Text > 0 Then T3 = 8 * D3.Text \ Rmax 'Label16.Caption = T3tinh T3tinh = 64 * (D3.Text - T3 * Rmax * 0.125) \ Rmax 'Label16.Caption = T3tinh M3tho.Visible = True M3tinh.Visible = True M3tho.Left = 1600 + 1400 * Cos(45 * (T3 - 2) * pi / 180) M3tho.Top = 1600 + 1400 * Sin(45 * (T3 - 2) * pi / 180) M3tho.Width = 50 M3tho.Height = 50 M3tinh.Left = 1600 + 630 * Cos(45 * (T3tinh - 2) * pi / 180) M3tinh.Top = 1600 + 630 * Sin(45 * (T3tinh - 2) * pi / 180) M3tinh.Width = 50 M3tinh.Height = 50 End If End Sub Public Sub TrMT4() 'Hien thi len thanh quet tron If D4.Text > 0 Then T4 = 8 * D4.Text \ Rmax T4tinh = 64 * (D4.Text - T4 * Rmax * 0.125) \ Rmax M4tho.Visible = True M4tinh.Visible = True M4tho.Left = 1600 + 1400 * Cos(45 * (T4 - 2) * pi / 180) M4tho.Top = 1600 + 1400 * Sin(45 * (T4 - 2) * pi / 180) M4tho.Width = 50 M4tho.Height = 50 M4tinh.Left = 1600 + 630 * Cos(45 * (T4tinh - 2) * pi / 180) M4tinh.Top = 1600 + 630 * Sin(45 * (T4tinh - 2) * pi / 180) M4tinh.Width = 50 M4tinh.Height = 50 End If End Sub Public Sub TrMT5() 'Hien thi len thanh quet tron If D5.Text > 0 Then T5 = 8 * D5.Text \ Rmax T5tinh = 64 * (D5.Text - T5 * Rmax * 0.125) \ Rmax 'Label16.Caption = T5tinh - 2 M5tho.Visible = True M5tinh.Visible = True M5tho.Left = 1600 + 1400 * Cos(45 * (T5 - 2) * pi / 180) M5tho.Top = 1600 + 1400 * Sin(45 * (T5 - 2) * pi / 180) M5tho.Width = 50 M5tho.Height = 50 M5tinh.Left = 1600 + 630 * Cos(45 * (T5tinh - 2) * pi / 180) M5tinh.Top = 1600 + 630 * Sin(45 * (T5tinh - 2) * pi / 180) M5tinh.Width = 50 M5tinh.Height = 50 End If End Sub Public Sub TrMT6() 'Hien thi len thanh quet tron If D6.Text > 0 Then T6 = 8 * D6.._.

Các file đính kèm theo tài liệu này:

  • docBK0045.DOC
Tài liệu liên quan