Chapter 6 Application Programs
Example Program for Excel 97
142
'*********************************************************************************
' 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 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
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
Содержание E364XA Series
Страница 9: ...8...
Страница 15: ...14 Contents Contents...
Страница 16: ...1 Quick Start...
Страница 26: ...2 General Information...
Страница 38: ...3 Front Panel Operation and Features...
Страница 70: ...4 Remote Interface Reference...
Страница 122: ...5 Error Messages...
Страница 133: ...Chapter 5 Error Messages Calibration Errors 132...
Страница 134: ...6 Application Programs...
Страница 145: ...Chapter 6 Application Programs Example Program for Excel 97 144...
Страница 146: ...7 Tutorial...
Страница 157: ...Chapter 7 Tutorial Remote Programming 156...
Страница 158: ...8 Specifications...
Страница 165: ...Chapter 8 Specifications Supplemental Characteristics 164 Figure 8 2 Dimensions for Rack mounting...
Страница 166: ...Appendix Service Information...
Страница 175: ...Appendix Service Information General Disassembly 174 General Disassembly...
Страница 207: ......
Страница 208: ......
Страница 209: ......
Страница 210: ......
Страница 211: ......
Страница 212: ......
Страница 213: ......
Страница 214: ......
Страница 215: ......
Страница 216: ......
Страница 217: ......
Страница 218: ......