Agilent Technologies E3633A User Manual page 143

Dc power supplies
Hide thumbs Also See for E3633A:
Table of Contents

Advertisement

Chapter 6 Application Programs
Example Program for Excel 97
'*********************************************************************************
' This routine send a SCPI command string to the GPIB port or RS-232 port.
' If the command contains a question mark, the response is read, and returned
'**********************************************************************************
Private Function SendSCPI(command As String) As string
Dim commandString
Dim ReturnString As String
Dim crlfpos As Integer
Dim ReadBuffer As String * 512
Dim actual As Long
commandString = command & Chr$(10)
ErrorStatus = viWrite(power_supply, ByVal commandString, Len(commandString), _
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
Private Function ClosePort()
ErrorStatus = viClose(power_supply)
ErrorStatus = viClose(defaultRM)
End Function
Private Function delay(delay_time As Single)
Dim Finish As Single
Finish = Timer + delay_time
Do
Loop Until Finish <= Timer
End Function
Private Function CheckError(ErrorMessage As String)
If ErrorStatus < VI_SUCCESS Then
Cells(5, 2) = ErrorMessage
ClosePort
End
End If
End Function
End of Program
130
As String
' Command passed to power supply
' Store the string returned
' Location of any nul's in Read Buffer
' Buffer used for returned string
' Number of characters sent/returned
' The instrumented by linefeed
actual)

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

E3634a

Table of Contents