📄 ac6112.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 6615
ClientLeft = 60
ClientTop = 345
ClientWidth = 11700
LinkTopic = "Form1"
ScaleHeight = 6615
ScaleWidth = 11700
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton AC6112AD
Caption = "AC6112 AD"
Height = 495
Left = 120
TabIndex = 9
Top = 5520
Width = 2175
End
Begin VB.CommandButton AC6112DA
Caption = "AC6112 DA"
Height = 495
Left = 7800
TabIndex = 8
Top = 2280
Width = 1575
End
Begin VB.CommandButton AC6112DI
Caption = "AC6112 DI"
Height = 495
Left = 7800
TabIndex = 7
Top = 3840
Width = 1575
End
Begin VB.CommandButton AC6112DO
Caption = "AC6112 DO"
Height = 495
Left = 9360
TabIndex = 6
Top = 3840
Width = 1575
End
Begin VB.CommandButton AC6112RTIMER
Caption = "AC6112 RTIMER"
Height = 495
Left = 7080
TabIndex = 5
Top = 5520
Width = 1455
End
Begin VB.CommandButton AC6112RCOUNTER
Caption = "AC6112 RCOUNTER"
Height = 495
Left = 8520
TabIndex = 4
Top = 5520
Width = 1575
End
Begin VB.CommandButton AC6112WCOUNTER
Caption = "AC6112 WCOUNTER"
Height = 495
Left = 10080
TabIndex = 3
Top = 5520
Width = 1575
End
Begin VB.CommandButton AC6112_AD_INT_CHECK
Caption = "AC6112_AD_INT_CHECK"
Height = 495
Left = 2280
TabIndex = 2
Top = 5520
Width = 2175
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 100
Left = 11160
Top = 0
End
Begin VB.TextBox Text1
Height = 375
Left = 0
TabIndex = 1
Text = "Text1"
Top = 840
Width = 7335
End
Begin VB.TextBox Text2
Height = 375
Left = 0
TabIndex = 0
Text = "Text2"
Top = 1680
Width = 7335
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "AC6112示范程序(支持中断采样)"
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
Left = 2400
TabIndex = 10
Top = 120
Width = 6570
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub AC6112_AD_INT_CHECK_Click()
Dim FifoHard(4095) As Long
InitWord.ad_mode = 0
InitWord.ad_timer = 20
InitWord.Event = -1
InitWord.Event_Enable = 0
InitWord.EventFifoFull = -1
InitWord.Irq_Enable = 1
InitWord.start_end_chn = 7 * 32
InitWord.kFifo_Notify_Length = 100000
AC6112_INI hDevice, InitWord
Timer1.Interval = 100
Timer1.Enabled = True
AC6112_RUN hDevice
End Sub
Private Sub AC6112AD_Click()
Dim FifoHard(4095) As Long
InitWord.ad_mode = 0
InitWord.ad_timer = 20
InitWord.Event = -1
InitWord.Event_Enable = 0
InitWord.EventFifoFull = -1
InitWord.Irq_Enable = 0
InitWord.start_end_chn = 0
InitWord.kFifo_Notify_Length = 100000
AC6112_INI hDevice, InitWord
AC6112_RUN hDevice
Do While (StateOf6112.HardwareState And 1) <> 1 '//可根据FIFO状态进行选择(如,FIFO非空,FIFO半满,FIFO溢出)
AC6112_STATE hDevice, StateOf6112 '读AC6112状态(状态位的含义,请参考说明书)
If (StateOf6112.HardwareState And 4) = 0 Then
Print "Fifo overflow"
Exit Do
End If
DoEvents
Loop
Print AC6112_READ_HARD_FIFO(hDevice, FifoHard(0), 1)
Print FifoHard(0)
AC6112_STOP hDevice
End Sub
Private Sub AC6112DA_Click()
Print Null
AC6112_DA_MODE hDevice, 0
AC6112_DA0 hDevice, &HFFF0
AC6112_DA1 hDevice, &H7FF0
End Sub
Private Sub AC6112DI_Click()
Dim Data As Long
AC6112_IO_MODE hDevice, 0
AC6112_DI hDevice, Data
Print Hex(Data)
End Sub
Private Sub AC6112DO_Click()
AC6112_IO_MODE hDevice, 1
AC6112_DO hDevice, &HA5
End Sub
Private Sub AC6112RCOUNTER_Click()
Dim counter_data As Long
AC6112_RCOUNTER hDevice, counter_data
Print counter_data
End Sub
Private Sub AC6112RTIMER_Click()
Dim timer_data As Long
AC6112_RTIMER hDevice, timer_data
Print timer_data
End Sub
Private Sub AC6112WCOUNTER_Click()
AC6112_WCOUNTER hDevice, &HFFFF
End Sub
Private Sub Form_DblClick()
Cls
End Sub
Private Sub Form_Load()
hDevice = AC6112_CreateDevice(0, ErrorOfDriver)
End Sub
Private Sub Form_Unload(Cancel As Integer)
AC6112_STOP hDevice
Timer1.Enabled = False
If hDevice <> -1 Then temp = AC6112_CloseDevice(hDevice)
End Sub
Private Sub Timer1_Timer()
AC6112_STATE hDevice, StateOf6112
Text1.Text = Str(StateOf6112.SoftFifoCapacity) + Str(StateOf6112.SoftFifoItemForRead)
If StateOf6112.SoftFifoItemForWrite < 100000 Then AC6112_STOP hDevice
If StateOf6112.SoftFifoItemForRead >= 100000 Then
Text2.Text = ""
AC6112_READ_KFIFO hDevice, kBuffer(0), 100000 '//从软FIFO中取采样数据,长度为100000个采样点
For i = 0 To 7
Text2.Text = Text2.Text + Str(Int(kBuffer(i)))
Next
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -