ࡱ> HJG "bjbj 7F.((8T"<.^ttttOOO_aaaaaa$!#vOOtt$tt___t 1wK0,6$l6$6$O"qYOOOlOOO6$OOOOOOOOO( H:  Introduction Visual Basic .Net (VB.Net) is a great platform for instrument control applications; the full featured IDE and debugger provide instant productivity gains. The industry-standard instrument control libraries, VISA and VISA COM, are both accessible in VB.Net, so engineers have a choice of which library to use. VISA provides a C-style API for instrument control. Using VISA may be an easier choice for programmers who come from C/C++ backgrounds, or have used VISA in the past. VISA calls are embodied by the visa32 class, which is provided as a standard VB module file in the Agilent IO Libraries Suite (visa32.vb). VISA COM provides a COM-style API for instrument control. Most VB programmers will find that VISA COM fits very well with VBs object-oriented approach. VISA COM functions can be accessed in .Net through the standard Program Interop Assemblies (PIA) that are included in the IVI Shared Components (also installed with the Keysight IO Libraries Suite). For more complete information, see the VISA Users Guide, the VISA Help file, or the VISA COM Help file. These files are included in the Keysight IO Libraries Suite, which you can download from the web at  HYPERLINK "http://www.keysight.com/find/iosuite" www.keysight.com/find/iosuite. Using the VISA library Setup You need to add the visa32.vb file into your Visual Basic .Net project. visa32.vb might be installed in one of many locations, but if you use the following path Visual Studio will be able to find it on any PC (%VXIPNPPATH% is an environment variable): %VXIPNPPATH%winnt\agvisa\include\visa32.vb Code Imports System Imports System.Text Module Module1 Sub Main() ' ID of the VISA Resource Manager session Dim resourceManager As Integer = 0 ' ID of the instrument session Dim session As Integer = 0 ' VISA Address of the instrument Dim instrumentAddress As String = "USB0::2391::1031::MY43000571::0::INSTR" ' Holds the result of the *IDN? query Dim result As StringBuilder = New StringBuilder(256) ' 1) First we need to open a connection to the Resource Manager. It is able to query the PC for what ' interfaces and instruments are available. visa32.viOpenDefaultRM(resourceManager) ' 2) Next we need to open a connection to the instrument. While opening a connection, we can specify ' what instrument we want to connect to, and if we want to get a "lock" on the instrument. Locking ' allows an application, or PC, to have exclusive access to an instrument, but in this simple ' example we don't care about locking. visa32.viOpen( _ resourceManager, instrumentAddress, visa32.VI_NO_LOCK, visa32.VI_TMO_IMMEDIATE, session) ' You only need to enable the termination character if you are using a LAN SOCKET resource or ' a COM ASRL resource. The reason is that SOCKET and ASRL are serial connections, and do not ' have an out-of-band end indicator like GPIB, USB, or VXI-11. If you don't use this line ' with ASRL and SOCKET resources, all of your read's will timeout. visa32.viSetAttribute(session, visa32.VI_ATTR_TERMCHAR_EN, visa32.VI_TRUE) ' 3) In VISA we use viPrintf statements to send data to the instrument. We can then read back the data ' using viScanf statements. visa32.viPrintf(session, "*IDN?" + vbLf) visa32.viScanf(session, "%t", result) ' 4) Write out the data to the screen. Console.WriteLine("*IDN? query: " + result.ToString()) ' 5) It is important to close the instrument session and the Resource Manager session, or the ' instrument and VISA will eventually run out of resources and lock up. visa32.viClose(session) visa32.viClose(resourceManager) Console.ReadKey() End Sub End Module Using the VISA COM library Setup You need to add a reference to the VISA COM Type Library. In Visual Studio 2013, select Project from the menubar, then select Add Reference In the dialog that appears, select COM, then check the box next to VISA COM x.x Type Library and click OK. Code Imports System Imports System.Text ' Namespace for the VISA COM library Imports Ivi.Visa.Interop Module Module1 Sub Main() ' An instance of the Global Resource Manager (GRM) Dim globalResourceManager As ResourceManager = New ResourceManager ' FormattedIO allows us to send formatted IO messages to/from the instrument Dim formattedIO As FormattedIO488 = New FormattedIO488 ' VISA Address of the instrument Dim instrumentAddress As String = "USB0::2391::1031::MY43000571::0::INSTR" ' Holds the result of the *IDN? query Dim result As String = "" ' 1) The Global Resource Manager (GRM) provides a system-view of what interfaces and instruments are ' available on the PC. Using the GRM we will open a connection to our instrument and assign that ' connection to our FormattedIO488 object. This is what allows us to send and receive commands/data. ' While opening a connection, we can specify what instrument we want to connect to, and if we want ' to get a "lock" on the instrument. Locking allows an application, or PC, to have exclusive access ' to an instrument, but in this simple example we don't care about locking. formattedIO.IO = globalResourceManager.Open(instrumentAddress, AccessMode.NO_LOCK, 2000, "") ' You only need to enable the termination character if you are using a LAN SOCKET resource or ' a COM ASRL resource. The reason is that SOCKET and ASRL are serial connections, and do not ' have an out-of-band end indicator like GPIB, USB, or VXI-11. If you don't use this line ' with ASRL and SOCKET resources, all of your read's will timeout. formattedIO.IO.TerminationCharacterEnabled = True ' 2) Using FormattedIO488 allows us to read/write strings and other datatypes to/from the instrument. ' FormattedIO488 is capable of dealing with lists and binary blocks as well as the simple datatypes. formattedIO.WriteString("*IDN?", True) result = formattedIO.ReadString() ' 3) Write the data to the screen Console.WriteLine("*IDN? query: " + result) ' 4) It is important to close the instrument session, or the instrument and VISA COM will eventually ' run out of resources and lock up. formattedIO.IO.Close() Console.ReadKey() End Sub End Module     Using VISA and VISA COM in Visual Basic .Net 2013 Last Revised January 14, 2015 Keysight Technologies, Inc. "+bcde  " { e n ~mmWW*jha^CJOJQJUaJmHnHu!h1 CJOJQJaJmHnHu!h mCJOJQJaJmHnHu+h Sh+oCJOJQJaJmHnHsHu'h Sh mCJOJQJaJmHnHu!ha^CJOJQJaJmHnHuh Sh S5OJQJh+o5OJQJh Sh+o5OJQJ'h Sh+oCJOJQJaJmHnHuE F z    ! I 7$8$H$^gd|. 7$8$H$^gdwy $7$8$H$a$gd1 ^gd1 7$8$H$^`gd1 7$8$H$^gd1 gd S 7$8$H$gd1      0 ±vgUgUC/'h Sh mCJOJQJaJmHnHu"h1 h+o5OJQJmHnHu"h Sh+o5OJQJmHnHuh S5OJQJmHnHuh1 5OJQJmHnHuh Sh SOJQJmHnHuh SOJQJmHnHuh1 h1 CJOJQJaJ!h1 CJOJQJaJmHnHu!ha^CJOJQJaJmHnHu*jha^CJOJQJUaJmHnHu+hetha^0JCJOJQJaJmHnHu0 [ *07IJOPW_ɳݟݟzhO9(!hwyCJOJQJaJmHnHu*hwyB*CJOJQJaJmHnHphu0h+oh mB*CJOJQJaJmHnHphu"h1 h+o5OJQJmHnHu'h Sh+oCJOJQJaJmHnHu!hACJOJQJaJmHnHu'h Sh mCJOJQJaJmHnHu*h\0h\06CJOJQJaJmHnHu'h\0h\0CJOJQJaJmHnHu!h\0CJOJQJaJmHnHu!h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{UBwznʜ"Z xJZp; {/<P;,)''KQk5qpN8KGbe Sd̛\17 pa>SR! 3K4'+rzQ TTIIvt]Kc⫲K#v5+|D~O@%\w_nN[L9KqgVhn R!y+Un;*&/HrT >>\ t=.Tġ S; Z~!P9giCڧ!# B,;X=ۻ,I2UWV9$lk=Aj;{AP79|s*Y;̠[MCۿhf]o{oY=1kyVV5E8Vk+֜\80X4D)!!?*|fv u"xA@T_q64)kڬuV7 t '%;i9s9x,ڎ-45xd8?ǘd/Y|t &LILJ`& -Gt/PK! ѐ'theme/theme/_rels/themeManager.xml.relsM 0wooӺ&݈Э5 6?$Q ,.aic21h:qm@RN;d`o7gK(M&$R(.1r'JЊT8V"AȻHu}|$b{P8g/]QAsم(#L[PK-![Content_Types].xmlPK-!֧6 0_rels/.relsPK-!kytheme/theme/themeManager.xmlPK-!0C)theme/theme/theme1.xmlPK-! ѐ' theme/theme/_rels/themeManager.xml.relsPK] F ?? 0 _VkbT-""!I6l7"" "X8@0(  B S  ?kzlz 9*urn:schemas-microsoft-com:office:smarttagsplace `"+eng*IIBBEELbkn{-..01134679:gkrgIBBEELbkn{-."+Fzeng*IIN_jBBEELbkn{s-..01134679:gkr"+en[_g*07II BBEELbkn{-..01134679:gkr! _u^`OJQJo(hH^`OJQJ^Jo(hHopp^p`OJQJo(hH@ @ ^@ `OJQJo(hH^`OJQJ^Jo(hHo^`OJQJo(hH^`OJQJo(hH^`OJQJ^Jo(hHoPP^P`OJQJo(hH! _         "!D#la^q#VZ+c./@}8f^sf m+owy5\09|.aKHfAH~B MT!'1N/ SW81 S@RZq.0@@Unknown G*Ax Times New Roman5Symbol3. *Cx Arial7. [ @Verdana9=  @ Consolas?= *Cx Courier NewG5  jMS Mincho-3 fg;WingdingsA$BCambria Math"1hs1gJ1)F /F /!4!! 3QHX ?1!xx  Introduction Alan Copeland Alan Copeland Oh+'0t  0 < HT\dlIntroductionAlan Copeland Normal.dotmAlan Copeland5Microsoft Office Word@6F@2=0@<1F՜.+,D՜.+,8 hp|  CCA/ !  Introduction Title 8@ _PID_HLINKSAM%http://www.keysight.com/find/iosuite  !"#%&'()*+,-./012345689:;<=>@ABCDEFIRoot Entry F0 1K1Table$F$WordDocument7FSummaryInformation(7DocumentSummaryInformation8?CompObjr  F Microsoft Word 97-2003 Document MSWordDocWord.Document.89q