📄 ad.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "ART2001_Form"
ClientHeight = 4605
ClientLeft = 45
ClientTop = 330
ClientWidth = 7860
Icon = "AD.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4605
ScaleWidth = 7860
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text_Val
Height = 330
Index = 3
Left = 6240
TabIndex = 8
Top = 1440
Width = 975
End
Begin VB.TextBox Text_Val
Height = 330
Index = 2
Left = 4440
TabIndex = 7
Top = 1440
Width = 975
End
Begin VB.TextBox Text_Val
Height = 330
Index = 1
Left = 2640
TabIndex = 6
Top = 1440
Width = 975
End
Begin VB.TextBox Text_Val
Height = 330
Index = 0
Left = 840
TabIndex = 2
Top = 1440
Width = 975
End
Begin VB.CommandButton Command1
Caption = "采集数据"
Height = 615
Left = 3240
TabIndex = 0
Top = 2640
Width = 1695
End
Begin VB.Label Label4
Caption = "通道2"
Height = 255
Left = 3840
TabIndex = 5
Top = 1515
Width = 495
End
Begin VB.Label Label3
Caption = "通道3"
Height = 255
Left = 5640
TabIndex = 4
Top = 1515
Width = 495
End
Begin VB.Label Label2
Caption = "通道1"
Height = 255
Left = 2040
TabIndex = 3
Top = 1515
Width = 495
End
Begin VB.Label Label1
Caption = "通道0"
Height = 255
Left = 240
TabIndex = 1
Top = 1515
Width = 495
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim hDevice As Long
Dim DeviceID As Integer
Dim BaseAddress As Integer
Dim DMAChannel As Integer
Dim PerLsbVolt As Single
Dim ADPara As ART2001_PARA_AD
Dim pADBuffer(0 To 65535) As Integer
Dim nReadSizeWords As Integer
Dim nDMABufferOffset As Integer
Dim CurrentIndex As Integer
Dim fVal As Single
Dim str As String
Private Sub Command1_Click()
PerLsbVolt = 20000# / 16384
DeviceID = 0
nReadSizeWords = 2048
BaseAddress = &H280
DMAChannel = 6
hDevice = ART2001_CreateDevice(BaseAddress)
If (hDevice = -1) Then
MsgBox "ART2001_CreateDevice Error..."
Exit Sub
End If
ADPara.ADMode = ART2001_SEQUENCE_MODE ' 连续采集和分组采集方式选择
ADPara.FirstChannel = 0 ' 首通道号
ADPara.LastChannel = 1 ' 末通道号
ADPara.Frequency = 50000 ' 采集频率(Hz)
ADPara.GroupInterval = 1000 ' 组间间隔(uS)
ADPara.Gains = ART2001_1MULT_GAINS ' 增益选择
ADPara.TriggerSource = ART2001_IN_TRIGGER ' 内外触发源选择
ADPara.ClockSource = ART2001_IN_CLOCK ' 时钟源选择
ADPara.GroundingMode = ART2001_SE_MODE ' 接地方式(单端或双端选择)
If (ART2001_InitDeviceDmaAD(hDevice, pADBuffer(0), 65536, ADPara, DMAChannel) = False) Then ' 硬件参数, 它仅在此函数中决定硬件状态
MsgBox ("Init Dma Failure...")
GoTo ExitReleaseDevice
End If
If (ART2001_StartDeviceDmaAD(hDevice) = False) Then
MsgBox ("Start Device Failure...")
GoTo ExitReleaseDeviceDmaAD
End If
nDMABufferOffset = 0
CurrentIndex = 0
While (True)
While (True)
CurrentIndex = ART2001_GetDevIndexDmaAD(hDevice)
If ((CurrentIndex >= nDMABufferOffset) And (CurrentIndex < (nDMABufferOffset + 8192))) Then
Else
GoTo ReadData
End If
Wend
ReadData:
If (ART2001_MapDevBufferDmaAD(hDevice, nDMABufferOffset, 8192) = False) Then
MsgBox ("Map data Failure...")
GoTo ExitReleaseDeviceDmaAD
End If
nDMABufferOffset = nDMABufferOffset + 8192 ' 改变偏移位置
If (nDMABufferOffset >= 65535) Then
nDMABufferOffset = 0
End If
Dim i As Integer
For i = 0 To 3 Step 1
fVal = ((pADBuffer(i) Xor 8192) And 16383) * PerLsbVolt - 10000#
str = fVal
Text_Val(i).Text = Format(str, "0#.00")
'printf("[CH0]=%6.2f\t[CH1]=%6.2f" , ((pADBuffer[i]^0x2000)&0x3FFF)*PerLsbVolt - 10000.0, ((pADBuffer[i+1]^0x2000)&0x3FFF)*PerLsbVolt-10000.0)
Next i
Wend
ExitReleaseDeviceDmaAD:
ART2001_ReleaseDeviceDmaAD (hDevice)
ExitReleaseDevice:
ART2001_ReleaseDevice (hDevice)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -