Other topics about Sample Programs
This program assigns Port 1 of the E5091A to A, Port 2 to T2, Port 3 to R2, and Port 4 to R2 and sets Line 1 and Line 3 of the control line to HIGH.
See Controlling E5091A by Programming for this programming.
Sub e5091ctrl_Click()
Dim defrm As Long 'Session to Default Resource Manager
Dim vi As Long 'Session to instrument
Dim Port1 As String
Dim Port2 As String
Dim Port3 As String
Dim Port4 As String
Dim Line1 As String
Dim Line2 As String
Dim Line3 As String
Dim Line4 As String
Dim Line5 As String
Dim Line6 As String
Dim Line7 As String
Dim Line8 As String
Dim Data_Bin As String
Dim Data_Dec As Long
Dim i As Integer
Dim X As Long
Dim Model As String
Const TimeOutTime = 20000
Model = "E5091_9" 'Model E5091A-009
Port1 = "A" 'Port1 = A
Port2 = "T2" 'Port2 = T2
Port3 = "R2" 'Port3 = R2
Port4 = "R2" 'Port4 = R2
Line1 = "1" 'Line1 = High
Line2 = "0" 'Line2 = Low
Line3 = "1" 'Line3 = High
Line4 = "0" 'Line4 = Low
Line5 = "0" 'Line5 = Low
Line6 = "0" 'Line6 = Low
Line7 = "0" 'Line7 = Low
Line8 = "0" 'Line8 = Low
Call viOpenDefaultRM(defrm) 'Initializes the VISA system.
Call viOpen(defrm, "GPIB0::17::INSTR", 0, 0, vi) 'Opens the session to the specified instrument.
Call viSetAttribute(vi, VI_ATTR_TMO_VALUE, TimeOutTime) 'The state of an attribute for the specified session.
Call viVPrintf(vi, "*RST" & vbLf, 0) 'Presets the setting state of the ENA.
Call viVPrintf(vi, "*CLS" & vbLf, 0) 'Clears the all status register.
Call viVPrintf(vi, ":SENS1:MULT1:NAME " & Model & vbLf, 0) 'Specifies the test set name.
Call viVPrintf(vi, ":SENS:MULT:PORT1 " & Port1 & vbLf, 0) 'Sets the port assigned to port 1 to A
Call viVPrintf(vi, ":SENS:MULT:PORT2 " & Port2 & vbLf, 0) 'Sets the port assigned to port 2 to T2
Call viVPrintf(vi, ":SENS:MULT:PORT3 " & Port3 & vbLf, 0) 'Sets the port assigned to port 3 to R2
Call viVPrintf(vi, ":SENS:MULT:PORT4 " & Port4 & vbLf, 0) 'Sets the port assigned to port 4 to R2
Call ErrorCheck(vi) 'Checking the error.
Data_Bin = Line8 & Line7 & Line6 & Line5 & Line4 & Line3 & Line2 & Line1
For i = 1 To Len(Data_Bin) 'Creates a decimal setting value.
If Mid(Data_Bin, Len(Data_Bin) - i + 1, 1) = "1" Then
X = 2 ^ (i - 1)
Data_Dec = Data_Dec + X
End If
Next i
Call viVPrintf(vi, ":SENS:MULT:OUTP " & CStr(Data_Dec) & vbLf, 0) 'Sets the control line.
Call viVPrintf(vi, ":SENS:MULT:DISP ON" & vbLf, 0) 'Turns on the E5091A property display.
Call viVPrintf(vi, ":SENS:MULT:STAT ON" & vbLf, 0) 'Turns on the control of the E5091A.
Call ErrorCheck(vi) 'Checking the error.
Call viClose(vi) 'Closes the resource manager session.
Call viClose(defrm) 'Breaks the communication and terminates the VISA system.
End 'End
End Sub
Sub ErrorCheck(vi As Long)
Dim err As String * 50, ErrNo As Variant, Response
Call viVQueryf(vi, ":SYST:ERR?" & vbLf, "%t", err) 'Reads error message.
ErrNo = Split(err, ",") 'Gets the error code.
If Val(ErrNo(0)) <> 0 Then
Response = MsgBox(CStr(ErrNo(1)), vbOKOnly) 'Display the message box.
End If
End Sub
10 DIM Port1$[3],Port2$[3],Port3$[3],Port4$[3],Data_bin$[9]
20 DIM Line1$[3],Line2$[3],Line3$[3],Line4$[3]
30 DIM Line5$[3],Line6$[3],Line7$[3],Line8$[3]
40 DIM Model$[8]
50 INTEGER Data_dec
60 !
70 ASSIGN @Agte507x TO 717
80 !
90 Model$="E5091_9" ! Model:E5091A-009
100 !
110 Port1$="A" ! Port1: A
120 Port2$="T2" ! Port2: T2
130 Port3$="R2" ! Port3: R2
140 Port4$="R2" ! Port4: R2
150 !
160 Line1$="1" ! Line1: HIGH
170 Line2$="0" ! Line2: Low
180 Line3$="1" ! Line3: HIGH
190 Line4$="0" ! Line4: Low
200 Line5$="0" ! Line5: Low
210 Line6$="0" ! Line6: Low
220 Line7$="0" ! Line7: Low
230 Line8$="0" ! Line8: Low
240 !
250 OUTPUT @Agte507x;":SENS1:MULT1:NAME "&Model$
260 !
270 OUTPUT @Agte507x;":SENS1:MULT1:PORT1 "&Port1$
280 OUTPUT @Agte507x;":SENS1:MULT1:PORT2 "&Port2$
290 OUTPUT @Agte507x;":SENS1:MULT1:PORT3 "&Port3$
300 OUTPUT @Agte507x;":SENS1:MULT1:PORT4 "&Port4$
310 !
320 Data_bin$=Line8$&Line7$&Line6$&Line5$&Line4$&Line3$&Line2$&Line1$
330 Data_dec=IVAL(Data_bin$,2)
340 OUTPUT @Agte507x;":SENS1:MULT1:OUTP ";Data_dec
350 !
360 OUTPUT @Agte507x;":SENS:MULT1:DISP ON"
370 OUTPUT @Agte507x;":SENS:MULT1:STAT ON"
380 !
390 END