EasyManua.ls Logo

HP E3633A - Page 142

HP E3633A
175 pages
Print Icon
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...
Chapter 6 Application Programs
Example Program for Excel 97
141
6
Diode Macro
'"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
' This is the subroutine first executed. Modify this routine to suit
' your needs. To change the HP-IB address, go to the module OpenPort, and
' change the variable HPIB_Address = "5” to the required HP-IB address.
' To change the RS-232 port, go to the moudle OpenPort, and change the
' variable COM_Address = "1” to the required port
'"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Global defaultRM As Long ' Resource manager id for VISA HP-IB
Global power_supply As Long ' Identifies power supply
Global bHPIB As Boolean ' A flag using of HP-IB or RS-232
Global ErrorStatus As Long ' VISA Error code
Sub Diode_Click()
Range("B5:B15").ClearContents
Dim I As Integer
bHPIB = True ' To use RS-232, set the bHPIB to False
OpenPort
SendSCPI "*RST" ' Set power-on condition
SendSCPI "Output on" ' Turn on the output
For I = 5 To 15
SendSCPI "Volt " & Str$(Cells(I, 1))
Cells(I, 2) = Val(SendSCPI("Meas:Current?"))
Next I
SendSCPI "Output off" ' Turn off the output
ClosePort
End Sub
Private Function OpenPort()
Dim HPIB_Address As String
Dim COM_Address As String
If bHPIB Then
HPIB_Address = "5" ' Select HP-IB 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 bHPIB Then
ErrorStatus = viOpen(defaultRM, "GPIB0::" & HPIB_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 port"
End Function
Continued on next page

Table of Contents

Related product manuals