是德科技
直播中

李宛蔓

8年用户 1047经验值
私信 关注
[问答]

如何通过USB端口和Visual Basic 2010与34972A通信?

大家好,自从我编写任何东西以来已经有一段时间了,我在主题行中找到一些关于此事的好资源有点困难。
总之,我需要在Visual Basic 2010 Express中编写程序。
我将通过USB端口与设备通信,需要设置一个34901A读取模拟电压,另一个34901A读取温度,一个34907A触发数字输出线。
由于我使用的是Visual Basic 2010,看起来我需要使用Ivi.Visa.Interop,但我似乎找不到任何有关如何使用它通过USB与设备通信的资源。
看起来有几种解决方法,比如使用名为Command Expert的东西,但这不是我现在可以使用的选项。
这是我到目前为止所得到的:Imports Ivi.Visa.Interop Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Button1.Click Dim rsc As New ResourceManager Dim sesn As IVisaSession Dim lines
As String()lines = rsc.FindRsrc(“?* INSTR”)sesn = rsc.Open(lines(0),AccessMode.NO_LOCK,2000)End Sub End Class我认为我在下一步遇到一些麻烦。
我熟悉旧的visa32.dll原型,但它看起来像Ivi.Visa.Interop是不同的。
任何帮助,将不胜感激。
-S.Crider

以上来自于谷歌翻译


     以下为原文

  Hello all,

It has been a while since I programmed anything and I am having a little difficulty finding some good resources over the matter in the subject line.   
In short I need to write a program in Visual Basic 2010 Express.  I will be communicating with the device via a USB port and need to set up one 34901A to read analog voltage, another 34901A to read temperature, and one 34907A to trigger a digital out line.  Since I am using Visual Basic 2010, it looks like I need to use Ivi.Visa.Interop but I can't seem to find any resources on how to use it to communicate to the device via the USB.  It looks like there are several work arounds, like using something called Command Expert, but that is not an option I can use presently.  Here is what I got so far:

Imports Ivi.Visa.Interop

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim rsc As New ResourceManager
        Dim sesn As IVisaSession
        Dim lines As String()

        lines = rsc.FindRsrc("?*INSTR")
        sesn = rsc.Open(lines(0), AccessMode.NO_LOCK, 2000)

    End Sub

End Class

I think I am having a little trouble with the next step.  I am familiar with the old visa32.dll protocals but it looks like the Ivi.Visa.Interop is different.  Any help would be appreciated.

-S.Crider  

回帖(12)

姜春阳

2019-6-26 08:41:45
您好S.Crider,您正在使用VISA COM与.NET语言提供的互操作。
您已正确创建资源管理器,现在需要创建FormattedIO488对象来控制3497x。
您将使用其writestring和readstring函数来发送SCPI命令。
首先,您需要将VISA COM 3.0类型库和VISA COM 488.2格式化I / O引用导入到项目中。
这是一个简单的VB.NET VISA COM / USB示例,它发送idn命令:---------------------------- Sub Main()
Dim ioMgr As Ivi.Visa.Interop.ResourceManager Dim instrument As Ivi.Visa.Interop.FormattedIO488 Dim idn As String ioMgr = New Ivi.Visa.Interop.ResourceManager instrument = New Ivi.Visa.Interop.FormattedIO488'创建更多FormatedIO488对象
控制其他仪器在ACE的VISA仪器地址中的位置,常见的别名是USBInstrument1 instrument.IO = ioMgr.Open(“USBInstrument1”)instrument.WriteString(“* IDN?”)'用于发送命令idn = instrument.ReadString
()'用于MsgBox(“IDN字符串是:”& idn,vbOKOnly,“IDN结果”)End Sub -----------------------
---- Agilent Connection Expert附带有关VISA COM使用的文档。
一个很好的入门指南可以在这里找到:http://cp.literature.agilent.com/litweb/pdf/5989-6338EN.pdf有关创建/设置扫描的SCPI VB示例,请参阅34970/34972产品页面
list(它们共享相同的命令)。
下面是一组用于设置DCV /温度扫描列表的SCPI命令-----------------------------#配置3497x数据采集
单元收集温度和直流电压测量。
通过软件触发器启动采集。
此示例测量通道1-10为C型热电偶温度(Celcius)和通道11-20(直流电压)。
##运行说明:#1。设置多路复用器卡进行温度和电压测量(见下文)。
#2。将多路复用器卡插入第一个插槽。
#3。在connect语句中更新仪器地址。
#4。运行序列。
##设置多路复用器卡的说明#1。本例使用20通道多路复用器卡(型号34901A)。
#2。通道1-10保留用于使用J型热电偶测量,而通道11-20#用于直流电压测量。
#3。此示例要求将卡放入第一个插槽。
##要求:#本示例是为Agilent 34970A或34972A数据采集单元编写的。
##操作:#1。重置数据采集单元以清除所有寄存器。
#2。如上所述配置和设置仪器。
#3。运行序列后等待10秒钟以完成测量。
#4。前10个结果测量的是Celcius的温度和最后10个测量电压。
##如果您同意安捷伦科技公司不承担任何保证,义务或责任,您可以以任何有用的方式使用,修改,复制和分发此示例程序(和/或任何修改版本)的免版税权利。
任何示例程序。
(连接“3497x”,“”,“3497x数据采集/数据记录器开关单元/ 1.13”)#复位并清除仪器* RST * CLS#设置通道101至110,用J型热电偶测量温度(C):CONFigure
:TEMPerature TCouple,J,(@ 101:110):UNIT:TEMPerature C,(@ 101:110):SENSe:TEMPerature:TRANsducer:TCouple:RJUNction:TYPE INTernal,(@ 101:110)#Setup channels 111 th 120
以5.5位分辨率读取10V范围内的电压:CONFigure:VOLTage:DC 10,(@ 111:120):SENSe:VOLTage:DC:NPLC 1,(@ 111:120)#Scan Channels 101 thru 120:ROUTe:
SCAN(@ 101:120):TRIGger:COUNt 1:TRIGger:SOURce TIMer#开始触发:INITiate:FORMat:READing:CHANnel 0#等待扫描完成(等待10000ms):DATA:POINts?
#检索10个热数据通道:DATA:REMove?
10#检索10个通道的电压数据:DATA:REMove?
10编辑:2013年4月24日下午2:21连接

以上来自于谷歌翻译


     以下为原文

  Hi S.Crider,

You are using VISA COM with the interop provided for .NET languages.  You have correctly created a resource manager, now you will need to create a FormattedIO488 object to control your 3497x.  You will use its writestring and readstring functions to send SCPI commands.  

You will first need to import the VISA COM 3.0 Type library and the VISA COM 488.2 Formatted I/O reference into your project.  Here is a simple VB.NET VISA COM/USB example that sends the idn command:

----------------------------
   Sub Main()
        Dim ioMgr As Ivi.Visa.Interop.ResourceManager
        Dim instrument As Ivi.Visa.Interop.FormattedIO488
        Dim idn As String
        ioMgr = New Ivi.Visa.Interop.ResourceManager
        instrument = New Ivi.Visa.Interop.FormattedIO488   'create more FormatedIO488 objects to control the other instruments
        'Place in VISA Instrument address for ACE, a common alias is USBInstrument1
        instrument.IO = ioMgr.Open("USBInstrument1")
        instrument.WriteString("*IDN?")  'Use to send commands
        idn = instrument.ReadString()     'Use to 
        MsgBox("The IDN String is: " & idn, vbOKOnly, "IDN Result")
    End Sub
---------------------------

Agilent Connection Expert comes with documentation on the use of VISA COM.  A great getting started guide can be found here:  http://cp.literature.agilent.com/litweb/pdf/5989-6338EN.pdf

Please see the 34970/34972 product pages for SCPI VB examples on creating/setting up a scan list(they share the same commands).  Below is a set of SCPI commands to setup  a scanlist for DCV/Temperature

-----------------------------

# Configure the 3497x Data Acquisition unit to gather temperature and DC voltage measurements. The acquisition is started by a software trigger.  This example measures channels 1-10 for type J thermocouple temperatures in Celcius and channels 11-20 for DC voltage.  

# Instructions for Running:
# 1. Setup the multiplexer card for temperature and voltage measurements(see below). 
# 2. Insert multiplexer card into the first slot.
# 3. Update the instrument address in the connect statement.
# 4. Run the sequence.

# Instructions for setting up the Multiplexer Card
# 1.  This example uses a 20 channel multiplexer card (model 34901A).
# 2.  Channels 1-10 are reserved for using type J thermocouple measurements, while Channels 11-20 
# are used for DC voltage measurements.
# 3.  This example requires the card be placed into the first slot.

# Requirements:
# This example was written for an Agilent 34970A or 34972A Data Acquisition Unit.   

# Operation:
# 1. Reset the Data Acquisition Unit to clear all registers.
# 2. Configure and setup the instrument as explained above.
# 3. Wait 10 seconds for the measurements to complete after running the sequence.
# 4. The first 10 results measure temperature in Celcius and the last 10 measure voltage. 

# You have a royalty-free right to use, modify, reproduce and distribute this example program (and/or any modified version) in any way you find useful, provided you agree that Agilent Technologies has no warranty, obligations, or liability for any example programs.
(Connect "3497x", "", "3497x Data Acquisition / Data Logger Switch Unit / 1.13")
# Reset and clear the instrument
*RST
*CLS
# Setup channels 101 thru 110 to measure temperature (C) with type J thermocouples
:CONFigure:TEMPerature TCouple,J,(@101:110)
:UNIT:TEMPerature C,(@101:110)
:SENSe:TEMPerature:TRANsducer:TCouple:RJUNction:TYPE INTernal,(@101:110)
# Setup channels 111 thru 120 to read voltage on the 10V range with 5.5 digit resolution
:CONFigure:VOLTage:DC 10,(@111:120)
:SENSe:VOLTage:DC:NPLC 1,(@111:120)
# Scan Channels 101 thru 120
:ROUTe:SCAN (@101:120)
:TRIGger:COUNt 1
:TRIGger:SOURce TIMer
# Start trigger
:INITiate
:FORMat:READing:CHANnel 0
# Wait for scan to complete
(Wait 10000ms)
:DATA:POINts?
# Retrieve 10 Channels of thermo data
:DATA:REMove? 10
# Retrieve 10 channels of voltage data
:DATA:REMove? 10

Edited by: connectivity on Apr 24, 2013 2:21 PM
举报

李宛蔓

2019-6-26 08:54:57
大家好,很抱歉我有一段时间没有回复,我在工作中被拉向另一个方向。
无论如何,我可以通过以下链接下载该设备的最新驱动程序:http://www.home.agilent.com/agilent/software.jspx?ckey = 1639533& lc = eng& amp; cc = US& nid =
-11143.0.00& id = 1639533 34972确实附带了安装CD上的驱动程序,但它们已经过时用于Windows 7和vb.net。
说实话,我碰到了几家仍在研究新驱动程序的公司,以及Windows 7和.net的不足之处,所以我想不到以后再检查网站。
安捷伦应考虑在其安装CD中添加一组新驱动程序。
当我完成代码的过程后,我会发布一些可以读取频道的内容。
- S.Crider PS:Thx连接

以上来自于谷歌翻译


     以下为原文

  Hello All,

Sorry I haven't replied in a while, I was pulled in another direction at work.  
Anyhow, I was able to download the latest drivers for the device on the link below:

http://www.home.agilent.com/agilent/software.jspx?ckey=1639533&lc=eng&cc=US&nid=-11143.0.00&id=1639533

The 34972 did come with drivers on the install CD but they were outdated for Windows 7 and for vb.net.    
To be honest, I ran across several companies that are still working on new drivers and what nots for the windows 7 and .net so I did not think to check the website till later on.  
Agilent should think about adding a set of their new drivers to their install CDs.
When I finish going over the code, I post something that will read a channel or something.

- S.Crider

PS: Thx connectivity
举报

李宛蔓

2019-6-26 09:14:09
大家好,这是一个简单的问题。
是否可以对数据记录器进行编程以一次读取多张卡?
我正在设置两个34901A卡 - 一个用于读取电压,另一个用于读取温度。
当我尝试运行代码时,我只从我设置的第二张卡中获取数据,而不是第一张。
试图清理代码发布。
S.Crider

以上来自于谷歌翻译


     以下为原文

  Hello All Again,

Here is a quick question. Is it possible to program the datalogger to read multiple cards at once?
I am setting two 34901A cards - one to read voltage and other to read temperature.
When I try to run the code, I only get the data from the second card I set up, not the first.
Trying to clean up code to post.

S.Crider
举报

李宛蔓

2019-6-26 09:24:49
Hello All Again,看起来它与扫描列表/频道列表有关。
当我配置一张卡时,看起来信息和扫描列表在配置第二张卡时会被覆盖。
我甚至在那个命令专家那里尝试过,同样的事情发生了。
我很确定我只是在忽略某些东西,但我没有看到它。
所以我想问题是如何使用Agilent 34972A在visual basic 2010中配置mulltiple卡?
我已经包含了代码:Imports System Imports System.Runtime.InteropServices Imports Ivi.Visa.Interop Imports Agilent.Agilent34970.Interop Imports Ivi.Driver.Interop Dim rsc As New ResourceManager Dim strRscName As String()Dim strVoltChan As String Dim strTcChan As String
Dim strErrMsg As String Dim strResult()as String Dim dblVoltRes As Double Dim dblVoltRng As Double Dim dblTcRes As Double Dim intErrCode As Integer Dim tcType As Agilent34970ThermocoupleEnum strRscName = rsc.FindRsrc(“?* INSTR”)strVoltChan =“101:120”dblVoltRes
= 10 dblVoltRng = 0.001 strTcChan =“201:220”dblTcRes = 0.1 tcType = Agilent34970ThermocoupleEnum.Agilent34970ThermocoupleTType atalogger.Initialize(strRscName(0),False,True)datalogger.Voltage.DCVoltage.Configure(“101:120”,dblVoltRng,dblVoltRes
)datalogger.Temperature.ConfigureTCouple(strTcChan,tcType,dblTcRes)datalogger.Scan.Initiate()result = datalogger.Scan.Fetch For i = 0 To(result.Length - 1)TextBox1.Text = TextBox1.Text&
“”&
结果(i)接下来我

以上来自于谷歌翻译


     以下为原文

  Hello All Again,

It looks like it has something to do with the scan list/channel list.  
When I configure one card, it looks like the info and scan list gets over written when I configure the second card.  I even tried it in that command expert and the same thing happens.  I am pretty sure I am just overlooking something, but I am not seeing it.  So I guess the question is how to configure mulltiple cards in visual basic 2010 using the Agilent 34972A?

I have included code:


Imports System
Imports System.Runtime.InteropServices
Imports Ivi.Visa.Interop
Imports Agilent.Agilent34970.Interop
Imports Ivi.Driver.Interop

Dim rsc As New ResourceManager   
Dim strRscName As String()   
Dim strVoltChan As String    
Dim strTcChan As String    
Dim strErrMsg As String    
Dim strResult() as String
Dim dblVoltRes As Double                                                               
Dim dblVoltRng As Double                                                                   
Dim dblTcRes As Double                                                                 
Dim intErrCode As Integer                                                                
Dim tcType As Agilent34970ThermocoupleEnum                                                 

strRscName = rsc.FindRsrc("?*INSTR")                                                  

strVoltChan = "101:120"                                                                  
dblVoltRes = 10                                                                           
dblVoltRng = 0.001                                                                        

strTcChan = "201:220"                                                                    
dblTcRes = 0.1                                                                           
tcType = Agilent34970ThermocoupleEnum.Agilent34970ThermocoupleTType                      

atalogger.Initialize(strRscName(0), False, True)          
datalogger.Voltage.DCVoltage.Configure("101:120", dblVoltRng, dblVoltRes)    
datalogger.Temperature.ConfigureTCouple(strTcChan, tcType, dblTcRes)         

   datalogger.Scan.Initiate()
        result = datalogger.Scan.Fetch

        For i = 0 To (result.Length - 1)

            TextBox1.Text = TextBox1.Text & "" & result(i)
        Next i
举报

更多回帖

发帖
×
20
完善资料,
赚取积分