Specifications

Chapter 15 251
Controlling Peripherals
Programming with VISA
1. Chapter Title
2. Chapter Title 3. Chapter Title
4. Chapter Title
15. Controlling Peripherals
Application program using DC power supply (Agilent E3631A)
The sample program shown below controls the DC power supply (Agilent E3631A)
connected via GPIB while using the E4991A as the system controller. This program is
stored on the sample program disk. Its filename is ext_cont.bas.
NOTE When controlling the DC power supply (Agilent E3631A) from the E4991A macro
(E4991A VBA), VISA is used for communication of the GPIB commands supplied with
the DC power supply (Agilent E3631A). On the other hand, when controlling the E4991A
itself from the E4991A macro (E4991A VBA), the COM interface provided with the
E4991A is used for communication (Lines 120 and 380 in Example 15-1).
Line 100 Assigns settings for the DC power supply output current to a variable.
Line 120 Sets the trigger source of the E4991A to the GPIB trigger via the COM
interface.
Lines 150 to 160 Initializes and starts up the VISA system and outputs the startup
information to the Defrm variable.
Lines 190 to 200 Establishes the connection to the DC power source (GPIB address: 5)
and outputs the connection information to the Dcsp variable.
Lines 230 to 280 Via VISA, sets the DC power supply output current (0.1 A) and
queries the output voltage value at that time.
Lines 310 to 350 Via VISA, reads out the DC power supply output voltage value and
outputs it to the Res variable. Displays the read-out result in the
message box.
Line 380 Via the COM interface, executes a single sweep to the E4991A and
waits for the completion of the sweep.
Line 410 Via VISA, turns off the DC power supply output.
Line 440 Disconnects communication and terminates the VISA system.
Lines 480 to 520 If an error occurs in a VISA function, forces termination of the
program.
Example 15-1 Sample program using a DC power supply
10|
20| Sub main()
30|
40| Dim status As Long 'VISA function status return
code
50| Dim Defrm As Long 'Session to Default Resource
Manager
60| Dim Dcsp As Long 'Session to instrument
70| Dim Cur As Double 'Single to set current level
80| Dim Res As String * 100 'String to hold results
90|
100| Cur = 0.1
110|
120| SCPI.Output "TRIG:SOUR BUS"
130|
140| ' Initializes the VISA system.
150| status = viOpenDefaultRM(Defrm)
160| If (status <> VI_SUCCESS) Then GoTo VisaErrorHandler