EasyManuals Logo

HP 34970A User Manual

HP 34970A
429 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #320 background imageLoading...
Page #320 background image
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 ’ Resource manager id for VISA GPIB
Global vi As Long ’ Stores the session for VISA
Dim errorStatus As Long ’ VTL error code
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 HP VISA User’s Guide (part number E2090-90029).
’""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Public Sub SendSCPI(SCPICmd As String)
’ This routine sends a SCPI command string to the HP-IB port. If the command is a
’ query command (contains a question mark), you must read the response with ’getScpi’
Dim commandstr As String ’ Command passed to instrument
Dim actual As Long ’ Number of characters sent/returned
’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 ’ Buffer used for returned string
Dim replyString As String ’ Store the string returned
Dim nulpos As Integer ’ Location of any nul’s in readbuf
Dim actual As Long ’ Number of characters sent/returned
’ 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
Continued on next page
7
Chapter 7 Application Programs
Example Programs for Excel 7.0
323

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the HP 34970A and is the answer not in the manual?

HP 34970A Specifications

General IconGeneral
BrandHP
Model34970A
CategorySwitch
LanguageEnglish

Related product manuals