主题:数据采集卡的VB程序详细解释说明
Dim Ch0 As String
Dim Am As Integer
Dim T(31) As Double
Dim ChN As String
Private Sub Command1_Click()
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Dim retval As Integer
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Combo1_Click()
Select Case Combo1.ListIndex
Case 0
Am = 0
Case 1
Am = 1
Case 2
Am = 2
Case 3
Am = 3
Case 4
Am = 4
End Select
End Sub
Private Sub Command2_Click()
Call AM9110_WR8254(hPLX9052, 3, &H37&)
Call AM9110_WR8254(hPLX9052, 0, &H0&)
Call AM9110_WR8254(hPLX9052, 0, &H0&)
Call AM9110_WR8254(hPLX9052, 3, &H77&)
Call AM9110_WR8254(hPLX9052, 1, &H4&) '&H0&)
Call AM9110_WR8254(hPLX9052, 1, &H0&) '&H1&)
Call AM9110_WR8254(hPLX9052, 3, &HB6&) '&HB7&)
Call AM9110_WR8254(hPLX9052, 2, &HFF&) '&H2&)
Call AM9110_WR8254(hPLX9052, 2, &HFF&) '&H0&)
Timer2.Interval = 100
Timer2.Enabled = True
Command1.Enabled = False
Command9.Enabled = False
Command6.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command7.Enabled = False
Command5.Enabled = True
End Sub
Private Sub Command3_Click()
Dim data As Integer
data = Val("&H" + Text17.Text)
Call AM9110_DA(hPLX9052, 1, data)
End Sub
Private Sub Command4_Click()
Dim data As Integer
data = Val("&H" + Text24.Text)
Call AM9110_DA(hPLX9052, 0, data)
End Sub
Private Sub ReadDI()
Dim I As Integer
I = AM9110_DI(hPLX9052)
Text21.Text = Hex$(I) '56506Double
If ((I And 1) = 1) Then
Shape17.BackColor = &HFF&
Else
Shape17.BackColor = &HFFFF80
End If
'2
If ((I And 2) = 2) Then
Shape16.BackColor = &HFF&
Else
Shape16.BackColor = &HFFFF80
End If
'3
If ((I And 4) = 4) Then
Shape15.BackColor = &HFF&
Else
Shape15.BackColor = &HFFFF80
End If
'4
If ((I And 8) = 8) Then
Shape13.BackColor = &HFF&
Else
Shape13.BackColor = &HFFFF80
End If
'5
If ((I And 16) = 16) Then
Shape12.BackColor = &HFF&
Else
Shape12.BackColor = &HFFFF80
End If
'6
If ((I And 32) = 32) Then
Shape11.BackColor = &HFF&
Else
Shape11.BackColor = &HFFFF80
End If
'7
If ((I And 64) = 64) Then
Shape10.BackColor = &HFF&
Else
Shape10.BackColor = &HFFFF80
End If
'8
If ((I And 128) = 128) Then
Shape9.BackColor = &HFF&
Else
Shape9.BackColor = &HFFFF80
End If
'9
If ((I And 256) = 256) Then
Shape8.BackColor = &HFF&
Else
Shape8.BackColor = &HFFFF80
End If
'10
If ((I And 512) = 512) Then
Shape7.BackColor = &HFF&
Else
Shape7.BackColor = &HFFFF80
End If
'11
If ((I And 1024) = 1024) Then
Shape6.BackColor = &HFF&
Else
Shape6.BackColor = &HFFFF80
End If
'12
If ((I And 2048) = 2048) Then
Shape5.BackColor = &HFF&
Else
Shape5.BackColor = &HFFFF80
End If
'13
If ((I And 4096) = 4096) Then
Shape4.BackColor = &HFF&
Else
Shape4.BackColor = &HFFFF80
End If
'14
If ((I And 8192) = 8192) Then
Shape3.BackColor = &HFF&
Else
Shape3.BackColor = &HFFFF80
End If
'15
If ((I And 16384) = 16384) Then
Shape2.BackColor = &HFF&
Else
Shape2.BackColor = &HFFFF80
End If
'16
If ((I And 32768) = 32768) Then
Shape1.BackColor = &HFF&
Else
Shape1.BackColor = &HFFFF80
End If
End Sub
Private Sub Command5_Click()
Timer2.Enabled = False
Command1.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command9.Enabled = True
End Sub
Private Sub Command6_Click()
Dim OUT As Double
OUT = Val("&H" & Text22.Text)
Dim retval As Integer
Call AM9110_DO(hPLX9052, OUT)
'1
If ((OUT And 1) = 1) Then
Shape32.BackColor = &HFF&
Else
Shape32.BackColor = &HFFFF80
End If
'2
If ((OUT And 2) = 2) Then
Shape31.BackColor = &HFF&
Else
Shape31.BackColor = &HFFFF80
End If
'3
If ((OUT And 4) = 4) Then
Shape30.BackColor = &HFF&
Else
Shape30.BackColor = &HFFFF80
End If
'4
If ((OUT And 8) = 8) Then
Shape29.BackColor = &HFF&
Else
Shape29.BackColor = &HFFFF80
End If
'5
If ((OUT And 16) = 16) Then
Shape28.BackColor = &HFF&
Else
Shape28.BackColor = &HFFFF80
End If
'6
If ((OUT And 32) = 32) Then
Shape27.BackColor = &HFF&
Else
Shape27.BackColor = &HFFFF80
End If
'7
If ((OUT And 64) = 64) Then
Shape26.BackColor = &HFF&
Else
Shape26.BackColor = &HFFFF80
End If
'8
If ((OUT And 128) = 128) Then
Shape25.BackColor = &HFF&
Else
Shape25.BackColor = &HFFFF80
End If
'9
If ((OUT And 256) = 256) Then
Shape24.BackColor = &HFF&
Else
Shape24.BackColor = &HFFFF80
End If
'10
If ((OUT And 512) = 512) Then
Shape23.BackColor = &HFF&
Else
Shape23.BackColor = &HFFFF80
End If
'11
If ((OUT And 1024) = 1024) Then
Shape22.BackColor = &HFF&
Else
Shape22.BackColor = &HFFFF80
End If
'12
If ((OUT And 2048) = 2048) Then
Shape21.BackColor = &HFF&
Else
Shape21.BackColor = &HFFFF80
End If
'13
If ((OUT And 4096) = 4096) Then
Shape20.BackColor = &HFF&
Else
Shape20.BackColor = &HFFFF80
End If
'14
If ((OUT And 8192) = 8192) Then
Shape19.BackColor = &HFF&
Else
Shape19.BackColor = &HFFFF80
End If
'15
If ((OUT And 16384) = 16384) Then
Shape18.BackColor = &HFF&
Else
Shape18.BackColor = &HFFFF80
End If
'16
If ((OUT And 32768) = 32768) Then
Shape14.BackColor = &HFF&
Else
Shape14.BackColor = &HFFFF80
End If
End Sub
Private Sub Command7_Click()
Unload Form1
Call AM9110_Close(hPLX9052)
End Sub
Private Sub Command9_Click()
Timer1.Enabled = False
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
Text14.Text = ""
Text15.Text = ""
Text16.Text = ""
Text19.Text = ""
Text20.Text = ""
Text25.Text = ""
Text26.Text = ""
Text27.Text = ""
Text28.Text = ""
Text29.Text = ""
Text30.Text = ""
Text31.Text = ""
Text32.Text = ""
Text33.Text = ""
Text34.Text = ""
Text35.Text = ""
Text36.Text = ""
Text37.Text = ""
Text38.Text = ""
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
Combo1.AddItem "1"
Combo1.AddItem "2"
Combo1.AddItem "4"
Combo1.AddItem "8"
Combo1.AddItem "16"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unload Form1
Call AM9110_Close(hPLX9052)
End Sub
Private Sub Timer1_Timer()
T(0) = AM9110_AD(hPLX9052, 0, 1)
Text1.Text = (T(0) And &HFFF&) * 10000 / 4096 / 2
T(1) = AM9110_AD(hPLX9052, 1, 1)
Text2.Text = (T(1) And &HFFF&) * 10000 / 4096 / 2
T(2) = AM9110_AD(hPLX9052, 2, 1)
Text3.Text = (T(2) And &HFFF&) * 10000 / 4096 / 2
T(3) = AM9110_AD(hPLX9052, 3, 1)
Text4.Text = (T(3) And &HFFF&) * 10000 / 4096 / 2
T(4) = AM9110_AD(hPLX9052, 4, 1)
Text5.Text = (T(4) And &HFFF&) * 10000 / 4096 / 2
T(5) = AM9110_AD(hPLX9052, 5, 1)
Text6.Text = (T(5) And &HFFF&) * 10000 / 4096 / 2
T(6) = AM9110_AD(hPLX9052, 6, 1)
Text7.Text = (T(6) And &HFFF&) * 10000 / 4096 / 2
T(7) = AM9110_AD(hPLX9052, 7, 1)
Text8.Text = (T(7) And &HFFF&) * 10000 / 4096 / 2
T(8) = AM9110_AD(hPLX9052, 8, 1)
Text9.Text = (T(8) And &HFFF&) * 10000 / 4096 / 2
T(9) = AM9110_AD(hPLX9052, 9, 1)
Text10.Text = (T(9) And &HFFF&) * 10000 / 4096 / 2
T(10) = AM9110_AD(hPLX9052, 10, 1)
Text11.Text = (T(10) And &HFFF&) * 10000 / 4096 / 2
T(11) = AM9110_AD(hPLX9052, 11, 1)
Text12.Text = (T(11) And &HFFF&) * 10000 / 4096 / 2
T(12) = AM9110_AD(hPLX9052, 12, 1)
Text13.Text = (T(12) And &HFFF&) * 10000 / 4096 / 2
T(13) = AM9110_AD(hPLX9052, 13, 1)
Text14.Text = (T(13) And &HFFF&) * 10000 / 4096 / 2
T(14) = AM9110_AD(hPLX9052, 14, 1)
Text15.Text = (T(14) And &HFFF&) * 10000 / 4096 / 2
T(15) = AM9110_AD(hPLX9052, 15, 1)
Text16.Text = (T(15) And &HFFF&) * 10000 / 4096 / 2
T(16) = AM9110_AD(hPLX9052, 16, 1)
Text19.Text = (T(16) And &HFFF&) * 10000 / 4096 / 2
T(17) = AM9110_AD(hPLX9052, 17, 1)
Text20.Text = (T(17) And &HFFF&) * 10000 / 4096 / 2
'
T(18) = AM9110_AD(hPLX9052, 18, 1)
Text25.Text = (T(18) And &HFFF&) * 10000 / 4096 / 2
T(19) = AM9110_AD(hPLX9052, 19, 1)
Text26.Text = (T(19) And &HFFF&) * 10000 / 4096 / 2
T(20) = AM9110_AD(hPLX9052, 20, 1)
Text27.Text = (T(20) And &HFFF&) * 10000 / 4096 / 2
T(21) = AM9110_AD(hPLX9052, 21, 1)
Text28.Text = (T(21) And &HFFF&) * 10000 / 4096 / 2
T(22) = AM9110_AD(hPLX9052, 22, 1)
Text29.Text = (T(22) And &HFFF&) * 10000 / 4096 / 2
T(23) = AM9110_AD(hPLX9052, 23, 1)
Text30.Text = (T(23) And &HFFF&) * 10000 / 4096 / 2
T(24) = AM9110_AD(hPLX9052, 24, 1)
Text31.Text = (T(24) And &HFFF&) * 10000 / 4096 / 2
T(25) = AM9110_AD(hPLX9052, 25, 1)
Text32.Text = (T(25) And &HFFF&) * 10000 / 4096 / 2
T(26) = AM9110_AD(hPLX9052, 26, 1)
Text33.Text = (T(26) And &HFFF&) * 10000 / 4096 / 2
T(27) = AM9110_AD(hPLX9052, 27, 1)
Text34.Text = (T(27) And &HFFF&) * 10000 / 4096 / 2
T(28) = AM9110_AD(hPLX9052, 28, 1)
Text35.Text = (T(28) And &HFFF&) * 10000 / 4096 / 2
T(29) = AM9110_AD(hPLX9052, 29, 1)
Text36.Text = (T(29) And &HFFF&) * 10000 / 4096 / 2
T(30) = AM9110_AD(hPLX9052, 30, 1)
Text37.Text = (T(30) And &HFFF&) * 10000 / 4096 / 2
T(31) = AM9110_AD(hPLX9052, 31, 1)
Text38.Text = (T(31) And &HFFF&) * 10000 / 4096 / 2
ReadDI
End Sub
Private Sub Timer2_Timer()
Dim data1 As Integer, data2 As Integer, data3 As Integer, data As Double
data1 = AM9110_RD8254(hPLX9052, 2)
data2 = AM9110_RD8254(hPLX9052, 2)
data = CDbl(data1) + 256 * CDbl(data2)
Text18.Text = data
End Sub
代码就是上面这些,看不懂,麻烦有人帮忙解释说明下。另外想问下要怎么学习VB啊?我是利用数据采集卡把采集数据通过A/D(采集卡内带)转换并在电脑上实时显示的VB编程。