📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BackColor = &H00808000&
Caption = "Interrupt Demo , Using Channel Scan"
ClientHeight = 4680
ClientLeft = 1260
ClientTop = 1884
ClientWidth = 8268
LinkTopic = "Form1"
ScaleHeight = 4680
ScaleWidth = 8268
Begin VB.Frame Frame1
BackColor = &H00FF8080&
Caption = " Board Setting "
Height = 972
Left = 2760
TabIndex = 12
Top = 3120
Width = 2172
Begin VB.TextBox eTotal
Alignment = 1 'Right Justify
BackColor = &H0000FFFF&
Enabled = 0 'False
Height = 288
Left = 600
TabIndex = 14
Text = "0"
Top = 240
Width = 372
End
Begin VB.TextBox eSelect
Alignment = 1 'Right Justify
BackColor = &H0000FF00&
Height = 288
Left = 1680
TabIndex = 13
Text = "0"
Top = 240
Width = 372
End
Begin VB.Label Label4
BackColor = &H00FF8080&
Caption = "Total"
ForeColor = &H00FFFFFF&
Height = 252
Left = 120
TabIndex = 16
Top = 240
Width = 492
End
Begin VB.Label Label7
BackColor = &H00FF8080&
Caption = "Active"
ForeColor = &H00FFFFFF&
Height = 252
Left = 1200
TabIndex = 15
Top = 240
Width = 492
End
End
Begin VB.Frame Frame4
BackColor = &H00FF80FF&
Caption = " Interrupt Setting "
Height = 972
Left = 5040
TabIndex = 7
Top = 3120
Width = 3132
Begin VB.TextBox eSRate
Alignment = 1 'Right Justify
BackColor = &H0000FF00&
Height = 288
Left = 1920
TabIndex = 10
Text = "10"
Top = 600
Width = 852
End
Begin VB.ComboBox cbTriggerMode
BackColor = &H0000FF00&
Height = 288
ItemData = "Form1.frx":0000
Left = 1920
List = "Form1.frx":000A
Style = 2 'Dropdown List
TabIndex = 8
Top = 240
Width = 1092
End
Begin VB.Label Label3
BackColor = &H00FF80FF&
Caption = "Sampling Rate(KHz)"
BeginProperty Font
Name = "MS Sans Serif"
Size = 7.8
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 252
Left = 120
TabIndex = 11
Top = 600
Width = 1932
End
Begin VB.Label Label2
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H00FF80FF&
Caption = "JP4: Trigger Source"
BeginProperty Font
Name = "MS Serif"
Size = 9.6
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 240
Index = 0
Left = 120
TabIndex = 9
Top = 240
Width = 1596
End
End
Begin VB.Frame Frame3
BackColor = &H0080C0FF&
Caption = " Analog Input Setting "
Height = 972
Left = 120
TabIndex = 4
Top = 3120
Width = 2532
Begin VB.ComboBox cbCardType
BackColor = &H0000FF00&
Height = 288
ItemData = "Form1.frx":0028
Left = 1080
List = "Form1.frx":0032
Style = 2 'Dropdown List
TabIndex = 5
Top = 240
Width = 1332
End
Begin VB.Label Label5
BackColor = &H0080C0FF&
Caption = "Card Type"
BeginProperty Font
Name = "MS Sans Serif"
Size = 7.8
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 252
Left = 120
TabIndex = 6
Top = 240
Width = 1092
End
End
Begin VB.Frame Frame2
BackColor = &H00FFFFC0&
Caption = "Analog to Digital Display"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.6
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2892
Left = 120
TabIndex = 2
Top = 120
Width = 8028
Begin VB.PictureBox Gph2
BackColor = &H0080FFFF&
BeginProperty Font
Name = "MS Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000C0&
Height = 1068
Left = 480
ScaleHeight = 1020
ScaleWidth = 7344
TabIndex = 17
Top = 1680
Width = 7392
End
Begin VB.PictureBox Gph
BackColor = &H0080FFFF&
BeginProperty Font
Name = "MS Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000C0&
Height = 1068
Left = 480
ScaleHeight = 1020
ScaleWidth = 7344
TabIndex = 3
Top = 480
Width = 7392
End
Begin VB.Label Label9
BackColor = &H00FFFFC0&
Caption = "-10"
Height = 252
Left = 120
TabIndex = 21
Top = 2520
Width = 252
End
Begin VB.Label Label8
BackColor = &H00FFFFC0&
Caption = "-10"
Height = 252
Left = 120
TabIndex = 20
Top = 1320
Width = 252
End
Begin VB.Label Label6
BackColor = &H00FFFFC0&
Caption = "10"
Height = 252
Left = 120
TabIndex = 19
Top = 1680
Width = 252
End
Begin VB.Label Label1
BackColor = &H00FFFFC0&
Caption = "10"
Height = 252
Left = 120
TabIndex = 18
Top = 480
Width = 252
End
End
Begin VB.CommandButton Command2
Caption = "Active"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.6
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 372
Left = 5040
TabIndex = 1
Top = 4200
Width = 1332
End
Begin VB.CommandButton Command1
Caption = "&Exit"
BeginProperty Font
Name = "Arial"
Size = 10.8
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 372
Left = 6720
TabIndex = 0
Top = 4200
Width = 1452
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const DataNo = 100
Dim fBuf(0 To DataNo * 2 - 1) As Single
Dim wRtn As Integer, wTotalBoards As Integer
Dim hEvent As Long
Dim wCardType As Integer
Dim wCount As Long
Dim wFlag As Integer
Private Sub Command1_Click()
A823_DriverClose
End
End Sub
Private Sub Form_Load()
Dim rtn
Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
'********************************************************************
'* NOTICE: call A823_DriverInit() to initialize the driver. *
'* Initial the device driver, and return the board number in the PC *
'********************************************************************
Command2.Caption = "Active"
Command2.Enabled = False
wRtn = A823_DriverInit(wTotalBoards)
If wRtn <> A823_NoError Then
MsgBox "Can not initial Device Driver!!!"
Exit Sub
End If
If wTotalBoards < 1 Then
MsgBox "Card Not Found!!"
Exit Sub
End If
eTotal.Text = Str(wTotalBoards)
Command2.Enabled = True
cbCardType.ListIndex = 0
cbTriggerMode.ListIndex = 0
Gph.Cls
Gph.Scale (0, -10)-(DataNo, 10)
Gph2.Cls
Gph2.Scale (0, -10)-(DataNo, 10)
End Sub
Private Sub Command2_Click()
Dim i As Integer
Dim c2 As Integer
Dim fTmp As Single
A823_SetTriggerMode cbTriggerMode.ListIndex '0:Internal Trigger 1:External Trigger
c2 = 2 * 1024 / Val(eSRate.Text) 'Used in Internal Trigger Mode
If Command2.Caption = "Active" Then
If A823_ActiveBoard(Val(eSelect.Text)) <> A823_NoError Then
MsgBox "Can not Active the Board."
Exit Sub
End If
wCardType = cbCardType.ListIndex
A823_ChScan_Clear
wRtn = A823_ChScan_Add(2, 0) ' Channel 2, config 0
If wRtn <> A823_NoError Then
MsgBox "Fail to add channel !!"
Exit Sub
End If
wRtn = A823_ChScan_Add(0, 0) ' Channel 0, config 0
If wRtn <> A823_NoError Then
MsgBox "Fail to add channel !!"
Exit Sub
End If
hEvent = CreateEvent(0, False, False, 0)
If hEvent = 0 Then
MsgBox "Create Event Error!!"
Exit Sub
End If
If A823_ChScan_IntInstall(hEvent, DataNo) <> A823_NoError Then
MsgBox "Can not install IRQ."
Exit Sub
End If
Command2.Caption = "Stop"
Command1.Enabled = False
Do While Command2.Caption = "Stop"
'******* Start Interrup ********
wRtn = A823_ChScan_IntStart(c2, wCardType) 'Sampling rate 2M/(c1*c2)
If wRtn <> A823_NoError Then
A823_ChScan_IntStop
Exit Do
End If
Do While Command2.Caption = "Stop"
If WaitForSingleObject(hEvent, 300) = WAIT_OBJECT_0 Then
Exit Do
End If
Sleep (100)
DoEvents
Loop
A823_ChScan_IntStop
If Command2.Caption <> "Stop" Then
Exit Do
End If
wRtn = A823_ChScan_IntGetFloatBuf(fBuf(0))
'******* End Interrup ********
Gph.Cls ' First Channel
Gph.PSet (0, fBuf(0))
For i = 1 To DataNo - 1
Gph.Line -(i, fBuf(i))
Next i
Gph2.Cls ' Second Channel
Gph2.PSet (0, fBuf(DataNo))
For i = 1 To DataNo - 1
Gph2.Line -(i, fBuf(i + DataNo))
Next i
DoEvents
Sleep 100
Loop
A823_ChScan_IntRemove
CloseHandle hEvent
hEvent = 0
Command2.Caption = "Active"
Command1.Enabled = True
Else
Command2.Caption = "Active"
Command1.Enabled = True
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -