ဒါက Form Code မွာကူးထဲ့
Private Sub send_Click()
PortAddress = Val(&H37F)
Out PortAddress, Val(Text1.Text)
End Sub
Private Sub start_click()
Dim speed As Double
Dim fre As Double
Text1.Text = "0"
Dim ino As Integer
Dim GMTime As SYSTEMTIME
Dim TheTime As String
Dim a As Double, b As Double
GetSystemTime GMTime
a = GMTime.wSecond + 0.001 * GMTime.wMilliseconds
For x = 1 To 10000
PortAddress = Val(&H378)
ino = InValue(PortAddress + 1)
Next
GetSystemTime GMTime
Timer1.Interval = 1
b = GMTime.wSecond + 0.001 * GMTime.wMilliseconds
speed = 0.127 / (b - a)
Text1.Text = speed
End Sub
Private Sub stop_click()
Text1.Text = "0"
End Sub
ဒါက Module Code မွာကူးထဲ့
Public Declare Function InValue Lib "inpout32.dll" _
Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Public Declare Sub Out Lib "inpout32.dll" _
Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)
Public Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Public Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
Public Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
အဲဒီမွာပါတဲ့ (&H378) က Parallel port ရဲ႕ Address ပါ။ သူက 8 Channels ရွိပါတယ္။ ေအာက္ကပံုကိုၾကည့္ပါ။ 0x378 ကေန 0x37F ဆိုေတာ့ I/O ၈ လုိင္းကို ထိန္းခ်ဳပ္လို႔ရတဲ့သေဘာေပါ့။
No comments:
Post a Comment