EasyManua.ls Logo

Keysight Technologies E3646A - Page 176

Keysight Technologies E3646A
260 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...
5 Application Programs
Example Program for Excel 97
152 E364xA User’s and Service Guide
Private Function OpenPort()
Dim GPIB_Address As String
Dim COM_Address As String
If bGPIB Then
GPIB_Address = "5" ' Select GPIB address between 0 to 30
Else
COM_Address = "1" ' Set the number to 2 for COM2 port
End If
ErrorStatus = viOpenDefaultRM(defaultRM) ' Open the VISA session
If bGPIB Then
ErrorStatus = viOpen(defaultRM, "GPIB0::" & GPIB_Address & "::INSTR", _
0, 1000, power_supply)
Else
ErrorStatus = viOpen(defaultRM, "ASRL" & COM_Address & "::INSTR", _
0, 1000, power_supply)
SendSCPI "System:Remote"
End If
CheckError "Unable to open interface"
End Function
'*********************************************************************************
' This routine sends a SCPI command string to the GPIB interface or RS-232 interface.
' If the command contains a question mark, the response is read, and returned
'**********************************************************************************
Private Function SendSCPI(command As String) As string
Dim commandString As String ' Command passed to power supply
Dim ReturnString As String ' Store the string returned
Dim crlfpos As Integer ' Location of any nul’s in Read Buffer
Dim ReadBuffer As String * 512 ' Buffer used for returned string
Dim actual As Long ' Number of characters sent/returned
commandString = command & Chr$(10) ' The instrumented by linefeed
ErrorStatus = viWrite(power_supply, ByVal commandString, Len(commandString), _
actual)
CheckError "Can’t Write to Device"
If bGPIB = False Then
delay 0.5
End If
If InStr(commandString, "?") Then
ErrorStatus = viRead(power_supply, ByVal ReadBuffer, 512, actual)
CheckError "Can’t Read From Device"
ReturnString = ReadBuffer
crlfpos = InStr(ReturnString, Chr$(0))
If crlfpos Then
ReturnString = Left(ReturnString, crlfpos - 1)
End If
SendSCPI = ReturnString
End If
End Function

Table of Contents

Related product manuals