EasyManua.ls Logo

Keysight 34972A - Page 259

Keysight 34972A
353 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
Loading...
Application Programs 6
Keysight 34970A/34972A User’s Guide 259
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
Sub OpenPort()
’""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’ Be sure that the GPIB address has been set in the ’VISAaddr’ variable
’ before calling this routine.
’""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’ Open the VISA session
errorStatus = viOpenDefaultRM(videfaultRM)
’ Open communications to the instrument
errorStatus = viOpen(videfaultRM, "GPIB0::" & VISAaddr & "::INSTR", 0, 2500, vi)
’ If an error occurs, give a message
If errorStatus < VI_SUCCESS Then
Range("A2").Select
Cells(1, 1) = "Unable to Open Port"
End If
End Sub
Sub ClosePort()
errorStatus = viClose(vi)
’ Close the session
errorStatus = viClose(videfaultRM)
End Sub
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’ This subroutine is used to create delays. The input is in seconds and
’ fractional seconds are allowed.
’""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Sub delay(delay_time As Single)
Dim Finish As Single
Finish = Timer + delay_time
Do
Loop Until Finish <= Timer
End Sub

Table of Contents

Related product manuals