72
1 บบบบบ 1 บบบบบ 1.1.บบบบบบบบบบบบบบบบ บบบบบบบบบบบบบบบบบ บบบบบบ จจจจจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจ-จจจจจจจจจจจจจจจจจจจจ จ จจจ จจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจ4 input /4 output board for PC Interface hardware. จจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจ-จจจ จจจจ จจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจ-จจจ จจจ จจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจ 1.2.บบบบบบบบบบบบ

โครงการ tee. ok

Embed Size (px)

Citation preview

1 1 1.1. - 4 input /4 output board for PC Interface hardware. - - 1.2.1. - 22. 3. 1.3. 1. 2. , 1.4. 1 1.5. 1. 2. 1.6. 3 1.6.1 4 input /4 output board for PC Interface hardware 4 4 2 2.1.2.1. Visual Basic (VB)Visual Basic (VB)4 Visual Basic (VB) Visual Basic (VB) Visual Basic Visual Basic (Controls) (Controls) Graphic User Interface (GUI) Graphic User Interface (GUI) Event - Driven Programming Event - Driven Programming (Event) (Event) Visual Basic Visual Basic Form TextBox Label Form TextBox Label (Object (Object ) ) Visual Basic Visual Basic (properties) (properties) (Methods) (Methods) Visual Basic Visual Basic (procedure)(procedure) 5 (Object Oriented(Object Oriented Programming-OOP) Programming-OOP) Visual Basic Visual Basic OOP OOP Visual Basic Visual Basic Visual BasicVisual Basic Visual Basic Standard EXE Standard EXE Visual BasicVisual Basic 2.1 Visual Basic6 2.2 2.2 Visual BasicVisual Basic Visual Basic Visual Basic (Toolbars) (Toolbars) Visual Basic Visual Basic 7 2.3 2.3 (Toolbars)(Toolbars) Visual BasicVisual Basic 4 4 1. Standard Toolbars 1. Standard Toolbars Project 2.Project 2. Edit Toolbars Edit Toolbars code editor 3. Debugcode editor 3. Debug Toolbars Toolbars 4. Form Editor Toolbars4. Form Editor Toolbars , , , , Toolboxs Toolboxs Controls Controls 2 2 8 2.4 2.4 Controls Controls 1. 1. (Intrinsic controls) (Intrinsic controls) Visual Basic Visual Basic Form Form 2. 2. ActiveX (ActiveX controls) ActiveX (ActiveX controls) Form Designer Form Designer 9 Visual Basic Visual Basic Project Project 11 2.5 Form Designer2.5 Form Designer Project ExplorerProject Explorer (tree-view)(tree-view) 22 10 2.6 Project Explorer 2.6 Project Explorer Properties WindowProperties Window (adtive) (adtive) (focus) (focus) 2.7 2.7 Alphabetic Alphabetic CategorizedCategorized11 2 2 1. 1. Alphabetic Alphabetic 2. 2. Categorized Categorized Form LayoutForm Layout drag drag 2.8 2.8 Form LayoutForm Layout Immediate WindowImmediate Window 12 2.9 Immediate Window2.9 Immediate Window New Project New Project New Project New Project File/New Project File/New Project Visual Basic Visual Basic 2.10 2.10 New ProjectNew Project13 Code EditorCode Editor 2.112.11 Code EditorCode Editor 2.2 2.2 4 input /4 output board for PC Interface hardware 14 2.12 2.12 4 input /4 output board for PC Interface hardware 2.13 4 input /4 output board for PC Interface hardware 152.3. IC SN74LS240 SN74LS244 IC ULN2803 ULN2804 2.14 IC SN74LS240 SN74LS244 IC ULN2803 ULN280416171819202122232.4 ET-BASE PIC 16F28 V1 2.15 ET-BASE PIC16F628 V124 252627 2.16 (Hex File)282930 2.17 PIC16F628V131 2.5 ET USB/RS232 MINI 2.18 ET USB/RS232 MINI2.6 Serial Port( RS232)32 RS-232 ( RS-232), , , , , RS-232 PC 3 - TX- RX- GND RS-232C 50 , , 33 2.19 PC DB9 (Male) 2.20 DB9 (Female) - DB9 2.21 DB9 Null modem 2.22 DB9 3 DB9 TXD RXD DTR 34 , DSR DTR ON DSR RTS ,CTS RTS ON TXD OFF CTS GND ground- RS232 2.23 RS232C TTL 35 "1" -3V -15V "0" +3V +15V RS232 +15V -15V RS232 TTL - (Baud rate) - 300, 1,200, 2,400, 4,800 , 9,600 ,14,400 ,19,200, 38,400 ,56,000 , ,- 2 (Synchronous) (Asynchronous) - (Synchronous) 36 2.24 (Synchronous) - (Asynchronous)1 (Start bit) 1 2 (Data) 5,6,7 8 3 (Parity bit) 1 4 (Stop bit) 1, 1.5, 2 2.25 (Asynchronous) data "1" (Waiting stage) data "0" 1 (Start bit) (LSB) 37 ( ) "1" 1 ( 1, 1.5, 2 ) 33 383.1. 3.1. 2 2 Visual Basic Visual Basic 3.2.3.2. Visual Basic 6.0 Visual Basic 6.0 1. Drive Drive CD-ROM CD-ROM Next Next 3.1 3.1 Drive Drive CD-ROMCD-ROM39 3.2 3.2 Microsoft VisualMicrosoft Visual Studio 6.0Studio 6.0 2. 2. I accept the agreement I accept the agreement NextNext40 3.3 3.3 3. 3. Products ID , Products ID , , , Next Next . . 41 3.4 3.4 Products ID , Products ID , , , 4. 4. Install Visual Studio 6.0 Professional Edition Install Visual Studio 6.0 Professional Edition NextNext 3.5 3.5 Install Visual Studio 6.0 ProfessionalInstall Visual Studio 6.0 Professional EditionEdition 5. 5. Drive Drive Browse Browse Drive Drive Next Next 42 3.6 3.6 Drive Drive 6. 6. .. 3.7 3.7 43 7. 7. Continue Continue 3.8 3.8 8. 8. Components Components 3.8 3.8 ComponentsComponents9. 9. Custom Custom 44 3.9 3.9 Custom Custom 10. 10. Microsoft Visual Basic 6.0Microsoft Visual Basic 6.0 MicrosoftMicrosoft Visual Basic 6.0 Visual Basic 6.0 ..45 3.10 3.10 Microsoft Visual Basic 6.0 CustomMicrosoft Visual Basic 6.0 Custom 11. 11. OK OK 3.11 3.11 12. 12. . . 3.12 3.12 13. 13. 46 3.13 3.13 14. 14. Restart Windows Restart Windows Restart Restart 3.14 3.14 Restart Windows Restart Windows 473.3 .3.3 . 4 input /4 output board for PC4 input /4 output board for PC Interface hardware.Interface hardware. Visual Basic Visual Basic (Floew Chart ) (Floew Chart ) 48o aO.m- q o ro _ao_qmm-ccaacwm.aOqmm-ccr mmoaaaamdoOm.qaqmOa' qmamdoO o r ooooo-occoooeer mm oOcdaasd cg=eeoooo ams0qaOaaoO-mam- m0 =oocco visual basicg=eeooccon g=eeoooooceooccooen g=eeoaOo.qr r o' oonocc=oo=0cg-gognn o-sqqnn o-sqqn sgn sgn sgn sgoceoooceoooceoooceoonn o-sqqnn o-sqqnn o-sqqnn o-sqq 3.15 3.15 493.4.3.4. 50 3.1 3.1 11223344112233441122334411223344112233441.1. 2.2. 3.3. 4.4. 5.5. 6.6. 7.7. 513.5 3.5 3.15 3.15 4 input /4 output board for PC Interface hardware 52 3.15 4 input /4 output board for PC Interface hardware 53 3.1 ET-BASE PIC16F628 V1 3.16 3.17 3.18 54 3.19 3.20 3.21 55 3.22 3.24 3.6 4 input /4 output board for PC Interface hardware 56 3.24 3.6.1 3.6.1 Private Declare Function Inp Lib "DllPort.dll" Alias "Inp32" (ByVal PortAddress As Integer) As IntegerPrivate Declare Sub Out Lib "DllPort.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)Public f As IntegerPublic b As IntegerDim c As IntegerDim d As IntegerDim e As IntegerDim inbit1 As ByteDim counter1 As IntegerDim counter2 As Integer57Dim counter3 As IntegerDim counter4 As IntegerDim portdataDim bit1 As ByteDim bit2 As ByteDim bit3 As ByteDim bit4 As ByteDim A As IntegerPrivate Sub Command10_Click()counter2 = 0Label8.Caption = 0End SubPrivate Sub Command11_Click()counter3 = 0Label9.Caption = 0End SubPrivate Sub Command12_Click()counter4 = 0Label10.Caption = 0End SubPrivate Sub Command13_Click()If MSComm1.PortOpen = True ThenMSComm1.PortOpen = FalseEnd IfUnload Me58End SubPrivate Sub Command9_Click()counter1 = 0Label7.Caption = 0End SubPrivate Sub connect_Click()MSComm1.CommPort = Combo1.TextIf MSComm1.PortOpen = False ThenMSComm1.PortOpen = TrueEnd IfFrame1.Visible = TrueFrame2.Visible = TrueEnd SubPrivate Sub Form_Load() A = &H378 f = &H379b = 0c = 0d = 0e = 0Dim thisyear As Integer, thismonth As Integer, thisday As IntegerDim olddate As StringDim thisHour As Integer, thisMinute As Integer, thisSecond As IntegerDim oldTime As Stringolddate = Date$59oldTime = Time$Label11.Caption = Date$Label12.Caption = Time$MSComm1.Settings = "9600,N,8,1"MSComm1.InputLen = 1MSComm1.RThreshold = 1Combo1.AddItem ("1")Combo1.AddItem ("2")Combo1.AddItem ("3")Combo1.AddItem ("4")Combo1.AddItem ("5")Combo1.AddItem ("6")Combo1.AddItem ("7")Combo1.AddItem ("8")Combo1.AddItem ("9")Combo1.AddItem ("10")Combo1.AddItem ("11")Combo1.AddItem ("12")Combo1.AddItem ("13")Combo1.AddItem ("14")Combo1.AddItem ("15")Combo1.AddItem ("16")Combo1.AddItem ("17")Combo1.AddItem ("18")Combo1.AddItem ("19")Combo1.AddItem ("20")Combo1.AddItem ("21")60Command2.Enabled = FalseCommand4.Enabled = FalseCommand6.Enabled = FalseCommand8.Enabled = FalseEnd SubPrivate Sub Form_Unload(Cancel As Integer)If MSComm1.PortOpen = True ThenMSComm1.PortOpen = FalseEnd IfUnload MeEnd SubPrivate Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)bit1 = 0bit2 = 0biy3 = 0bit4 = 0End SubPrivate Sub Command1_Click()Label3.Caption = "ON"Label3.BackColor = &HFF61bit1 = 1MSComm1.Output = Hex(bit1 Or bit2 Or bit3 Or bit4)Command1.Enabled = FalseCommand2.Enabled = TrueEnd SubPrivate Sub Command2_Click()Label3.Caption = "OFF"Label3.BackColor = &H8000000Fbit1 = 0Command1.Enabled = TrueCommand2.Enabled = FalseMSComm1.Output = Hex(bit1 Or bit2 Or bit3 Or bit4) End SubPrivate Sub Command3_Click()Label4.Caption = "ON"Label4.BackColor = &HFFbit2 = 2MSComm1.Output = Hex(bit1 Or bit2 Or bit3 Or bit4)Command3.Enabled = FalseCommand4.Enabled = TrueEnd SubPrivate Sub Command4_Click()Label4.Caption = "OFF"62Label4.BackColor = &H8000000Fbit2 = 0MSComm1.Output = Hex(bit1 Or bit2 Or bit3 Or bit4) Command3.Enabled = TrueCommand4.Enabled = FalseEnd SubPrivate Sub Command5_Click()Label5.Caption = "ON"Label5.BackColor = &HFFbit3 = 4MSComm1.Output = Hex(bit1 Or bit2 Or bit3 Or bit4)Command5.Enabled = FalseCommand6.Enabled = TrueEnd SubPrivate Sub Command6_Click()Label5.Caption = "OFF"Label5.BackColor = &H8000000Fbit3 = 0MSComm1.Output = Hex(bit1 Or bit2 Or bit3 Or bit4) Command5.Enabled = TrueCommand6.Enabled = FalseEnd Sub63Private Sub Command7_Click()bit4 = 8MSComm1.Output = Hex(bit1 Or bit2 Or bit3 Or bit4)Label6.Caption = "ON"Label6.BackColor = &HFFCommand7.Enabled = FalseCommand8.Enabled = TrueEnd SubPrivate Sub Command8_Click()Label6.Caption = "OFF"Label6.BackColor = &H8000000Fbit4 = 0MSComm1.Output = Hex(bit1 Or bit2 Or bit3 Or bit4) Command7.Enabled = TrueCommand8.Enabled = False End SubPrivate Sub Frame2_DragDrop(Source As Control, X As Single, Y As Single)A = &H379b = 0c = 0d = 0e = 0End SubPrivate Sub Text1_Change()64End SubPrivate Sub MSComm1_OnComm()inbit1 = MSComm1.InputIf (inbit1 And &H40) = 0 And b = 0 Thenb = 1c = 0d = 0e = 0counter1 = counter1 + 1Label7.Caption = counter1ElseIf (inbit1 And &H80) = &H80 And c = 0 Thenc = 1b = 0d = 0e = 0counter2 = counter2 + 1Label8.Caption = counter2ElseIf (inbit1 And &H20) = 0 And d = 0 Thenb = 0c = 0d = 1e = 0counter3 = counter3 + 1Label9.Caption = counter3ElseIf (inbit1 And &H10) = 0 And e = 0 Then65b = 0c = 0d = 0e = 1counter4 = counter4 + 1Label10.Caption = counter4ElseIf inbit1 = &H7F Thenb = 0c = 0d = 0e = 0ElseEnd IfEnd SubPrivate Sub Timer1_Timer()'inbit1 = Inp(f)'If (inbit1 And &H40) = 0 And b = 0 Then'b = 1'c = 0'd = 0'e = 0'counter1 = counter1 + 1'Label7.Caption = counter1'ElseIf (inbit1 And &H80) = &H80 And c = 0 Then'c = 166'b = 0'd = 0'e = 0'counter2 = counter2 + 1'Label8.Caption = counter2'ElseIf (inbit1 And &H20) = 0 And d = 0 Then'b = 0'c = 0'd = 1'e = 0'counter3 = counter3 + 1'Label9.Caption = counter3'ElseIf (inbit1 And &H10) = 0 And e = 0 Then'b = 0'c = 0'd = 0'e = 1'counter4 = counter4 + 1'Label10.Caption = counter4'ElseIf inbit1 = &H7F Then'b = 0'c = 0'd = 0'e = 0'Else'End If67End Sub 44 3 3 4.1.4.1. 6 6 684.2.4.2. 4.3.4.3. XP XP 4.4.4.4. TestTest 4.5.4.5. 66 6 6 Windows xp Windows xp 69 Setup Setup 70 55 5.1.5.1. 11 5.2.5.2. 71 1.1. 2. 2. 3.3. 4.4. 5.3.5.3. 1.1. 5.4 5.4 1.1. 2. 2. thaiio.com thaiio.com 72