Agilent Technologies 34901A User Manual page 326

Data acquisition/switch unit
Table of Contents

Advertisement

Chapter 7 Application Programs
Example Programs for Excel 7.0
Excel 7.0 Example: Port Configuration Macro
Option Explicit
' Declarations for VISA.DLL
' Basic I/O Operations
Private Declare Function viOpenDefaultRM Lib "VISA32.DLL" Alias "#141" (sesn As Long) As Long
Private Declare Function viOpen Lib "VISA32.DLL" Alias "#131" (ByVal sesn As Long, _
ByVal desc As String, ByVal mode As Long, ByVal TimeOut As Long, vi As Long) As Long
Private Declare Function viClose Lib "VISA32.DLL" Alias "#132" (ByVal vi As Long) As Long
Private Declare Function viRead Lib "VISA32.DLL" Alias "#256" (ByVal vi As Long, _
ByVal Buffer As String, ByVal Count As Long, retCount As Long) As Long
Private Declare Function viWrite Lib "VISA32.DLL" Alias "#257" (ByVal vi As Long, _
ByVal Buffer As String, ByVal Count As Long, retCount As Long) As Long
' Error Codes
Global Const VI_SUCCESS = 0
' Global Variables
Global videfaultRM As Long
Global vi As Long
Dim errorStatus As Long
Global VISAaddr As String
'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
' This routine requires the file 'VISA32.DLL' which typically resides in the
' c:\windows\system directory on your PC. This routine uses the VTL Library to send
' commands to the instrument. A description of these and additional VTL commands can be
' found in the Agilent VISA User's Guide.
'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Public Sub SendSCPI(SCPICmd As String)
' This routine sends a SCPI command string to the GPIB port. If the command is a
' query command (contains a question mark), you must read the response with 'getScpi'
Dim commandstr As String
Dim actual As Long
'Write the command to the instrument terminated by a line feed
commandstr = SCPICmd & Chr$(10)
errorStatus = viWrite(vi, ByVal commandstr, Len(commandstr), actual)
End Sub
Function getScpi() As String
Dim readbuf As String * 2048
Dim replyString As String
Dim nulpos As Integer
Dim actual As Long
' Read the response string
errorStatus = viRead(vi, ByVal readbuf, 2048, actual)
replyString = readbuf
' Strip out any nul's from the response string
nulpos = InStr(replyString, Chr$(0))
If nulpos Then
replyString = Left(replyString, nulpos - 1)
End If
getScpi = replyString
End Function
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
' Resource manager id for VISA GPIB
' Stores the session for VISA
' VTL error code
' Command passed to instrument
' Number of characters sent/returned
' Buffer used for returned string
' Store the string returned
' Location of any nul's in readbuf
' Number of characters sent/returned
Continued on next page
323
7

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents