AGILENT 34970A 与 VB 的通讯
2010-03-05 18:44
在使用AGILENT 34970A 与电脑实现数据采集时,首先要安装 IO LIBRARIES SUITS 15.5 的库程序。然而,在与 VB 实现电脑通讯的时候,在 VB 里还应该做如下的处理,否则,无法实现与 Visual Basic 的通讯。
例如,在使用 agilent 提供的举例程序时,电脑将显示如下的报警:
以上报警的内容表示,在VB中仍然缺少 6 项 打钩的引用。
具体的处理方法如下:
* 首先将需要运行的VB程序调入电脑。
* 增加6 项引用的方法如下:
点击工程之后,点击引用
弹出 引用项,将Visa COM 1.0 type Library 删除,将滚动条向下拉,到并选择Visa COM 3.0 type Library ,之后点击确定。
重新保存程序(再次启动时,就不需要重新再做引用的设定),运行AGILENT举例程序程序.
AGILENT 对于串口的名称定义为 ASRL1::INSTR ( 手册里并没有明确的表示)
如果程序运行时显示的设备名称是 BPIB::9,就把它修改为 ASRL1::INSTR 。
联机调试的现场
联机调试的现场
现在的众多技术手册,无论中英文,都需要你耐着心情去猜想、分析和试验,技术手册很少有写得很清楚的,实在是没有办法。
剩下的编程工作就可以根据具体的要求,进行具体的编写了。
当然,也可以用我编写的串口通讯协议分析软件,来分析AGILENT的通讯内容,再使用MSCOMM控件来编写用户的应用程序。
举例源代码如下:
Option Explicit
''' """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
''' Copyright ?2001,2010 Agilent Technologies Inc. All rights reserved.
'''
''' You have a royalty-free right to use, modify, reproduce and distribute
''' the Sample Application Files (and/or any modified version) in any way
''' you find useful, provided that you agree that Agilent Technologies has no
''' warranty, obligations or liability for any Sample Application Files.
'''
''' Agilent Technologies provides programming examples for illustration only,
''' This sample program assumes that you are familiar with the programming
''' language being demonstrated and the tools used to create and debug
''' procedures. Agilent Technologies support engineers can help explain the
''' functionality of Agilent Technologies software components and associated
''' """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
''' Copyright ?2001,2010 Agilent Technologies Inc. All rights reserved.
'''
''' You have a royalty-free right to use, modify, reproduce and distribute
''' the Sample Application Files (and/or any modified version) in any way
''' you find useful, provided that you agree that Agilent Technologies has no
''' warranty, obligations or liability for any Sample Application Files.
'''
''' Agilent Technologies provides programming examples for illustration only,
''' This sample program assumes that you are familiar with the programming
''' language being demonstrated and the tools used to create and debug
''' procedures. Agilent Technologies support engineers can help explain the
''' functionality of Agilent Technologies software components and associated
''' commands, but they will not modify these samples to provide added
''' functionality or construct procedures to meet your specific needs.
''' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
'
'' You must have a scan list set in the instrument for this example to work
''
'' This example demonstrates how to read the scan list, and how to monitor
'' a channel that is on the scan list.
'' The example also demonstrates how to query the instrument for instrument
'' errors.
''' functionality or construct procedures to meet your specific needs.
''' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
'
'' You must have a scan list set in the instrument for this example to work
''
'' This example demonstrates how to read the scan list, and how to monitor
'' a channel that is on the scan list.
'' The example also demonstrates how to query the instrument for instrument
'' errors.
Dim Daq As VisaComLib.FormattedIO488
Const IO_ADDRESS = "GPIB::9"
Dim m_ioAddress As String
Dim m_ioAddress As String
Private Sub cmdMonitor_Click()
Dim channel As String
Dim channel As String
If isconnected Then
channel = MonitorChannel
Monitor Daq, txtMonitor, channel
InstrumentError Daq
End If
channel = MonitorChannel
Monitor Daq, txtMonitor, channel
InstrumentError Daq
End If
End Sub
connect to和connect with的区别Private Sub cmdRefreshChannels_Click()
' gets the scan list from instrument
' and checks instrument for errors
Me.MousePointer = vbHourglass
If isconnected Then
GetScanList Daq, lstChannel
InstrumentError Daq
End If
Me.cmdMonitor.Enabled = True
InstrumentError Daq
End If
Me.cmdMonitor.Enabled = True
Me.MousePointer = vbDefault
End Sub
Private Function MonitorChannel() As String
' returns the user selected channel to monitor
Dim index As Long
Private Function MonitorChannel() As String
' returns the user selected channel to monitor
Dim index As Long
With lstChannel
index = .ListIndex
index = .ListIndex
If index > 0 Then
MonitorChannel = Right$(.List(index), 3)
Else
MonitorChannel = "Front Panel"
Exit Function
End If
End With
MonitorChannel = Right$(.List(index), 3)
Else
MonitorChannel = "Front Panel"
Exit Function
End If
End With
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论