EasyManua.ls Logo

Keysight E3632A - Page 168

Keysight E3632A
196 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
5 Application Programs
Example Program for Excel 5.0 (Windows 3.1 and GPIB)
146 E3632A User’s Guide
GPIB bas Macro
Option Explicit
' - Declarations for VISA.DLL, additional declarations are usually in the
' directory c:\vxipnp\win\include in file visa.bas, also see the VISA manual
Declare Function viOpenDefaultRM Lib "VISA.DLL" Alias "#141" (sesn As Long) As Long
Declare Function viOpen Lib "VISA.DLL" Alias "#131" (ByVal sesn As Long, _
ByVal desc As String, ByVal mode As Long, ByVal TimeOut As Long, vi As Long) As Long
Declare Function viClose Lib "VISA.DLL" Alias "#132" (ByVal vi As Long) As Long
Declare Function viRead Lib "VISA.DLL" Alias "#256" (ByVal vi As Long, _
ByVal Buffer As String, ByVal Count As Long, retCount As Long) As Long
Declare Function viWrite Lib "VISA.DLL" Alias "#257" (ByVal vi As Long, _
ByVal Buffer As String, ByVal Count As Long, retCount As Long) As Long
' Error Codes and other global variables
Global Const VI_SUCCESS = &h0&
Global videfaultRM As Long ' resource manager id for VISA GPIB
Global vi As Long ' stores the session for VISA
Dim errorStatus As Long ' VTL error code
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This routine requires the file VISA.dll. It typically resides under
' the directory c:\windows\system. This routine uses the VTL Library to
' send commands to an instrument. A description of these and additional
' VTL commands are contained in the Hewlett Packard Visa Transition
' Library book Keysight PN E2094-90002.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function SendSCPI(SCPICmd As String) As String
' This function will send a SCPI command string to the
' GPIB port. If the command contains a question mark,
' the response is read, and returned.
Dim readbuf As String * 512 ' buffer used for returned string
Dim crlfpos As Integer ' location of CR's and LF's in readbuf
Dim cmdString As String ' command passed to instrument
Dim ReturnString As String ' string returned from instrument
Dim actual As Long ' number of characters send/returned
'Set up an error handler within this subroutine that will get
'called if an error occurs.
On Error GoTo VIerrorHandler
'Write the command to the instrument terminated by a linefeed.
cmdstring = SCPICmd & Chr$(10)
errorStatus = viWrite(vi, ByVal commandstr, Len(commandstr), actual)

Table of Contents

Other manuals for Keysight E3632A

Related product manuals